#include "scope.h"
#include "declaration.h"
+#include "errors.h"
#include "parse.h"
#include "statement.h"
* 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 ]
case TOKlbracket:
if (p->peekNext() == TOKidentifier)
{
+ // Skip over openings `[`
p->nextToken();
+ // Store the symbolic name
name = p->token.ident;
p->nextToken();
}
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)
{
break;
default:
+ Ldefault:
p->error("expected constant string constraint for operand, not `%s`",
p->token.toChars());
goto Lerror;