OSDN Git Service

PR c++/29318
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Oct 2006 04:09:41 +0000 (04:09 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Oct 2006 04:09:41 +0000 (04:09 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117683 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4102503..18958d4 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 b4cede4..0cb825d 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 ce07d43..7952579 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;
+}