From 5d1504d42af6b12efeb83a2056424ceb1512961f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 8 Mar 2019 08:45:23 +0100 Subject: [PATCH] re PR c++/89585 (GCC 8.3: asm volatile no longer accepted at file scope) 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 | 4 ++++ gcc/cp/parser.c | 13 ++++++++----- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/asm-qual-3.C | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6e023ff663..5faebe5e007 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-03-08 Jakub Jelinek + 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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5ac6fc49bde..e6c2036ab33 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 `('. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5db4e375b27..4010924cd5a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2019-03-08 Jakub Jelinek + 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. diff --git a/gcc/testsuite/g++.dg/asm-qual-3.C b/gcc/testsuite/g++.dg/asm-qual-3.C index 0f8de369462..0bf60697ea5 100644 --- a/gcc/testsuite/g++.dg/asm-qual-3.C +++ b/gcc/testsuite/g++.dg/asm-qual-3.C @@ -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} } -- 2.30.2