c++: Sorry about type-dependent arg for __builtin_has_attribute [PR90915]

Until 92104 is fixed, let's sorry rather than crash.

	PR c++/90915
	* parser.c (cp_parser_has_attribute_expression): Sorry on a
	type-dependent argument.

	* g++.dg/ext/builtin-has-attribute.C: New test.
This commit is contained in:
Marek Polacek 2020-05-07 21:10:42 -04:00
parent 7a41fcde6c
commit 5d2246a32c
4 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2020-05-18 Marek Polacek <polacek@redhat.com>
PR c++/90915
* parser.c (cp_parser_has_attribute_expression): Sorry on a
type-dependent argument.
2020-05-18 Marek Polacek <polacek@redhat.com>
DR 1512

View File

@ -8679,7 +8679,12 @@ cp_parser_has_attribute_expression (cp_parser *parser)
location_t atloc = cp_lexer_peek_token (parser->lexer)->location;
if (tree attr = cp_parser_gnu_attribute_list (parser, /*exactly_one=*/true))
{
if (oper != error_mark_node)
if (oper == error_mark_node)
/* Nothing. */;
else if (type_dependent_expression_p (oper))
sorry_at (atloc, "%<__builtin_has_attribute%> with dependent argument "
"not supported yet");
else
{
/* Fold constant expressions used in attributes first. */
cp_check_const_attributes (attr);

View File

@ -1,3 +1,8 @@
2020-05-18 Marek Polacek <polacek@redhat.com>
PR c++/90915
* g++.dg/ext/builtin-has-attribute.C: New test.
2020-05-18 Martin Sebor <msebor@redhat.com>
PR middle-end/92815

View File

@ -0,0 +1,8 @@
// PR c++/90915
// { dg-do compile { target c++11 } }
template<typename T>
void foo ()
{
static_assert(!__builtin_has_attribute(T::a, aligned), ""); // { dg-message "sorry, unimplemented: .__builtin_has_attribute. with dependent argument not supported yet" }
}