From: Marek Polacek Date: Thu, 11 Jun 2020 20:21:18 +0000 (-0400) Subject: c++: Sorry about type-dependent arg for __builtin_has_attribute [PR90915] X-Git-Tag: releases/gcc-10.2.0~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53e91f867bd1c3773d37b2efb8875b8b1416a9d2;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 42d7b1c03361..45ad2c05288d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8677,7 +8677,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); diff --git a/gcc/testsuite/g++.dg/ext/builtin-has-attribute.C b/gcc/testsuite/g++.dg/ext/builtin-has-attribute.C new file mode 100644 index 000000000000..3438dd59ba3d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin-has-attribute.C @@ -0,0 +1,8 @@ +// PR c++/90915 +// { dg-do compile { target c++11 } } + +template +void foo () +{ + static_assert(!__builtin_has_attribute(T::a, aligned), ""); // { dg-message "sorry, unimplemented: .__builtin_has_attribute. with dependent argument not supported yet" } +}