Commit 628be4ef by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/89640 (g++ chokes on lambda with __attribute__)

	PR c++/89640
	* parser.c (cp_parser_decl_specifier_seq): Don't parse attributes
	if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.

	* g++.dg/cpp1z/attr-lambda1.C: New test.
	* g++.dg/ext/attr-lambda2.C: New test.

From-SVN: r277741
parent 1afe39ac
2019-11-02 Jakub Jelinek <jakub@redhat.com>
PR c++/89640
* parser.c (cp_parser_decl_specifier_seq): Don't parse attributes
if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.
PR c++/88335 - Implement P1073R3: Immediate functions
* cp-tree.h (struct lang_decl_fn): Add immediate_fn_p bit.
(DECL_IMMEDIATE_FUNCTION_P, SET_DECL_IMMEDIATE_FUNCTION_P): Define.
......
......@@ -13994,7 +13994,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
if (!start_token)
start_token = token;
/* Handle attributes. */
if (cp_next_tokens_can_be_attribute_p (parser))
if ((flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) == 0
&& cp_next_tokens_can_be_attribute_p (parser))
{
/* Parse the attributes. */
tree attrs = cp_parser_attributes_opt (parser);
2019-11-02 Jakub Jelinek <jakub@redhat.com>
PR c++/89640
* g++.dg/cpp1z/attr-lambda1.C: New test.
* g++.dg/ext/attr-lambda2.C: New test.
* c-c++-common/gomp/declare-variant-6.c: Expect construct rather than
constructor in diagnostic messages.
* c-c++-common/gomp/declare-variant-7.c: Likewise.
......
// PR c++/89640
// { dg-options "-Wno-attributes" }
// { dg-do compile { target c++17 } }
void test() {
[]() mutable [[gnu::cold]] constexpr {}(); // { dg-error "expected" }
[]() constexpr [[gnu::cold]] mutable {}(); // { dg-error "expected" }
[]() [[gnu::cold]] mutable constexpr {}(); // { dg-error "expected" }
[]() [[gnu::cold]] constexpr mutable {}(); // { dg-error "expected" }
[]() mutable constexpr [[gnu::cold]] {}();
[]() constexpr mutable [[gnu::cold]] {}();
}
// PR c++/89640
// { dg-options "-Wno-attributes" }
// { dg-do compile { target c++17 } }
void test() {
[]() mutable __attribute__((cold)) constexpr {}(); // { dg-error "expected" }
[]() constexpr __attribute__((cold)) mutable {}(); // { dg-error "expected" }
[]() __attribute__((cold)) mutable constexpr {}(); // { dg-error "expected" }
[]() __attribute__((cold)) constexpr mutable {}(); // { dg-error "expected" }
[]() mutable constexpr __attribute__((cold)) {}();
[]() constexpr mutable __attribute__((cold)) {}();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment