From 8d2eb30433ecedf4db7e00b62320973a587f4216 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 13 Feb 2008 16:27:16 -0500 Subject: [PATCH] PR c++/34962, c++/34937, c++/34939 PR c++/34962, c++/34937, c++/34939 * decl2.c (is_late_template_attribute): Always defer attributes vector_size and weak. From-SVN: r132297 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl2.c | 7 +++++++ gcc/testsuite/g++.dg/ext/tmplattr9.C | 25 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/tmplattr9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 65bf6234f9e..38f951032e6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2008-02-13 Jason Merrill + PR c++/34962, c++/34937, c++/34939 + * decl2.c (is_late_template_attribute): Always defer attributes + vector_size and weak. + PR c++/34774 * pt.c (value_dependent_expression_p): Look into DECL_INITIAL of enumerators, too. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 1832926eb31..695390ce78f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -991,6 +991,13 @@ is_late_template_attribute (tree attr, tree decl) /* Unknown attribute. */ return false; + /* Attribute vector_size handling wants to dive into the back end array + building code, which breaks during template processing. */ + if (is_attribute_p ("vector_size", name) + /* Attribute weak handling wants to write out assembly right away. */ + || is_attribute_p ("weak", name)) + return true; + /* If any of the arguments are dependent expressions, we can't evaluate the attribute until instantiation time. */ for (arg = args; arg; arg = TREE_CHAIN (arg)) diff --git a/gcc/testsuite/g++.dg/ext/tmplattr9.C b/gcc/testsuite/g++.dg/ext/tmplattr9.C new file mode 100644 index 00000000000..721ccefecf8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/tmplattr9.C @@ -0,0 +1,25 @@ +// PR c++/34937, 34962 +// { dg-options "" } + +struct A +{ + static const int i; +}; + +template void foo() +{ + int x[A::i] __attribute((vector_size(8))); +} + +template struct B +{ + enum { a, b = a }; + void bar(B) __attribute((weak)); +}; + +void f() +{ + foo<0>(); + B<0> b; + b.bar (B::b>()); +} -- 2.30.2