diff --git a/std/d/ast.d b/std/d/ast.d index 8490f50..94e0e1d 100644 --- a/std/d/ast.d +++ b/std/d/ast.d @@ -1531,6 +1531,7 @@ public: /** */ FunctionBody functionBody; /** */ MemberFunctionAttribute[] memberFunctionAttributes; /** */ string comment; + /** */ Attribute[] attributes; mixin OpEquals; } diff --git a/std/d/parser.d b/std/d/parser.d index 08da2e0..a3e99d9 100644 --- a/std/d/parser.d +++ b/std/d/parser.d @@ -1790,7 +1790,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c; if (peekIs(tok!"=")) node.variableDeclaration = parseVariableDeclaration(null, true); else if (peekIs(tok!"(")) - node.functionDeclaration = parseFunctionDeclaration(null, true); + node.functionDeclaration = parseFunctionDeclaration(null, true, node.attributes); else goto type; } @@ -1811,7 +1811,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c; return null; } if (peekIs(tok!"(")) - node.functionDeclaration = parseFunctionDeclaration(type); + node.functionDeclaration = parseFunctionDeclaration(type, false, node.attributes); else node.variableDeclaration = parseVariableDeclaration(type); break; @@ -2540,7 +2540,7 @@ body {} // six * ($(RULE storageClass) | $(RULE _type)) $(LITERAL Identifier) $(RULE templateParameters) $(RULE parameters) $(RULE memberFunctionAttribute)* $(RULE constraint)? ($(RULE functionBody) | $(LITERAL ';')) * ;) */ - FunctionDeclaration parseFunctionDeclaration(Type type = null, bool isAuto = false) + FunctionDeclaration parseFunctionDeclaration(Type type = null, bool isAuto = false, Attribute[] attributes = null) { mixin(traceEnterAndExit!(__FUNCTION__)); auto node = allocate!FunctionDeclaration; @@ -2548,6 +2548,8 @@ body {} // six comment = null; MemberFunctionAttribute[] memberFunctionAttributes; + node.attributes = attributes; + if (isAuto) goto functionName;