typeck2.c (incomplete_type_error): Reorganise to avoid excessive diagnostics.
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 17 Nov 2000 09:48:53 +0000 (09:48 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 17 Nov 2000 09:48:53 +0000 (09:48 +0000)
* typeck2.c (incomplete_type_error): Reorganise to avoid
excessive diagnostics.

From-SVN: r37516

gcc/cp/ChangeLog
gcc/cp/typeck2.c

index a9930eedd647ac1515ff1629eae8b351c4b20c8f..f059212cd3a78381c1234501a57cfed38e7d4bde 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-17  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * typeck2.c (incomplete_type_error): Reorganise to avoid
+       excessive diagnostics.
+
 2000-11-16  Zack Weinberg  <zack@wolery.stanford.edu>
 
        * lex.c (struct impl_files, internal_filename): Constify a char *.
index b030a0504908fff1720e5949f6c2720661ca67fe..60933e385d31f3accaab02e9d6f1ed7935b620f4 100644 (file)
@@ -187,10 +187,18 @@ incomplete_type_error (value, type)
      tree value;
      tree type;
 {
+  int decl = 0;
+  
   /* Avoid duplicate error message.  */
   if (TREE_CODE (type) == ERROR_MARK)
     return;
 
+  if (value != 0 && (TREE_CODE (value) == VAR_DECL
+                    || TREE_CODE (value) == PARM_DECL))
+    {
+      cp_error_at ("`%D' has incomplete type", value);
+      decl = 1;
+    }
 retry:
   /* We must print an error message.  Be clever about what it says.  */
 
@@ -199,12 +207,13 @@ retry:
     case RECORD_TYPE:
     case UNION_TYPE:
     case ENUMERAL_TYPE:
-      cp_error ("invalid use of undefined type `%#T'", type);
+      if (!decl)
+        cp_error ("invalid use of undefined type `%#T'", type);
       cp_error_at ("forward declaration of `%#T'", type);
       break;
 
     case VOID_TYPE:
-      cp_error ("invalid use of void expression");
+      cp_error ("invalid use of `%T'", type);
       break;
 
     case ARRAY_TYPE:
@@ -239,10 +248,6 @@ retry:
     default:
       my_friendly_abort (108);
     }
-
-  if (value != 0 && (TREE_CODE (value) == VAR_DECL
-                    || TREE_CODE (value) == PARM_DECL))
-    cp_error_at ("incomplete `%D' defined here", value);
 }
 
 /* This is a wrapper around fancy_abort, as used in the back end and