OSDN Git Service

PR c++/13791
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 2004 02:21:51 +0000 (02:21 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 2004 02:21:51 +0000 (02:21 +0000)
* 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.

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

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

index 73451be..873a79f 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 b2dfe64..137cede 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 4a498e7..d5cbccb 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>;