re PR c++/20028 (class and then template class gives an ICE)
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 17 Feb 2005 19:25:05 +0000 (19:25 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 17 Feb 2005 19:25:05 +0000 (19:25 +0000)
gcc/cp/ChangeLog:
PR c++/20028
* class.c (finish_struct): Initialize TYPE_SIZE_UNIT of a
template along with TYPE_SIZE.
gcc/testsuite/ChangeLog:
PR c++/20028
* g++.dg/template/crash34.C: New.

From-SVN: r95182

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash34.C [new file with mode: 0644]

index f1406be7438301f5e4263d4bd665ca09d6d5d8dd..cdbbfa51d809288bbc7fad86ce233dba9440726e 100644 (file)
@@ -1,5 +1,9 @@
 2005-02-17  Alexandre Oliva  <aoliva@redhat.com>
 
+       PR c++/20028
+       * class.c (finish_struct): Initialize TYPE_SIZE_UNIT of a
+       template along with TYPE_SIZE.
+
        PR c++/20022
        * semantics.c (perform_deferred_access_checks): Use
        get_deferred_access_checks to get the top of the stack.
index ae73f5221211fd0652823aebf7eaf79e98991150..77e9b80f4f9a49712af15c1c626d3df1f8980c0a 100644 (file)
@@ -5111,6 +5111,7 @@ finish_struct (tree t, tree attributes)
 
       finish_struct_methods (t);
       TYPE_SIZE (t) = bitsize_zero_node;
+      TYPE_SIZE_UNIT (t) = size_zero_node;
 
       /* We need to emit an error message if this type was used as a parameter
         and it is an abstract type, even if it is a template. We construct
index 4d58a1082335a2227f8b87c897753a407426d448..d03c81fa06f84a6d24a691886b67b2264ba6a114 100644 (file)
@@ -1,5 +1,8 @@
 2005-02-17  Alexandre Oliva  <aoliva@redhat.com>
 
+       PR c++/20028
+       * g++.dg/template/crash34.C: New.
+
        PR c++/20022
        * g++.dg/other/access3.C: New.
 
diff --git a/gcc/testsuite/g++.dg/template/crash34.C b/gcc/testsuite/g++.dg/template/crash34.C
new file mode 100644 (file)
index 0000000..9cca62f
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+// PR c++/20028
+
+// We used to crash when referencing TYPE_SIZE_UNIT of the messed-up
+// type used for x, because it was not initialized.
+
+class Foo;
+
+template <typename T> class Foo { }; // { dg-error "not a template type" }
+
+Foo<int> x; // { dg-error "not a template" }