re PR c++/29318 (ICE: type_info of pointer to VLA)
authorMark Mitchell <mark@codesourcery.com>
Fri, 13 Oct 2006 04:09:41 +0000 (04:09 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 13 Oct 2006 04:09:41 +0000 (04:09 +0000)
PR c++/29318
* rtti.c (get_tinfo_decl): Refuse to create type info objects for
variably modified types.
PR c++/29318
* g++.dg/ext/vla4.C: New test.

From-SVN: r117683

gcc/cp/ChangeLog
gcc/cp/rtti.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/vla4.C [new file with mode: 0644]

index 4102503dea8dca52c46cd73346f66d6b54781f9b..18958d46baba4ece818fa90a63bc9506a0795d8a 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-12  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/29318
+       * rtti.c (get_tinfo_decl): Refuse to create type info objects for
+       variably modified types.
+
 2006-10-12 Lee Millward <lee.millward@codesourcery.com>
 
        PR c++/27961
index b4cede48b06929fbeb09e84cd08c08d147f5b6ed..0cb825dd1997ad4edec4975908938a6c5b08b84f 100644 (file)
@@ -342,11 +342,10 @@ get_tinfo_decl (tree type)
   tree name;
   tree d;
 
-  if (COMPLETE_TYPE_P (type)
-      && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
+  if (variably_modified_type_p (type, /*fn=*/NULL_TREE))
     {
       error ("cannot create type information for type %qT because "
-            "its size is variable",
+            "it involves types of variable size",
             type);
       return error_mark_node;
     }
index ce07d43a4f14d90b6b6423a46b0a90719de2faa1..7952579c81da11f4c13f777782e46053ab690638 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-12  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/29318
+       * g++.dg/ext/vla4.C: New test.
+
 2006-10-12 Lee Millward <lee.millward@codesourcery.com>
 
        PR c++/27961
diff --git a/gcc/testsuite/g++.dg/ext/vla4.C b/gcc/testsuite/g++.dg/ext/vla4.C
new file mode 100644 (file)
index 0000000..8b7f38f
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/29318
+// { dg-options "" }
+
+#include <typeinfo>
+
+void f(int i) {
+  try {
+    int a[i];
+    throw &a; // { dg-error "variable size" }
+  } catch (int (&)[i]) { // { dg-error "variable size" }
+  }
+}
+
+int main()
+{
+  int i = 5;
+  int va[i];
+  const std::type_info& info(typeid(&va)); // { dg-error "variable size" }
+
+  return 0;
+}