Commit 0fd699fb authored by Matthias Klose's avatar Matthias Klose

* Fix PR c++/89585, taken from the gcc-8 branch.

parent 76f9c710
gcc-7 (7.4.0-7) UNRELEASED; urgency=medium
* Fix PR c++/89585, taken from the gcc-8 branch.
-- Matthias Klose <doko@debian.org> Fri, 08 Mar 2019 12:29:40 +0100
gcc-7 (7.4.0-6) unstable; urgency=medium
* Update to SVN 20190225 (r269187) from the gcc-7-branch.
......
# DP: Fix PR c++/89585, taken from the gcc-8 branch.
gcc/cp/
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.
gcc/testsuite/
2019-03-07 Jakub Jelinek <jakub@redhat.com>
PR c++/89585
* g++.dg/asm-qual-3.C: Adjust expected diagnostics.
--- a/src/gcc/cp/parser.c (revision 269451)
+++ b/src/gcc/cp/parser.c (revision 269452)
@@ -19125,8 +19125,9 @@
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);
@@ -19152,6 +19153,8 @@
}
else
inline_loc = loc;
+ if (!first_loc)
+ first_loc = loc;
cp_lexer_consume_token (parser->lexer);
continue;
@@ -19163,6 +19166,8 @@
}
else
goto_loc = loc;
+ if (!first_loc)
+ first_loc = loc;
cp_lexer_consume_token (parser->lexer);
continue;
@@ -19182,6 +19187,12 @@
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;
--- a/src/gcc/testsuite/g++.dg/asm-qual-3.C (revision 269451)
+++ b/src/gcc/testsuite/g++.dg/asm-qual-3.C (revision 269452)
@@ -2,11 +2,11 @@
// { 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 "" }
......@@ -92,6 +92,7 @@ debian_patches += \
libffi-riscv \
gcc-force-cross-layout \
kfreebsd-decimal-float \
pr89585 \
# FIXME: see #915194
# gcc-search-prefixed-as-ld \
......
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