mirror of
https://github.com/dlang/dmd.git
synced 2025-04-29 06:30:10 +03:00
Fix Issue 23271 - Mark lowered DeclExps in array appends as exptemp (#14328)
This commit is contained in:
parent
5843effb01
commit
0f2c2e8b60
2 changed files with 19 additions and 0 deletions
|
@ -10330,6 +10330,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
||||||
// `__appendtmp*` will be destroyed together with the array `exp.e1`.
|
// `__appendtmp*` will be destroyed together with the array `exp.e1`.
|
||||||
auto vd = eValue2.isDeclarationExp().declaration.isVarDeclaration();
|
auto vd = eValue2.isDeclarationExp().declaration.isVarDeclaration();
|
||||||
vd.storage_class |= STC.nodtor;
|
vd.storage_class |= STC.nodtor;
|
||||||
|
// Be more explicit that this "declaration" is local to the expression
|
||||||
|
vd.storage_class |= STC.exptemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ale = new ArrayLengthExp(exp.loc, value1);
|
auto ale = new ArrayLengthExp(exp.loc, value1);
|
||||||
|
|
17
compiler/test/compilable/testgotoskips.d
Normal file
17
compiler/test/compilable/testgotoskips.d
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
Tests to defend against false positives from the goto skips over decl errors
|
||||||
|
*/
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=23271
|
||||||
|
class A {
|
||||||
|
private static A[] active;
|
||||||
|
private void test() {
|
||||||
|
foreach(a; active) {
|
||||||
|
if(a is this)
|
||||||
|
goto label;
|
||||||
|
}
|
||||||
|
// used to say Error: `goto` skips declaration of variable `s.A.test.__appendtmp4` at s.d(...)
|
||||||
|
active ~= this;
|
||||||
|
label:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue