Commit e41d4a0a by Iain Buclaw

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  <ibuclaw@gdcproject.org>

	* gdc.dg/asm1.d: Add new test for ICE in asm parser.
	* gdc.dg/asm5.d: New test.
parent f2d3807f
e9420cfbf5cd0cf9e6e398603e009ccc8e14d324
b061bd744cb4eb94a7118581387d988d4ec25e97
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
......@@ -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;
......
2020-03-16 Iain Buclaw <ibuclaw@gdcproject.org>
* gdc.dg/asm1.d: Add new test for ICE in asm parser.
* gdc.dg/asm5.d: New test.
2020-03-16 Jakub Jelinek <jakub@redhat.com>
PR debug/94167
......
......@@ -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()
{
{
......
// 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" }
}
}
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