re PR c++/13791 (ICE in layout_type with packed types)
authorMark Mitchell <mark@codesourcery.com>
Thu, 29 Jan 2004 02:21:51 +0000 (02:21 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 29 Jan 2004 02:21:51 +0000 (02:21 +0000)
PR c++/13791
* typeck.c (merge_types): Do not merge attributes into
TYPENAME_TYPEs.

2004-01-28  Mark Mitchell  <mark@codesourcery.com>

PR c++/13791
* g++.dg/ext/attrib12.C: New test.

From-SVN: r76837

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

index 73451be58df1e336eff99bbbb84347c8c8d73cdc..873a79fd1aa6167ae8c9ba810402ae2d17512f5b 100644 (file)
@@ -1,5 +1,9 @@
 2004-01-28  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13791
+       * typeck.c (merge_types): Do not merge attributes into
+       TYPENAME_TYPEs.
+
        PR c++/13736
        * parser.c (cp_parser_direct_declarator): Do not prevent
        backtracking inside a parenthesized declarator.
index b2dfe647a6bd99c8026314034661f13eb74cc2bc..137cedede721cca016384daf0a4ec86c3030774c 100644 (file)
@@ -714,6 +714,12 @@ merge_types (tree t1, tree t2)
        break;
       }
 
+    case TYPENAME_TYPE:
+      /* There is no need to merge attributes into a TYPENAME_TYPE.
+        When the type is instantiated it will have whatever
+        attributes result from the instantiation.  */
+      return t1;
+
     default:;
     }
   return build_type_attribute_variant (t1, attributes);
index 4a498e761ab11a647abdbc1a069d8bda0611d2b5..d5cbccb74424fba4a4003b357252a84b70d11d6b 100644 (file)
@@ -1,5 +1,8 @@
 2004-01-28  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13791
+       * g++.dg/ext/attrib12.C: New test.
+
        PR c++/13736
        * g++.dg/parse/cast2.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/ext/attrib12.C b/gcc/testsuite/g++.dg/ext/attrib12.C
new file mode 100644 (file)
index 0000000..aea9378
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/13791
+
+template <typename T> struct O {
+  struct __attribute__((packed)) I {
+    int i;
+    char c;
+  };
+
+  I* foo();
+};
+
+template <typename T>
+typename O<T>::I*
+O<T>::foo() { return 0; }
+
+template class O<int>;