decl.c (create_array_type_for_decl): Check if NAME is NULL_TREE when displaying error...
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Sun, 18 Nov 2001 06:31:20 +0000 (06:31 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Sun, 18 Nov 2001 06:31:20 +0000 (06:31 +0000)
* decl.c (create_array_type_for_decl): Check if NAME is NULL_TREE
when displaying error message about missing array bounds.

From-SVN: r47136

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/other/array1.C [new file with mode: 0644]

index 6503ad8..a388f51 100644 (file)
@@ -1,5 +1,10 @@
 2001-11-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
+       * decl.c (create_array_type_for_decl): Check if NAME is NULL_TREE
+       when displaying error message about missing array bounds.
+
+2001-11-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
        * mangle.c (write_expression): Handle CAST_EXPR, STATIC_CAST_EXPR,
        CONST_CAST_EXPR.
        * operators.def: Add CAST_EXPR, STATIC_CAST_EXPR, CONST_CAST_EXPR.
index ed6b6bf..f7448f5 100644 (file)
@@ -9476,8 +9476,11 @@ create_array_type_for_decl (name, type, size)
      can be omitted only for the first member of the sequence.  */
   if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type))
     {
-      cp_error ("declaration of `%D' as multidimensional array must have bounds for all dimensions except the first",
-               name);
+      if (name)
+       cp_error ("declaration of `%D' as multidimensional array must have bounds for all dimensions except the first",
+                 name);
+      else
+       cp_error ("multidimensional array must have bounds for all dimensions except the first");
 
       return error_mark_node;
     }
diff --git a/gcc/testsuite/g++.dg/other/array1.C b/gcc/testsuite/g++.dg/other/array1.C
new file mode 100644 (file)
index 0000000..aff960e
--- /dev/null
@@ -0,0 +1,10 @@
+// Test typeid of multidimensional array with no bounds.
+// { dg-do compile }
+
+#include <typeinfo>
+
+int main()
+{
+       const char *s = typeid(double[][]).name(); // { dg-error "bounds|confused" }
+       return 0;
+}