Commit f879f0e3 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/89585 (GCC 8.3: asm volatile no longer accepted at file scope)

	PR c++/89585
	* doc/extend.texi (Basic Asm): Document qualifiers are not allowed
	at toplevel.

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

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

From-SVN: r269451
parent c0017f91
2019-03-07 Jakub Jelinek <jakub@redhat.com>
PR c++/89585
* doc/extend.texi (Basic Asm): Document qualifiers are not allowed
at toplevel.
2019-03-06 Peter Bergner <bergner@linux.ibm.com> 2019-03-06 Peter Bergner <bergner@linux.ibm.com>
PR rtl-optimization/88845 PR rtl-optimization/88845
......
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.
2019-03-06 Jason Merrill <jason@redhat.com> 2019-03-06 Jason Merrill <jason@redhat.com>
PR c++/89381 - implicit copy and using-declaration. PR c++/89381 - implicit copy and using-declaration.
......
...@@ -19766,8 +19766,9 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -19766,8 +19766,9 @@ cp_parser_asm_definition (cp_parser* parser)
location_t volatile_loc = UNKNOWN_LOCATION; location_t volatile_loc = UNKNOWN_LOCATION;
location_t inline_loc = UNKNOWN_LOCATION; location_t inline_loc = UNKNOWN_LOCATION;
location_t goto_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 (;;) for (;;)
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
...@@ -19782,6 +19783,8 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -19782,6 +19783,8 @@ cp_parser_asm_definition (cp_parser* parser)
} }
else else
volatile_loc = loc; volatile_loc = loc;
if (!first_loc)
first_loc = loc;
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
continue; continue;
...@@ -19793,6 +19796,8 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -19793,6 +19796,8 @@ cp_parser_asm_definition (cp_parser* parser)
} }
else else
inline_loc = loc; inline_loc = loc;
if (!first_loc)
first_loc = loc;
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
continue; continue;
...@@ -19804,6 +19809,8 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -19804,6 +19809,8 @@ cp_parser_asm_definition (cp_parser* parser)
} }
else else
goto_loc = loc; goto_loc = loc;
if (!first_loc)
first_loc = loc;
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
continue; continue;
...@@ -19823,6 +19830,12 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -19823,6 +19830,12 @@ cp_parser_asm_definition (cp_parser* parser)
bool inline_p = (inline_loc != UNKNOWN_LOCATION); bool inline_p = (inline_loc != UNKNOWN_LOCATION);
bool goto_p = (goto_loc != UNKNOWN_LOCATION); bool goto_p = (goto_loc != UNKNOWN_LOCATION);
if (!parser->in_function_body && (volatile_p || inline_p || goto_p))
{
error_at (first_loc, "asm qualifier outside of function body");
volatile_p = inline_p = goto_p = false;
}
/* Look for the opening `('. */ /* Look for the opening `('. */
if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return; return;
...@@ -9064,6 +9064,8 @@ outside of C functions, you must use basic @code{asm}. ...@@ -9064,6 +9064,8 @@ outside of C functions, you must use basic @code{asm}.
You can use this technique to emit assembler directives, You can use this technique to emit assembler directives,
define assembly language macros that can be invoked elsewhere in the file, define assembly language macros that can be invoked elsewhere in the file,
or write entire functions in assembly language. or write entire functions in assembly language.
Basic @code{asm} statements outside of functions may not use any
qualifiers.
@item @item
Functions declared Functions declared
......
2019-03-07 Jakub Jelinek <jakub@redhat.com>
PR c++/89585
* g++.dg/asm-qual-3.C: Adjust expected diagnostics.
2019-03-06 Harald Anlauf <anlauf@gmx.de> 2019-03-06 Harald Anlauf <anlauf@gmx.de>
PR fortran/71203 PR fortran/71203
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// { dg-do compile } // { dg-do compile }
// { dg-options "-std=gnu++98" } // { dg-options "-std=gnu++98" }
asm const (""); // { dg-error {expected '\(' before 'const'} } asm const (""); // { dg-error {'const' is not an asm qualifier} }
asm volatile (""); // { dg-error {expected '\(' before 'volatile'} } asm volatile (""); // { dg-error {asm qualifier outside of function body} }
asm restrict (""); // { dg-error {expected '\(' before 'restrict'} } asm restrict (""); // { dg-error {expected '\(' before 'restrict'} }
asm inline (""); // { dg-error {expected '\(' before 'inline'} } asm inline (""); // { dg-error {asm qualifier outside of function body} }
asm goto (""); // { dg-error {expected '\(' before 'goto'} } asm goto (""); // { dg-error {asm qualifier outside of function body} }
// There are many other things wrong with this code, so: // There are many other things wrong with this code, so:
// { dg-excess-errors "" } // { dg-excess-errors "" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment