diff options
author | Marek Polacek <polacek@redhat.com> | 2021-01-29 11:29:25 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2021-02-01 10:09:11 -0500 |
commit | bab669f2fc643cb1673aecd177eec1c773e9e48e (patch) | |
tree | 510fff973e5d9d15d39ea43a78c6e8129700086b | |
parent | 6e0a231a4aa2407bb7167daf98a37795a67364d8 (diff) | |
download | gcc-bab669f2fc643cb1673aecd177eec1c773e9e48e.zip gcc-bab669f2fc643cb1673aecd177eec1c773e9e48e.tar.gz gcc-bab669f2fc643cb1673aecd177eec1c773e9e48e.tar.bz2 |
c++: Improve sorry for __builtin_has_attribute [PR98355]
__builtin_has_attribute doesn't work in templates yet (bug 92104), so
in r11-471 I added a sorry. But that only caught type-dependent
expressions and we also want to sorry on value-dependent expressions.
This patch uses uses_template_parms, but guarded with p_t_d, because
u_t_p sets p_t_d and then v_d_e_p considers variables with reference
types value-dependent, which breaks builtin-has-attribute-6.c.
This is a regression and I also plan to apply this to gcc-10.
gcc/cp/ChangeLog:
PR c++/98355
* parser.c (cp_parser_has_attribute_expression): Use
uses_template_parms instead of type_dependent_expression_p.
gcc/testsuite/ChangeLog:
PR c++/98355
* g++.dg/ext/builtin-has-attribute2.C: New test.
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/builtin-has-attribute2.C | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5c1d880..abadaf9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8934,7 +8934,7 @@ cp_parser_has_attribute_expression (cp_parser *parser) { if (oper == error_mark_node) /* Nothing. */; - else if (type_dependent_expression_p (oper)) + else if (processing_template_decl && uses_template_parms (oper)) sorry_at (atloc, "%<__builtin_has_attribute%> with dependent argument " "not supported yet"); else diff --git a/gcc/testsuite/g++.dg/ext/builtin-has-attribute2.C b/gcc/testsuite/g++.dg/ext/builtin-has-attribute2.C new file mode 100644 index 0000000..aba7932 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin-has-attribute2.C @@ -0,0 +1,8 @@ +// PR c++/98355 +// { dg-do compile { target c++11 } } + +struct S { int a; }; +template <int> struct T +{ + static_assert (!__builtin_has_attribute (((S*)0) -> a, packed), ""); // { dg-message "sorry, unimplemented: .__builtin_has_attribute. with dependent argument not supported yet" } +}; |