parser.c (cp_parser_primary_expression): See through explicitly scoped ALIAS_DECLs...
authorJason Merrill <jason@redhat.com>
Wed, 8 Jan 2003 20:00:17 +0000 (15:00 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 8 Jan 2003 20:00:17 +0000 (15:00 -0500)
        * parser.c (cp_parser_primary_expression): See through explicitly
        scoped ALIAS_DECLs, too.

From-SVN: r61054

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/lookup/anon3.C [new file with mode: 0644]

index 3435016..2376d13 100644 (file)
@@ -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.
index f5ada05..e88045d 100644 (file)
@@ -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 (file)
index 0000000..2523e0a
--- /dev/null
@@ -0,0 +1,11 @@
+// Test that anonymous unions work with explicit scope.
+
+static union
+{
+  int i;
+};
+
+int main()
+{
+  return ::i;
+}