From: Iain Buclaw Date: Mon, 16 Mar 2020 08:48:54 +0000 (+0100) Subject: d/dmd: Merge upstream dmd b061bd744 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e41d4a0a567f1091f646d076d8c9fad91422572b;p=gcc.git d/dmd: Merge upstream dmd b061bd744 Fixes an ICE in the parser, and deprecates a previously allowed style of syntax that deviated from GNU-style extended asm. Reviewed-on: https://github.com/dlang/dmd/pull/10916 gcc/testsuite/ChangeLog: 2020-03-16 Iain Buclaw * gdc.dg/asm1.d: Add new test for ICE in asm parser. * gdc.dg/asm5.d: New test. --- diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index b017c037d74..6cbc4e37819 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -e9420cfbf5cd0cf9e6e398603e009ccc8e14d324 +b061bd744cb4eb94a7118581387d988d4ec25e97 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/iasmgcc.c b/gcc/d/dmd/iasmgcc.c index cecbdefe41a..548453321db 100644 --- a/gcc/d/dmd/iasmgcc.c +++ b/gcc/d/dmd/iasmgcc.c @@ -13,6 +13,7 @@ #include "scope.h" #include "declaration.h" +#include "errors.h" #include "parse.h" #include "statement.h" @@ -23,8 +24,8 @@ Statement *semantic(Statement *s, Scope *sc); * Parse list of extended asm input or output operands. * Grammar: * | Operands: - * | SymbolicName(opt) StringLiteral AssignExpression - * | SymbolicName(opt) StringLiteral AssignExpression , Operands + * | SymbolicName(opt) StringLiteral ( AssignExpression ) + * | SymbolicName(opt) StringLiteral ( AssignExpression ), Operands * | * | SymbolicName: * | [ Identifier ] @@ -54,7 +55,9 @@ static int parseExtAsmOperands(Parser *p, GccAsmStatement *s) case TOKlbracket: if (p->peekNext() == TOKidentifier) { + // Skip over openings `[` p->nextToken(); + // Store the symbolic name name = p->token.ident; p->nextToken(); } @@ -63,12 +66,32 @@ static int parseExtAsmOperands(Parser *p, GccAsmStatement *s) p->error(s->loc, "expected identifier after `[`"); goto Lerror; } + // Look for closing `]` p->check(TOKrbracket); + // Look for the string literal and fall through + if (p->token.value != TOKstring) + goto Ldefault; // fall through case TOKstring: constraint = p->parsePrimaryExp(); - arg = p->parseAssignExp(); + // @@@DEPRECATED@@@ + // Old parser allowed omitting parentheses around the expression. + // Deprecated in 2.091. Can be made permanent error after 2.100 + if (p->token.value != TOKlparen) + { + arg = p->parseAssignExp(); + deprecation(arg->loc, "`%s` must be surrounded by parentheses", arg->toChars()); + } + else + { + // Look for the opening `(` + p->check(TOKlparen); + // Parse the assign expression + arg = p->parseAssignExp(); + // Look for the closing `)` + p->check(TOKrparen); + } if (!s->args) { @@ -86,6 +109,7 @@ static int parseExtAsmOperands(Parser *p, GccAsmStatement *s) break; default: + Ldefault: p->error("expected constant string constraint for operand, not `%s`", p->token.toChars()); goto Lerror; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1297954f5df..0f87a04d100 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-03-16 Iain Buclaw + + * gdc.dg/asm1.d: Add new test for ICE in asm parser. + * gdc.dg/asm5.d: New test. + 2020-03-16 Jakub Jelinek PR debug/94167 diff --git a/gcc/testsuite/gdc.dg/asm1.d b/gcc/testsuite/gdc.dg/asm1.d index 7b00e4d54ec..3fcfd6a58c1 100644 --- a/gcc/testsuite/gdc.dg/asm1.d +++ b/gcc/testsuite/gdc.dg/asm1.d @@ -29,6 +29,15 @@ void parse3() // { dg-error "found 'EOF' when expecting ';'" "" { target *-*-* } .-4 } } +void parse4() +{ + int expr; + asm + { + "%name" : [name] string (expr); // { dg-error "expected constant string constraint for operand, not 'string'" } + } +} + void semantic1() { { diff --git a/gcc/testsuite/gdc.dg/asm5.d b/gcc/testsuite/gdc.dg/asm5.d new file mode 100644 index 00000000000..b525a2131ce --- /dev/null +++ b/gcc/testsuite/gdc.dg/asm5.d @@ -0,0 +1,12 @@ +// https://issues.dlang.org/show_bug.cgi?id=20593 +// { dg-do compile } +// { dg-options "-Wall -Wdeprecated -Werror" } +module asm5; + +void test(int a) +{ + asm + { + "cpuid" : : "a" a; // { dg-error "'a' must be surrounded by parentheses" } + } +}