From fb4ccfed86b61baaafa7a86c07d572e7e9234d29 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 4 Oct 2017 17:21:21 +0000 Subject: [PATCH] re PR c++/71946 (asm in toplevel lambda function rejected) /cp 2017-10-04 Paolo Carlini Andrew Pinski PR c++/71946 * parser.c (cp_parser_lambda_body): Set parser->in_function_body. /testsuite 2017-10-04 Paolo Carlini Andrew Pinski PR c++/71946 * g++.dg/cpp0x/lambda/lambda-asm1.C: New. * g++.dg/cpp0x/lambda/lambda-stmtexpr1.C: Likewise. Co-Authored-By: Andrew Pinski From-SVN: r253423 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 3 +++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C | 4 ++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C | 5 +++++ 5 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 01b8c4d6da6..035a1b75e3d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-10-04 Paolo Carlini + Andrew Pinski + + PR c++/71946 + * parser.c (cp_parser_lambda_body): Set parser->in_function_body. + 2017-10-04 Nathan Sidwell Move mangling aliases out of global namespace. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6e817cb9fd5..28bc8e4d42a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10557,6 +10557,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr) { bool nested = (current_function_decl != NULL_TREE); bool local_variables_forbidden_p = parser->local_variables_forbidden_p; + bool in_function_body = parser->in_function_body; if (nested) push_function_context (); else @@ -10567,6 +10568,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr) save_omp_privatization_clauses (omp_privatization_save); /* Clear this in case we're in the middle of a default argument. */ parser->local_variables_forbidden_p = false; + parser->in_function_body = true; /* Finish the function call operator - class_specifier @@ -10653,6 +10655,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr) restore_omp_privatization_clauses (omp_privatization_save); parser->local_variables_forbidden_p = local_variables_forbidden_p; + parser->in_function_body = in_function_body; if (nested) pop_function_context(); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index da8358ced9e..8e00f3274c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-10-04 Paolo Carlini + Andrew Pinski + + PR c++/71946 + * g++.dg/cpp0x/lambda/lambda-asm1.C: New. + * g++.dg/cpp0x/lambda/lambda-stmtexpr1.C: Likewise. + 2017-10-04 Sudakshina Das * gcc.target/aarch64/bic_imm_1.c: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C new file mode 100644 index 00000000000..ef0b125fe50 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C @@ -0,0 +1,4 @@ +// PR c++/71946 +// { dg-do compile { target c++11 } } + +auto test = []{ __asm__ __volatile__ ("" : : "r" (0) ); }; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C new file mode 100644 index 00000000000..e461db653d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C @@ -0,0 +1,5 @@ +// PR c++/71946 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +auto test = []{ int t = ({ int t1; t1 = 7; t1; }); }; -- 2.30.2