]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/19375 (Access violation diagnostic given twice)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Wed, 19 Jan 2005 14:50:24 +0000 (14:50 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Wed, 19 Jan 2005 14:50:24 +0000 (14:50 +0000)
PR c++/19375
* semantics.c (finish_id_expression): Disable access checking for
already lookuped FIELD_DECL.

From-SVN: r93899

gcc/cp/ChangeLog
gcc/cp/semantics.c

index 885d5d1178fd06a3d3bb21fe6bea2d16a61a797b..0103228ee0038bf0a736ca54e27a66c39b7d4db5 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-19  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/19375
+       * semantics.c (finish_id_expression): Disable access checking for
+       already lookuped FIELD_DECL.
+
 2005-01-19  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/19258
index cf207102749b5da4d4a4ae0ddb32c2ff90186400..45fa695f294db81cf208716ed91ab2cc2eaa58b1 100644 (file)
@@ -4,7 +4,7 @@
    and during the instantiation of template functions. 
 
    Copyright (C) 1998, 1999, 2000, 2001, 2002,
-   2003, 2004 Free Software Foundation, Inc.
+   2003, 2004, 2005 Free Software Foundation, Inc.
    Written by Mark Mitchell (mmitchell@usa.net) based on code found
    formerly in parse.y and pt.c.  
 
@@ -2561,9 +2561,17 @@ finish_id_expression (tree id_expression,
          /* The same is true for FIELD_DECL, but we also need to
             make sure that the syntax is correct.  */
          else if (TREE_CODE (decl) == FIELD_DECL)
-           return finish_non_static_data_member
-                    (decl, current_class_ref,
-                     /*qualifying_scope=*/NULL_TREE);
+           {
+             /* Since SCOPE is NULL here, this is an unqualified name.
+                Access checking has been performed during name lookup
+                already.  Turn off checking to avoid duplicate errors.  */
+             push_deferring_access_checks (dk_no_check);
+             decl = finish_non_static_data_member
+                      (decl, current_class_ref,
+                       /*qualifying_scope=*/NULL_TREE);
+             pop_deferring_access_checks ();
+             return decl;
+           }
          return id_expression;
        }
 
@@ -2623,8 +2631,15 @@ finish_id_expression (tree id_expression,
            decl = build (SCOPE_REF, TREE_TYPE (decl), scope, decl);
        }
       else if (TREE_CODE (decl) == FIELD_DECL)
-       decl = finish_non_static_data_member (decl, current_class_ref,
-                                             /*qualifying_scope=*/NULL_TREE);
+       {
+         /* Since SCOPE is NULL here, this is an unqualified name.
+            Access checking has been performed during name lookup
+            already.  Turn off checking to avoid duplicate errors.  */
+         push_deferring_access_checks (dk_no_check);
+         decl = finish_non_static_data_member (decl, current_class_ref,
+                                               /*qualifying_scope=*/NULL_TREE);
+         pop_deferring_access_checks ();
+       }
       else if (is_overloaded_fn (decl))
        {
          tree first_fn = OVL_CURRENT (decl);