diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-24 14:41:32 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-24 14:41:32 +0000 |
commit | b2f4debb2d986bcbfe64142d5b7c41e06a19eacf (patch) | |
tree | 744a3147c6bfa7e64ba5a4159c09675fbe49a5c4 | |
parent | 0af13ed4509da54103f1565411beb70794f842a4 (diff) | |
download | gcc-b2f4debb2d986bcbfe64142d5b7c41e06a19eacf.tar.gz |
PR c++/34913
* decl2.c (is_late_template_attribute): Defer any attribute with
dependent args. Also defer type attributes if the type is dependent.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131779 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vector11.C | 6 |
3 files changed, 30 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 667f813b594..b6593cfa04a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-01-24 Jason Merrill <jason@redhat.com> + + PR c++/34913 + * decl2.c (is_late_template_attribute): Defer any attribute with + dependent args. Also defer type attributes if the type is dependent. + 2008-01-22 Jakub Jelinek <jakub@redhat.com>, Alexandre Oliva <aoliva@redhat.com> PR c++/33984 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 97b3ee0f3f2..550d0bcebab 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -985,17 +985,25 @@ is_late_template_attribute (tree attr, tree decl) tree name = TREE_PURPOSE (attr); tree args = TREE_VALUE (attr); const struct attribute_spec *spec = lookup_attribute_spec (name); + tree arg; if (!spec) /* Unknown attribute. */ return false; - if (is_attribute_p ("aligned", name) - && args - && value_dependent_expression_p (TREE_VALUE (args))) - /* Can't apply this until we know the desired alignment. */ - return true; - else if (TREE_CODE (decl) == TYPE_DECL || spec->type_required) + /* 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)) + { + tree t = TREE_VALUE (arg); + if (value_dependent_expression_p (t) + || type_dependent_expression_p (t)) + return true; + } + + if (TREE_CODE (decl) == TYPE_DECL + || TYPE_P (decl) + || spec->type_required) { tree type = TYPE_P (decl) ? decl : TREE_TYPE (decl); @@ -1006,6 +1014,10 @@ is_late_template_attribute (tree attr, tree decl) || code == BOUND_TEMPLATE_TEMPLATE_PARM || code == TYPENAME_TYPE) return true; + /* Also defer attributes on dependent types. This is not necessary + in all cases, but is the better default. */ + else if (dependent_type_p (type)) + return true; else return false; } diff --git a/gcc/testsuite/g++.dg/ext/vector11.C b/gcc/testsuite/g++.dg/ext/vector11.C new file mode 100644 index 00000000000..a3213522bf5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector11.C @@ -0,0 +1,6 @@ +// PR c++/34913 + +template<typename T> struct A +{ + int x[sizeof(T)] __attribute((vector_size(8))); +}; |