decl.c (grokdeclarator): Allow anonymous types to be cv-qualified.
authorBenjamin Kosnik <bkoz@loony.cygnus.com>
Mon, 17 Aug 1998 15:44:47 +0000 (15:44 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Mon, 17 Aug 1998 15:44:47 +0000 (15:44 +0000)
1998-08-17  Benjamin Kosnik  <bkoz@loony.cygnus.com>
* decl.c (grokdeclarator): Allow anonymous types to be cv-qualified.
fixes g++/16824

From-SVN: r21791

gcc/cp/ChangeLog
gcc/cp/decl.c

index a356da2ab55461f038e0f95d705f30747330f04b..3f3fa49bf9b4ed19077dee191a1335ef2eec88f8 100644 (file)
@@ -1,3 +1,7 @@
+1998-08-17  Benjamin Kosnik  <bkoz@loony.cygnus.com>
+
+       * decl.c (grokdeclarator): Allow anonymous types to be cv-qualified.
+
 Mon Aug 17 10:40:18 1998  Jeffrey A Law  (law@cygnus.com)
 
        * cp-tree.h (set_identifier_local_value): Provide prototype.
index 1fa4abf70d29fbf472e7fdc2719febe68d097fcf..ccaf75732d3bd63009bf37f2ff39c4425da4f20f 100644 (file)
@@ -9957,11 +9957,16 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
         refer to it, so nothing needs know about the name change.
         The TYPE_NAME field was filled in by build_struct_xref.  */
       if (type != error_mark_node
-         && !TYPE_READONLY (type) && !TYPE_VOLATILE (type)
          && TYPE_NAME (type)
          && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
          && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
        {
+         /* For anonymous structs that are cv-qualified, need to use
+             TYPE_MAIN_VARIANT so that name will mangle correctly. As
+             type not referenced after this block, don't bother
+             resetting type to original type, ie. TREE_TYPE (decl). */
+         type = TYPE_MAIN_VARIANT (type);
+
          /* Replace the anonymous name with the real name everywhere.  */
          lookup_tag_reverse (type, declarator);
          TYPE_NAME (type) = decl;