aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-21 02:00:43 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-11-21 02:00:43 +0100
commitb69d4d4542d718e9010a71f0b05e20422b3f0d40 (patch)
tree0f9ba94125c17b68f82364fbe137f77d8c9faef5
parentf0a2c2c89c8213ee3cf291983a7b4b4ed73b7e1e (diff)
downloadgcc-b69d4d4542d718e9010a71f0b05e20422b3f0d40.zip
gcc-b69d4d4542d718e9010a71f0b05e20422b3f0d40.tar.gz
gcc-b69d4d4542d718e9010a71f0b05e20422b3f0d40.tar.bz2
re PR c++/90842 (ICE in poplevel, at cp/decl.c:585)
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. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r278538
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-90842.C10
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 55ee3b8..507741b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2019-11-21 Jakub Jelinek <jakub@redhat.com>
+ Jason Merrill <jason@redhat.com>
+
+ 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-11-20 Paolo Carlini <paolo.carlini@oracle.com>
* typeck2.c (build_x_arrow): Early return if decay_conversion
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c473e7f..03b1ec7 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14097,6 +14097,9 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
ds = ds_concept;
cp_lexer_consume_token (parser->lexer);
+ if (flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR)
+ break;
+
/* Warn for concept as a decl-specifier. We'll rewrite these as
concept declarations later. */
if (!flag_concepts_ts)
@@ -14139,6 +14142,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
@@ -14235,6 +14242,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 eb33e63..d9499e5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/90842
+ * g++.dg/cpp1y/lambda-generic-90842.C: New test.
+
2019-11-20 Marek Polacek <polacek@redhat.com>
PR c++/92443
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 0000000..b3dc8c0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90842.C
@@ -0,0 +1,10 @@
+// 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" }
+#if __cpp_concepts >= 201907L
+auto c = [](auto x) constexpr concept {}; // { dg-error "'concept' invalid in lambda" "" { target c++2a } }
+#endif
+auto d = [](auto x) mutable friend {}; // { dg-error "'friend' invalid in lambda" }