[PATCH d]: Committed merge with upstream dmd
Iain Buclaw
ibuclaw@gdcproject.org
Mon Mar 16 09:54:01 GMT 2020
Hi,
This patch merges the D front-end implementation with upstream dmd
b061bd744.
Fixes an ICE in the parser, and deprecates a previously allowed style of
syntax that deviated from GNU-style extended asm.
Bootstrapped and tested on x86_64-linux-gnu, and committed to trunk.
Regards
Iain.
---
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.
---
gcc/d/dmd/MERGE | 2 +-
gcc/d/dmd/iasmgcc.c | 30 +++++++++++++++++++++++++++---
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gdc.dg/asm1.d | 9 +++++++++
gcc/testsuite/gdc.dg/asm5.d | 12 ++++++++++++
5 files changed, 54 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gdc.dg/asm5.d
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 ab0406656d2..32a51b96a0e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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 Bin Cheng <bin.cheng@linux.alibaba.com>
PR tree-optimization/94125
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" }
+ }
+}
--
2.20.1
More information about the Gcc-patches
mailing list