]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/90842 (ICE in poplevel, at cp/decl.c:585)
authorJakub Jelinek <jakub@redhat.com>
Fri, 20 Dec 2019 16:55:06 +0000 (17:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 20 Dec 2019 16:55:06 +0000 (17:55 +0100)
Backported from mainline
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.

* g++.dg/cpp1y/lambda-generic-90842.C: New test.

From-SVN: r279649

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/lambda-generic-90842.C [new file with mode: 0644]

index 5600ebea79813dca2e773f308c1f323c32bdd229..f11c453d208a020f13b782ee1ccb70ea53017ecd 100644 (file)
@@ -1,3 +1,15 @@
+2019-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-12-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/57082 - new X{} and private destructor.
index 3fac495d293e738700947901f69f7df7feb1d618..91702a50324fcc3b969c096805cfd6fd22b00416 100644 (file)
@@ -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,
index 6c6a118cd46f87a909ac32eeadbddee8e04636c2..0c3b578dda03adb3e8eeb8625d73aedfed8bc10c 100644 (file)
@@ -1,3 +1,11 @@
+2019-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-11-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/90842
+       * g++.dg/cpp1y/lambda-generic-90842.C: New test.
+
 2019-12-20  Roman Zhuykov  <zhroma@ispras.ru>
 
        * 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 (file)
index 0000000..e36aa54
--- /dev/null
@@ -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" }