]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/89585 (GCC 8.3: asm volatile no longer accepted at file scope)
authorMatthias Klose <doko@ubuntu.com>
Sun, 10 Mar 2019 07:25:13 +0000 (07:25 +0000)
committerMatthias Klose <doko@gcc.gnu.org>
Sun, 10 Mar 2019 07:25:13 +0000 (07:25 +0000)
gcc/cp/

2019-04-10  Matthias Klose  <doko@ubuntu.com>

Backport from the gcc-8 branch
2019-03-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/89585
* parser.c (cp_parser_asm_definition): Parse asm qualifiers even
at toplevel, but diagnose them.

gcc/testsuite/

2019-04-10  Matthias Klose  <doko@ubuntu.com>

Backport from the gcc-8 branch
2019-03-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/89585
* g++.dg/asm-qual-3.C: Adjust expected diagnostics.

From-SVN: r269546

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asm-qual-3.C

index c53684fafd614d38dac4fbd2ff78284b72a1ae96..f9d98365517975ade889faf75000b0f15ad09156 100644 (file)
@@ -1,3 +1,12 @@
+2019-04-10  Matthias Klose  <doko@ubuntu.com>
+
+       Backport from the gcc-8 branch
+       2019-03-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/89585
+       * parser.c (cp_parser_asm_definition): Parse asm qualifiers even
+       at toplevel, but diagnose them.
+
 2018-01-02  Segher Boessenkool  <segher@kernel.crashing.org>
 
        Backport from trunk
index 1f80a3c60d066a13e805798c1d6f55c30c06590c..a29b3940ab0e1c1f055b30c235b3d5c494f48c3b 100644 (file)
@@ -18847,8 +18847,9 @@ cp_parser_asm_definition (cp_parser* parser)
   location_t volatile_loc = UNKNOWN_LOCATION;
   location_t inline_loc = UNKNOWN_LOCATION;
   location_t goto_loc = UNKNOWN_LOCATION;
+  location_t first_loc = UNKNOWN_LOCATION;
 
-  if (cp_parser_allow_gnu_extensions_p (parser) && parser->in_function_body)
+  if (cp_parser_allow_gnu_extensions_p (parser))
     for (;;)
       {
        cp_token *token = cp_lexer_peek_token (parser->lexer);
@@ -18874,6 +18875,8 @@ cp_parser_asm_definition (cp_parser* parser)
              }
            else
              inline_loc = loc;
+           if (!first_loc)
+             first_loc = loc;
            cp_lexer_consume_token (parser->lexer);
            continue;
 
@@ -18885,6 +18888,8 @@ cp_parser_asm_definition (cp_parser* parser)
              }
            else
              goto_loc = loc;
+           if (!first_loc)
+             first_loc = loc;
            cp_lexer_consume_token (parser->lexer);
            continue;
 
@@ -18904,6 +18909,12 @@ cp_parser_asm_definition (cp_parser* parser)
   bool inline_p = (inline_loc != UNKNOWN_LOCATION);
   bool goto_p = (goto_loc != UNKNOWN_LOCATION);
 
+  if (!parser->in_function_body && (inline_p || goto_p))
+    {
+      error_at (first_loc, "asm qualifier outside of function body");
+      inline_p = goto_p = false;
+    }
+
   /* Look for the opening `('.  */
   if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return;
index 3622271345a62651aad167e22453847a5505c8c5..bb8077a41329f05398be4369a1d003f31a2da859 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-10  Matthias Klose  <doko@ubuntu.com>
+
+       Backport from the gcc-8 branch
+       2019-03-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/89585
+       * g++.dg/asm-qual-3.C: Adjust expected diagnostics.
+
 2019-03-07  Xiong Hu Luo  <luoxhu@linux.ibm.com>
 
        Backport of r268834 from mainline to gcc-7-branch.
index 95c9b570a5f813e34528f51f59c227b83f1f6445..6faf0ef5e06ed5bbe4d7e5ff16304c3b90a61fed 100644 (file)
@@ -2,11 +2,11 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++98" }
 
-asm const ("");    // { dg-error {expected '\(' before 'const'} }
-asm volatile (""); // { dg-error {expected '\(' before 'volatile'} }
+asm const ("");    // { dg-error {'const' is not an asm qualifier} }
+asm volatile ("");
 asm restrict (""); // { dg-error {expected '\(' before 'restrict'} }
-asm inline ("");   // { dg-error {expected '\(' before 'inline'} }
-asm goto ("");     // { dg-error {expected '\(' before 'goto'} }
+asm inline ("");   // { dg-error {asm qualifier outside of function body} }
+asm goto ("");     // { dg-error {asm qualifier outside of function body} }
 
 // There are many other things wrong with this code, so:
 // { dg-excess-errors "" }