From a171a8bb39d5674f0f1fafcec642e625d601dbe2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 18 Jul 2018 23:01:54 +0200 Subject: [PATCH] re PR c++/86550 (Lambda parsing allows arbitrary types in decl-specifier-seq) 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 | 6 ++++++ gcc/cp/parser.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-86550.C | 9 +++++++++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-86550.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 738b1795322..4a28c839ef3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-07-18 Jakub Jelinek + + 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 PR c++/86190 - bogus -Wsign-conversion warning diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d0f1e1e9701..90d5d007317 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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"); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 37354f3724d..1b7364aa45b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-18 Jakub Jelinek + + PR c++/86550 + * g++.dg/cpp0x/lambda/lambda-86550.C: New test. + 2018-07-18 Bernd Edlinger 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 index 00000000000..4f7985002c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-86550.C @@ -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" } +} -- 2.30.2