From 533007c1e9280941228e1a499cf5747d22d2b7ee Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 27 Sep 2007 14:54:06 -0400 Subject: [PATCH] decl2.c (is_late_template_attribute): Don't crash on unknown attribute. * decl2.c (is_late_template_attribute): Don't crash on unknown attribute. From-SVN: r128844 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl2.c | 4 ++++ gcc/testsuite/g++.dg/ext/tmplattr6.C | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/tmplattr6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f459c54ae59..a0e259c93c0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-09-27 Jason Merrill + + * decl2.c (is_late_template_attribute): Don't crash on unknown + attribute. + 2007-09-27 Paolo Carlini PR c++/33493 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d58194265db..c00c9796a1e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -986,6 +986,10 @@ is_late_template_attribute (tree attr, tree decl) tree args = TREE_VALUE (attr); const struct attribute_spec *spec = lookup_attribute_spec (name); + if (!spec) + /* Unknown attribute. */ + return false; + if (is_attribute_p ("aligned", name) && args && value_dependent_expression_p (TREE_VALUE (args))) diff --git a/gcc/testsuite/g++.dg/ext/tmplattr6.C b/gcc/testsuite/g++.dg/ext/tmplattr6.C new file mode 100644 index 00000000000..17f23fe3493 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/tmplattr6.C @@ -0,0 +1,12 @@ +// Don't crash on an unknown attribute. + +struct foo { + template + void __attribute__((leafify)) bar() {} // { dg-warning "ignored" } +}; + +void bar(void) +{ + foo f; + f.bar(); +} -- 2.30.2