From: Jakub Jelinek Date: Fri, 20 Dec 2019 16:55:06 +0000 (+0100) Subject: backport: re PR c++/90842 (ICE in poplevel, at cp/decl.c:585) X-Git-Tag: releases/gcc-9.3.0~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26f920e0d315b4b1b5c1cf506d0250e40b64551b;p=thirdparty%2Fgcc.git backport: re PR c++/90842 (ICE in poplevel, at cp/decl.c:585) Backported from mainline 2019-11-21 Jakub Jelinek Jason Merrill PR c++/90842 * parser.c (cp_parser_decl_specifier_seq): For concept or typedef break early if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR. For type specifiers, set CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR is set. * g++.dg/cpp1y/lambda-generic-90842.C: New test. From-SVN: r279649 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5600ebea7981..f11c453d208a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2019-12-20 Jakub Jelinek + + Backported from mainline + 2019-11-21 Jakub Jelinek + Jason Merrill + + PR c++/90842 + * parser.c (cp_parser_decl_specifier_seq): For concept or typedef + break early if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR. + For type specifiers, set CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS + if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR is set. + 2019-12-11 Jason Merrill PR c++/57082 - new X{} and private destructor. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3fac495d293e..91702a50324f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13998,6 +13998,10 @@ cp_parser_decl_specifier_seq (cp_parser* parser, case RID_CONCEPT: ds = ds_concept; cp_lexer_consume_token (parser->lexer); + + if (flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) + break; + /* In C++20 a concept definition is just 'concept name = expr;' Support that syntax by pretending we've seen 'bool'. */ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME) @@ -14025,6 +14029,10 @@ cp_parser_decl_specifier_seq (cp_parser* parser, ds = ds_typedef; /* Consume the token. */ cp_lexer_consume_token (parser->lexer); + + if (flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) + break; + /* A constructor declarator cannot appear in a typedef. */ constructor_possible_p = false; /* The "typedef" keyword can only occur in a declaration; we @@ -14120,6 +14128,9 @@ cp_parser_decl_specifier_seq (cp_parser* parser, bool is_cv_qualifier; tree type_spec; + if (flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) + flags |= CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS; + type_spec = cp_parser_type_specifier (parser, flags, decl_specs, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6c6a118cd46f..0c3b578dda03 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-12-20 Jakub Jelinek + + Backported from mainline + 2019-11-21 Jakub Jelinek + + PR c++/90842 + * g++.dg/cpp1y/lambda-generic-90842.C: New test. + 2019-12-20 Roman Zhuykov * gcc.dg/pr92951-1.c: Rename to ... diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90842.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90842.C new file mode 100644 index 000000000000..e36aa5470539 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90842.C @@ -0,0 +1,7 @@ +// PR c++/90842 +// { dg-do compile { target c++14 } } + +auto a = [](auto x) struct C { void foo (); } {}; // { dg-error "expected" } + // { dg-error "type-specifier invalid in lambda" "" { target *-*-* } .-1 } +auto b = [](auto x) mutable typedef {}; // { dg-error "'typedef' invalid in lambda" } +auto d = [](auto x) mutable friend {}; // { dg-error "'friend' invalid in lambda" }