mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 06:00:13 +03:00
Fix 23764 - Message printed twice: Usage of in on parameter
This commit is contained in:
parent
763b0a5fe5
commit
a78115f36e
9 changed files with 38 additions and 4 deletions
|
@ -777,6 +777,7 @@ extern (C++) final class Module : Package
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scope p = new Parser!AST(this, buf, cast(bool) docfile, global.errorSink, &global.compileEnv);
|
scope p = new Parser!AST(this, buf, cast(bool) docfile, global.errorSink, &global.compileEnv);
|
||||||
|
p.transitionIn = global.params.vin;
|
||||||
p.nextToken();
|
p.nextToken();
|
||||||
p.parseModuleDeclaration();
|
p.parseModuleDeclaration();
|
||||||
md = p.md;
|
md = p.md;
|
||||||
|
|
|
@ -1937,6 +1937,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
||||||
buf.writeByte(0);
|
buf.writeByte(0);
|
||||||
const str = buf.extractSlice()[0 .. len];
|
const str = buf.extractSlice()[0 .. len];
|
||||||
scope p = new Parser!ASTCodegen(cd.loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
scope p = new Parser!ASTCodegen(cd.loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
||||||
|
p.transitionIn = global.params.vin;
|
||||||
p.nextToken();
|
p.nextToken();
|
||||||
|
|
||||||
auto d = p.parseDeclDefs(0);
|
auto d = p.parseDeclDefs(0);
|
||||||
|
|
|
@ -73,6 +73,14 @@ class ErrorSinkCompiler : ErrorSink
|
||||||
vdeprecationSupplemental(loc, format, ap);
|
vdeprecationSupplemental(loc, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void message(const ref Loc loc, const(char)* format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
vmessage(loc, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ abstract class ErrorSink
|
||||||
|
|
||||||
void warning(const ref Loc loc, const(char)* format, ...);
|
void warning(const ref Loc loc, const(char)* format, ...);
|
||||||
|
|
||||||
|
void message(const ref Loc loc, const(char)* format, ...);
|
||||||
|
|
||||||
void deprecation(const ref Loc loc, const(char)* format, ...);
|
void deprecation(const ref Loc loc, const(char)* format, ...);
|
||||||
|
|
||||||
void deprecationSupplemental(const ref Loc loc, const(char)* format, ...);
|
void deprecationSupplemental(const ref Loc loc, const(char)* format, ...);
|
||||||
|
@ -47,6 +49,8 @@ class ErrorSinkNull : ErrorSink
|
||||||
|
|
||||||
void warning(const ref Loc loc, const(char)* format, ...) { }
|
void warning(const ref Loc loc, const(char)* format, ...) { }
|
||||||
|
|
||||||
|
void message(const ref Loc loc, const(char)* format, ...) { }
|
||||||
|
|
||||||
void deprecation(const ref Loc loc, const(char)* format, ...) { }
|
void deprecation(const ref Loc loc, const(char)* format, ...) { }
|
||||||
|
|
||||||
void deprecationSupplemental(const ref Loc loc, const(char)* format, ...) { }
|
void deprecationSupplemental(const ref Loc loc, const(char)* format, ...) { }
|
||||||
|
@ -117,5 +121,21 @@ class ErrorSinkStderr : ErrorSink
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void message(const ref Loc loc, const(char)* format, ...)
|
||||||
|
{
|
||||||
|
const p = loc.toChars();
|
||||||
|
if (*p)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", p);
|
||||||
|
//mem.xfree(cast(void*)p); // loc should provide the free()
|
||||||
|
}
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
vfprintf(stderr, format, ap);
|
||||||
|
fputc('\n', stderr);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
void deprecationSupplemental(const ref Loc loc, const(char)* format, ...) { }
|
void deprecationSupplemental(const ref Loc loc, const(char)* format, ...) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6107,6 +6107,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
||||||
const len = buf.length;
|
const len = buf.length;
|
||||||
const str = buf.extractChars()[0 .. len];
|
const str = buf.extractChars()[0 .. len];
|
||||||
scope p = new Parser!ASTCodegen(exp.loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
scope p = new Parser!ASTCodegen(exp.loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
||||||
|
p.transitionIn = global.params.vin;
|
||||||
p.nextToken();
|
p.nextToken();
|
||||||
//printf("p.loc.linnum = %d\n", p.loc.linnum);
|
//printf("p.loc.linnum = %d\n", p.loc.linnum);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
||||||
Loc lookingForElse; // location of lonely if looking for an else
|
Loc lookingForElse; // location of lonely if looking for an else
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool transitionIn = false; /// `-transition=in` is active, `in` parameters are listed
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* Use this constructor for string mixins.
|
* Use this constructor for string mixins.
|
||||||
* Input:
|
* Input:
|
||||||
|
@ -2857,6 +2859,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
||||||
// Don't call nextToken again.
|
// Don't call nextToken again.
|
||||||
}
|
}
|
||||||
case TOK.in_:
|
case TOK.in_:
|
||||||
|
if (transitionIn)
|
||||||
|
eSink.message(scanloc, "Usage of 'in' on parameter");
|
||||||
stc = STC.in_;
|
stc = STC.in_;
|
||||||
goto L2;
|
goto L2;
|
||||||
|
|
||||||
|
|
|
@ -4756,6 +4756,7 @@ private Statements* flatten(Statement statement, Scope* sc)
|
||||||
buf.writeByte(0);
|
buf.writeByte(0);
|
||||||
const str = buf.extractSlice()[0 .. len];
|
const str = buf.extractSlice()[0 .. len];
|
||||||
scope p = new Parser!ASTCodegen(cs.loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
scope p = new Parser!ASTCodegen(cs.loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
||||||
|
p.transitionIn = global.params.vin;
|
||||||
p.nextToken();
|
p.nextToken();
|
||||||
|
|
||||||
auto a = new Statements();
|
auto a = new Statements();
|
||||||
|
|
|
@ -1119,9 +1119,6 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
|
||||||
|
|
||||||
fparam.type = fparam.type.addStorageClass(fparam.storageClass);
|
fparam.type = fparam.type.addStorageClass(fparam.storageClass);
|
||||||
|
|
||||||
if (global.params.vin && fparam.storageClass & STC.in_)
|
|
||||||
message(loc, "Usage of 'in' on parameter");
|
|
||||||
|
|
||||||
if (fparam.storageClass & (STC.auto_ | STC.alias_ | STC.static_))
|
if (fparam.storageClass & (STC.auto_ | STC.alias_ | STC.static_))
|
||||||
{
|
{
|
||||||
if (!fparam.type)
|
if (!fparam.type)
|
||||||
|
@ -4934,6 +4931,7 @@ RootObject compileTypeMixin(TypeMixin tm, Loc loc, Scope* sc)
|
||||||
buf.writeByte(0);
|
buf.writeByte(0);
|
||||||
const str = buf.extractSlice()[0 .. len];
|
const str = buf.extractSlice()[0 .. len];
|
||||||
scope p = new Parser!ASTCodegen(loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
scope p = new Parser!ASTCodegen(loc, sc._module, str, false, global.errorSink, &global.compileEnv);
|
||||||
|
p.transitionIn = global.params.vin;
|
||||||
p.nextToken();
|
p.nextToken();
|
||||||
//printf("p.loc.linnum = %d\n", p.loc.linnum);
|
//printf("p.loc.linnum = %d\n", p.loc.linnum);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
compilable/transition_in.d(3): Usage of 'in' on parameter
|
compilable/transition_in.d(3): Usage of 'in' on parameter
|
||||||
compilable/transition_in.d(3): Usage of 'in' on parameter
|
compilable/transition_in.d(3): Usage of 'in' on parameter
|
||||||
compilable/transition_in.d(13): Usage of 'in' on parameter
|
compilable/transition_in.d(8): Usage of 'in' on parameter
|
||||||
compilable/transition_in.d(13): Usage of 'in' on parameter
|
compilable/transition_in.d(13): Usage of 'in' on parameter
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue