re PR c++/19508 (dwarf2, ICE on __attribute__(aligned) in class template)
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Fri, 18 Feb 2005 19:11:58 +0000 (19:11 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 18 Feb 2005 19:11:58 +0000 (11:11 -0800)
2005-01-20  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        PR c++/19508
        * g++.dg/ext/attrib20.C: New test.

2005-01-20  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        PR c++/19508
        * decl2.c (grokfield): Do not apply attributes to template parameters
        as they are ignored by tsubst anyway.

From-SVN: r95230

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

index 61cd6702c302b8ae6dd06dfea4b4ed81efa771e6..ab452e996db45ea6bb93600aedce5a9b86a7bf3b 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-20  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/19508
+       * decl2.c (grokfield): Do not apply attributes to template parameters
+       as they are ignored by tsubst anyway.
+
 2005-02-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/19813
index c7b04150e8f11beb9f1780e8526ade10699b691b..113386a880f97a64d0da76b7dfc91dc7c79d5713 100644 (file)
@@ -878,7 +878,16 @@ grokfield (const cp_declarator *declarator,
        value = push_template_decl (value);
 
       if (attrlist)
-       cplus_decl_attributes (&value, attrlist, 0);
+       {
+         /* Avoid storing attributes in template parameters:
+            tsubst is not ready to handle them.  */
+         tree type = TREE_TYPE (value);
+         if (TREE_CODE (type) == TEMPLATE_TYPE_PARM
+             || TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM)
+           sorry ("applying attributes to template parameters is not implemented");
+         else
+           cplus_decl_attributes (&value, attrlist, 0);
+       }
 
       return value;
     }
index 581e21a9028b92220318bfb2810799bfbf17cbf0..5eb642ece8679bf7ebfdffebc258128decd2b90d 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-20  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+        PR c++/19508
+        * g++.dg/ext/attrib20.C: New test.
+
 2004-02-18  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR middle-end/20030
diff --git a/gcc/testsuite/g++.dg/ext/attrib20.C b/gcc/testsuite/g++.dg/ext/attrib20.C
new file mode 100644 (file)
index 0000000..e46e8ae
--- /dev/null
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-g" }
+// Origin: <jan at etpmod dot phys dot tue dot nl>
+// PR c++/19508: avoid attributes for template parameters
+
+template <typename T>
+struct BVector
+{
+  typedef T T2;
+  typedef T value_type __attribute__ ((aligned(8)));    // { dg-bogus "attribute" "attribute" { xfail *-*-* } }
+  typedef T2 value_type2 __attribute__ ((aligned(8)));  // { dg-bogus "attribute" "attribute" { xfail *-*-* } }
+  value_type v;
+};
+BVector<int> m;
+
+template <template <class> class T>
+struct BV2
+{
+  typedef T<float> value_type __attribute__((aligned(8))); // { dg-bogus "attribute" "attribute" { xfail *-*-* } }
+  value_type v;
+};
+BV2<BVector> m2;
+