Merge pull request #106 from AndrejMitrovic/FixAliasLinkage
Add linkage attribute parsing support to alias declarations.
This commit is contained in:
commit
54118e905f
|
@ -346,8 +346,9 @@ class AliasDeclaration : ASTNode
|
||||||
public:
|
public:
|
||||||
override void accept(ASTVisitor visitor)
|
override void accept(ASTVisitor visitor)
|
||||||
{
|
{
|
||||||
mixin (visitIfNotNull!(type, name, initializers));
|
mixin (visitIfNotNull!(linkageAttribute, type, name, initializers));
|
||||||
}
|
}
|
||||||
|
/** */ LinkageAttribute linkageAttribute;
|
||||||
/** */ Type type;
|
/** */ Type type;
|
||||||
/** */ Token name;
|
/** */ Token name;
|
||||||
/** */ AliasInitializer[] initializers;
|
/** */ AliasInitializer[] initializers;
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Parser
|
||||||
*
|
*
|
||||||
* $(GRAMMAR $(RULEDEF aliasDeclaration):
|
* $(GRAMMAR $(RULEDEF aliasDeclaration):
|
||||||
* $(LITERAL 'alias') $(RULE aliasInitializer) $(LPAREN)$(LITERAL ',') $(RULE aliasInitializer)$(RPAREN)* $(LITERAL ';')
|
* $(LITERAL 'alias') $(RULE aliasInitializer) $(LPAREN)$(LITERAL ',') $(RULE aliasInitializer)$(RPAREN)* $(LITERAL ';')
|
||||||
* | $(LITERAL 'alias') $(RULE type) $(LITERAL identifier) $(LITERAL ';')
|
* | $(LITERAL 'alias') $(RULE linkageAttribute)? $(RULE type) $(LITERAL identifier) $(LITERAL ';')
|
||||||
* ;)
|
* ;)
|
||||||
*/
|
*/
|
||||||
AliasDeclaration parseAliasDeclaration()
|
AliasDeclaration parseAliasDeclaration()
|
||||||
|
@ -78,6 +78,18 @@ class Parser
|
||||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||||
auto node = new AliasDeclaration;
|
auto node = new AliasDeclaration;
|
||||||
if (expect(tok!"alias") is null) return null;
|
if (expect(tok!"alias") is null) return null;
|
||||||
|
|
||||||
|
// 'alias extern(C) void function() f;' => supported in DMD and DScanner.
|
||||||
|
// 'alias f = extern(C) void function();' => not supported in both DMD and DScanner. See D Bugzilla 10471.
|
||||||
|
// 'alias extern void function() f;' => supported in DMD, not supported in DScanner since it's a storage class.
|
||||||
|
if (currentIs(tok!"extern"))
|
||||||
|
{
|
||||||
|
if (!peekIs(tok!"("))
|
||||||
|
error(`"(" expected for the linkage attribute`);
|
||||||
|
|
||||||
|
node.linkageAttribute = parseLinkageAttribute();
|
||||||
|
}
|
||||||
|
|
||||||
if (startsWith(tok!"identifier", tok!"="))
|
if (startsWith(tok!"identifier", tok!"="))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in New Issue