re PR c++/89585 (GCC 8.3: asm volatile no longer accepted at file scope)
authorJakub Jelinek <jakub@redhat.com>
Fri, 8 Mar 2019 07:45:23 +0000 (08:45 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 8 Mar 2019 07:45:23 +0000 (08:45 +0100)
PR c++/89585
* parser.c (cp_parser_asm_definition): Just warn instead of error
on volatile qualifier outside of function body.

* g++.dg/asm-qual-3.C: Adjust expected diagnostics for toplevel
asm volatile.

From-SVN: r269483

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

index c6e023f..5faebe5 100644 (file)
@@ -1,5 +1,9 @@
 2019-03-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89585
+       * parser.c (cp_parser_asm_definition): Just warn instead of error
+       on volatile qualifier outside of function body.
+
        PR c++/89599
        * constexpr.c (potential_constant_expression_1): Reject
        REINTERPRET_CAST_P NOP_EXPRs.
index 5ac6fc4..e6c2036 100644 (file)
@@ -19782,9 +19782,12 @@ cp_parser_asm_definition (cp_parser* parser)
                inform (volatile_loc, "first seen here");
              }
            else
-             volatile_loc = loc;
-           if (!first_loc)
-             first_loc = loc;
+             {
+               if (!parser->in_function_body)
+                 warning_at (loc, 0, "asm qualifier %qT ignored outside of "
+                                     "function body", token->u.value);
+               volatile_loc = loc;
+             }
            cp_lexer_consume_token (parser->lexer);
            continue;
 
@@ -19830,10 +19833,10 @@ 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 && (volatile_p || inline_p || goto_p))
+  if (!parser->in_function_body && (inline_p || goto_p))
     {
       error_at (first_loc, "asm qualifier outside of function body");
-      volatile_p = inline_p = goto_p = false;
+      inline_p = goto_p = false;
     }
 
   /* Look for the opening `('.  */
index 5db4e37..4010924 100644 (file)
@@ -1,5 +1,9 @@
 2019-03-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89585
+       * g++.dg/asm-qual-3.C: Adjust expected diagnostics for toplevel
+       asm volatile.
+
        PR c++/89599
        * g++.dg/ubsan/vptr-4.C: Adjust expected diagnostics.
        * g++.dg/parse/array-size2.C: Likewise.
index 0f8de36..0bf6069 100644 (file)
@@ -3,7 +3,7 @@
 // { dg-options "-std=gnu++98" }
 
 asm const ("");    // { dg-error {'const' is not an asm qualifier} }
-asm volatile (""); // { dg-error {asm qualifier outside of function body} }
+asm volatile (""); // { dg-warning {asm qualifier 'volatile' ignored outside of function body} }
 asm restrict (""); // { dg-error {expected '\(' before 'restrict'} }
 asm inline ("");   // { dg-error {asm qualifier outside of function body} }
 asm goto ("");     // { dg-error {asm qualifier outside of function body} }