+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
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);
}
else
inline_loc = loc;
+ if (!first_loc)
+ first_loc = loc;
cp_lexer_consume_token (parser->lexer);
continue;
}
else
goto_loc = loc;
+ if (!first_loc)
+ first_loc = loc;
cp_lexer_consume_token (parser->lexer);
continue;
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;
+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.
// { 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 "" }