re PR c++/86550 (Lambda parsing allows arbitrary types in decl-specifier-seq)
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 Jul 2018 21:01:54 +0000 (23:01 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 18 Jul 2018 21:01:54 +0000 (23:01 +0200)
PR c++/86550
* parser.c (cp_parser_decl_specifier_seq): Diagnose invalid type
specifier if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.

* g++.dg/cpp0x/lambda/lambda-86550.C: New test.

From-SVN: r262862

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

index 738b179532273d0e3d2ce85a68cba5d0af64dd40..4a28c839ef3ff7b08c76100a1e806f4cc8c93f42 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/86550
+       * parser.c (cp_parser_decl_specifier_seq): Diagnose invalid type
+       specifier if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.
+
 2018-07-18  Marek Polacek  <polacek@redhat.com>
 
        PR c++/86190 - bogus -Wsign-conversion warning
index d0f1e1e97014ffaad3c04b87e57a5d1f79ce22d3..90d5d007317c679768fb6969831065b57f1a3ef9 100644 (file)
@@ -13797,6 +13797,9 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
              found_decl_spec = true;
              if (!is_cv_qualifier)
                decl_specs->any_type_specifiers_p = true;
+
+             if ((flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) != 0)
+               error_at (token->location, "type-specifier invalid in lambda");
            }
        }
 
index 37354f3724dafe69b1ef0278563d43abbb9bb418..1b7364aa45bdb9e38f8a375706d87d71ba88645f 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/86550
+       * g++.dg/cpp0x/lambda/lambda-86550.C: New test.
+
 2018-07-18  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR 69558
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-86550.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-86550.C
new file mode 100644 (file)
index 0000000..4f79850
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/86550
+// { dg-do compile { target c++11 } }
+
+void
+foo ()
+{
+  auto a = []() bool {};                       // { dg-error "type-specifier invalid in lambda" }
+  auto b = []() bool bool bool bool int {};    // { dg-error "type-specifier invalid in lambda" }
+}