From a26ddf116ec21df0a1e74c888d469647b6f2f396 Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Wed, 19 Jan 2005 14:30:21 +0000 Subject: [PATCH] re PR c++/19375 (Access violation diagnostic given twice) PR c++/19375 * semantics.c (finish_id_expression): Disable access checking for already lookuped FIELD_DECL. From-SVN: r93897 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 27 +++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dc11ad8a131..96ddad70ee0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-01-19 Kriang Lerdsuwanakij + + PR c++/19375 + * semantics.c (finish_id_expression): Disable access checking for + already lookuped FIELD_DECL. + 2005-01-18 Kazu Hirata * decl.c (delete_block): Remove. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2dc0cbb9ff0..ce7233fe540 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3,7 +3,7 @@ building RTL. These routines are used both during actual parsing and during the instantiation of template functions. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 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. @@ -2639,9 +2639,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; } @@ -2706,8 +2714,15 @@ finish_id_expression (tree id_expression, } } 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); -- 2.30.2