re PR c++/71946 (asm in toplevel lambda function rejected)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 4 Oct 2017 17:21:21 +0000 (17:21 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 4 Oct 2017 17:21:21 +0000 (17:21 +0000)
/cp
2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
    Andrew Pinski  <apinski@cavium.com>

PR c++/71946
* parser.c (cp_parser_lambda_body): Set parser->in_function_body.

/testsuite
2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
    Andrew Pinski  <apinski@cavium.com>

PR c++/71946
* g++.dg/cpp0x/lambda/lambda-asm1.C: New.
* g++.dg/cpp0x/lambda/lambda-stmtexpr1.C: Likewise.

Co-Authored-By: Andrew Pinski <apinski@cavium.com>
From-SVN: r253423

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

index 01b8c4d6da60a4a1c84d6d01be2aacc6903a770b..035a1b75e3d4e963f19108ebec3af09b2b6d469f 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
+           Andrew Pinski  <apinski@cavium.com>
+
+       PR c++/71946
+       * parser.c (cp_parser_lambda_body): Set parser->in_function_body.
+
 2017-10-04  Nathan Sidwell  <nathan@acm.org>
 
        Move mangling aliases out of global namespace.
index 6e817cb9fd5b2a3e1602cd8d8a9e997ad7058d19..28bc8e4d42a01c3cc704da5270f55fca4baed655 100644 (file)
@@ -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
index da8358ced9e17463defa6288669328a9be500136..8e00f3274c00cf095a6c06b857dc58d46961f6de 100644 (file)
@@ -1,3 +1,10 @@
+2017-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
+           Andrew Pinski  <apinski@cavium.com>
+
+       PR c++/71946
+       * g++.dg/cpp0x/lambda/lambda-asm1.C: New.
+       * g++.dg/cpp0x/lambda/lambda-stmtexpr1.C: Likewise.
+
 2017-10-04  Sudakshina Das  <sudi.das@arm.com>
 
        * 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 (file)
index 0000000..ef0b125
--- /dev/null
@@ -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 (file)
index 0000000..e461db6
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/71946
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+auto test = []{ int t = ({ int t1; t1 = 7; t1; }); };