diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-03-07 09:18:36 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-03-07 09:18:36 +0100 |
commit | f879f0e3f2667bd60b88603c5884364a0eed1fc4 (patch) | |
tree | 163301ef840f91ff320c8d9b60c0770358a5f9ce /gcc/cp | |
parent | c0017f91c4895e8cc625614454d0e2571c077770 (diff) | |
download | gcc-f879f0e3f2667bd60b88603c5884364a0eed1fc4.zip gcc-f879f0e3f2667bd60b88603c5884364a0eed1fc4.tar.gz gcc-f879f0e3f2667bd60b88603c5884364a0eed1fc4.tar.bz2 |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 15 |
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0667dd7..c2162a4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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> PR c++/89381 - implicit copy and using-declaration. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 155e350..5ac6fc4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19766,8 +19766,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); @@ -19782,6 +19783,8 @@ cp_parser_asm_definition (cp_parser* parser) } else volatile_loc = loc; + if (!first_loc) + first_loc = loc; cp_lexer_consume_token (parser->lexer); continue; @@ -19793,6 +19796,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; @@ -19804,6 +19809,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; @@ -19823,6 +19830,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 && (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 `('. */ if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return; |