diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5c1d880c9fc..abadaf972d6 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 00000000000..aba7932a136 --- /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 struct T +{ + static_assert (!__builtin_has_attribute (((S*)0) -> a, packed), ""); // { dg-message "sorry, unimplemented: .__builtin_has_attribute. with dependent argument not supported yet" } +};