decl.c (xref_tag): Only complain once about using a typedef-name with 'struct'.
authorJason Merrill <jason@yorick.cygnus.com>
Tue, 13 Apr 1999 00:10:42 +0000 (00:10 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 Apr 1999 00:10:42 +0000 (20:10 -0400)
* decl.c (xref_tag): Only complain once about using a typedef-name
with 'struct'.  Downgrade to pedwarn.
* decl.c (grokdeclarator): Allow [] syntax for zero-length array.

From-SVN: r26392

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

index a2fe0ce43e35b72c18d65f9d45497d5c2044ed3c..5531d63f4ac8890db5337b7b23156e3ae3bc19ee 100644 (file)
@@ -1,5 +1,10 @@
 1999-04-12  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * decl.c (xref_tag): Only complain once about using a typedef-name
+       with 'struct'.  Downgrade to pedwarn.
+
+       * decl.c (grokdeclarator): Allow [] syntax for zero-length array.
+
        * parse.y (absdcl_intern): New nonterminal.
        (absdcl, direct_abstract_declarator): Use it.
 
index c233079e9b5644665635b7e566d8272df6024e75..89b136793bf5fdd6b64580acba268d19929870cb 100644 (file)
@@ -10090,6 +10090,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            if (type == error_mark_node)
              continue;
 
+           /* VC++ spells a zero-sized array with [].  */
+           if (size == NULL_TREE && decl_context == FIELD && ! staticp)
+             size = integer_zero_node;
+
            if (size)
              {
                /* Must suspend_momentary here because the index
@@ -12354,9 +12358,17 @@ xref_tag (code_type_node, name, globalize)
        {
          if (t)
            {
-             if (t != TYPE_MAIN_VARIANT (t))
+             /* [dcl.type.elab] If the identifier resolves to a
+                typedef-name or a template type-parameter, the
+                elaborated-type-specifier is ill-formed.  */
+             if (t != TYPE_MAIN_VARIANT (t)
+                 || (CLASS_TYPE_P (t) && TYPE_WAS_ANONYMOUS (t)))
                cp_pedwarn ("using typedef-name `%D' after `%s'",
                            TYPE_NAME (t), tag_name (tag_code));
+             else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
+               cp_error ("using template type parameter `%T' after `%s'",
+                         t, tag_name (tag_code));
+
              ref = t;
            }
          else
@@ -12481,19 +12493,6 @@ xref_tag (code_type_node, name, globalize)
 
   TREE_TYPE (ref) = attributes;
 
-  if (ref && TYPE_P (ref))
-    {
-      /* [dcl.type.elab]
-            
-        If the identifier resolves to a typedef-name or a template
-        type-parameter, the elaborated-type-specifier is
-        ill-formed.  */
-      if (TYPE_LANG_SPECIFIC (ref) && TYPE_WAS_ANONYMOUS (ref))
-       cp_error ("`%T' is a typedef name", ref);
-      else if (TREE_CODE (ref) == TEMPLATE_TYPE_PARM)
-       cp_error ("`%T' is a template type paramter", ref);
-    }
-
   return ref;
 }