From 74766231fd92c0be2d41aa3f99bc4be848de0225 Mon Sep 17 00:00:00 2001 From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 8 Jan 2003 20:00:17 +0000 Subject: [PATCH] * parser.c (cp_parser_primary_expression): See through explicitly scoped ALIAS_DECLs, too. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61054 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 9 +++++---- gcc/testsuite/g++.dg/lookup/anon3.C | 11 +++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lookup/anon3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3435016603ec..2376d13948de 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2003-01-08 Jason Merrill <jason@redhat.com> + + * parser.c (cp_parser_primary_expression): See through explicitly + scoped ALIAS_DECLs, too. + 2003-01-08 Nathanael Nerode <neroden@gcc.gnu.org> * decl.c: ANSIfy function declarations. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f5ada05c0e49..e88045dc117c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3023,14 +3023,15 @@ cp_parser_primary_expression (cp_parser *parser, if (TREE_CODE (decl) == FIELD_DECL || BASELINK_P (decl)) *qualifying_class = parser->scope; } - /* Resolve references to variables of anonymous unions - into COMPONENT_REFs. */ - else if (TREE_CODE (decl) == ALIAS_DECL) - decl = DECL_INITIAL (decl); else /* Transform references to non-static data members into COMPONENT_REFs. */ decl = hack_identifier (decl, id_expression); + + /* Resolve references to variables of anonymous unions + into COMPONENT_REFs. */ + if (TREE_CODE (decl) == ALIAS_DECL) + decl = DECL_INITIAL (decl); } if (TREE_DEPRECATED (decl)) diff --git a/gcc/testsuite/g++.dg/lookup/anon3.C b/gcc/testsuite/g++.dg/lookup/anon3.C new file mode 100644 index 000000000000..2523e0a7dd5f --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/anon3.C @@ -0,0 +1,11 @@ +// Test that anonymous unions work with explicit scope. + +static union +{ + int i; +}; + +int main() +{ + return ::i; +} -- GitLab