fix diagnostic location for `@UDA auto f() {}`
This commit is contained in:
parent
c1e051bfba
commit
7601fe65f9
|
@ -47,14 +47,15 @@ public:
|
||||||
|
|
||||||
package static const(Token)[] findAutoReturnType(const(FunctionDeclaration) decl)
|
package static const(Token)[] findAutoReturnType(const(FunctionDeclaration) decl)
|
||||||
{
|
{
|
||||||
auto autoFunTokens = decl.storageClasses
|
const(Token)[] lastAtAttribute;
|
||||||
.map!(a => a.token.type == tok!"auto"
|
foreach (storageClass; decl.storageClasses)
|
||||||
? [a.token]
|
{
|
||||||
: a.atAttribute
|
if (storageClass.token.type == tok!"auto")
|
||||||
? a.atAttribute.tokens
|
return storageClass.tokens;
|
||||||
: null)
|
else if (storageClass.atAttribute)
|
||||||
.filter!(a => a.length > 0);
|
lastAtAttribute = storageClass.atAttribute.tokens;
|
||||||
return autoFunTokens.empty ? null : autoFunTokens.front;
|
}
|
||||||
|
return lastAtAttribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const(FunctionDeclaration) decl)
|
override void visit(const(FunctionDeclaration) decl)
|
||||||
|
@ -195,6 +196,9 @@ unittest
|
||||||
^^^^ [warn]: %s +/
|
^^^^ [warn]: %s +/
|
||||||
auto doStuff(){} /+
|
auto doStuff(){} /+
|
||||||
^^^^ [warn]: %s +/
|
^^^^ [warn]: %s +/
|
||||||
|
@Custom
|
||||||
|
auto doStuff(){} /+
|
||||||
|
^^^^ [warn]: %s +/
|
||||||
int doStuff(){auto doStuff(){}} /+
|
int doStuff(){auto doStuff(){}} /+
|
||||||
^^^^ [warn]: %s +/
|
^^^^ [warn]: %s +/
|
||||||
auto doStuff(){return 0;}
|
auto doStuff(){return 0;}
|
||||||
|
@ -203,6 +207,7 @@ unittest
|
||||||
AutoFunctionChecker.MESSAGE,
|
AutoFunctionChecker.MESSAGE,
|
||||||
AutoFunctionChecker.MESSAGE,
|
AutoFunctionChecker.MESSAGE,
|
||||||
AutoFunctionChecker.MESSAGE,
|
AutoFunctionChecker.MESSAGE,
|
||||||
|
AutoFunctionChecker.MESSAGE,
|
||||||
), sac);
|
), sac);
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
|
@ -275,10 +280,14 @@ unittest
|
||||||
auto doStuff(){} // fix
|
auto doStuff(){} // fix
|
||||||
@property doStuff(){} // fix
|
@property doStuff(){} // fix
|
||||||
@safe doStuff(){} // fix
|
@safe doStuff(){} // fix
|
||||||
|
@Custom
|
||||||
|
auto doStuff(){} // fix
|
||||||
}c, q{
|
}c, q{
|
||||||
void doStuff(){} // fix
|
void doStuff(){} // fix
|
||||||
@property void doStuff(){} // fix
|
@property void doStuff(){} // fix
|
||||||
@safe void doStuff(){} // fix
|
@safe void doStuff(){} // fix
|
||||||
|
@Custom
|
||||||
|
void doStuff(){} // fix
|
||||||
}c, sac);
|
}c, sac);
|
||||||
|
|
||||||
stderr.writeln("Unittest for AutoFunctionChecker passed.");
|
stderr.writeln("Unittest for AutoFunctionChecker passed.");
|
||||||
|
|
Loading…
Reference in New Issue