mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Fix bypassing nothrow in debug statements (#20720)
* Fix bypassing nothrow in debug statements * Fix debug walking null statements
This commit is contained in:
parent
b237d0329c
commit
ac9e8a5a70
4 changed files with 27 additions and 19 deletions
|
@ -1363,11 +1363,6 @@ private Expression resolveUFCSProperties(Scope* sc, Expression e1, Expression e2
|
|||
auto arguments = new Expressions(1);
|
||||
(*arguments)[0] = eleft;
|
||||
e = new CallExp(loc, e, arguments);
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=24017
|
||||
if (sc.flags & SCOPE.debug_)
|
||||
e.isCallExp().inDebugStatement = true;
|
||||
|
||||
e = e.expressionSemantic(sc);
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,16 @@ private Expression checkAssignmentAsCondition(Expression e, Scope* sc)
|
|||
return e;
|
||||
}
|
||||
|
||||
// Performs semantic analysis in Statement AST nodes
|
||||
/**
|
||||
* Performs semantic analysis in Statement AST nodes
|
||||
*
|
||||
* Params:
|
||||
* s = statement to perform semantic analysis on
|
||||
* sc = scope in which statement resides
|
||||
*
|
||||
* Returns: statement `s` after semantic analysis.
|
||||
* Can be `null`, for example with `pragma(msg, "")`
|
||||
*/
|
||||
Statement statementSemantic(Statement s, Scope* sc)
|
||||
{
|
||||
import dmd.compiler;
|
||||
|
@ -3461,6 +3470,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
sc = sc.push();
|
||||
sc.flags |= SCOPE.debug_;
|
||||
ds.statement = ds.statement.statementSemantic(sc);
|
||||
debugThrowWalker(ds.statement);
|
||||
sc.pop();
|
||||
}
|
||||
result = ds.statement;
|
||||
|
@ -4736,7 +4746,6 @@ private Statements* flatten(Statement statement, Scope* sc)
|
|||
if (dc)
|
||||
{
|
||||
s = new DebugStatement(cs.loc, cs.ifbody);
|
||||
debugThrowWalker(cs.ifbody);
|
||||
}
|
||||
else
|
||||
s = cs.ifbody;
|
||||
|
@ -4908,7 +4917,8 @@ Params:
|
|||
*/
|
||||
private void debugThrowWalker(Statement s)
|
||||
{
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
extern(C++) final class DebugWalker : SemanticTimeTransitiveVisitor
|
||||
{
|
||||
alias visit = SemanticTimeTransitiveVisitor.visit;
|
||||
|
|
|
@ -85,3 +85,17 @@ void test6() nothrow
|
|||
() {throw new Exception("");}();
|
||||
}
|
||||
}
|
||||
|
||||
void writeln() {}
|
||||
void writeln(string) {}
|
||||
|
||||
void test7() nothrow
|
||||
{
|
||||
debug writeln("Hello"); // https://issues.dlang.org/show_bug.cgi?id=24017
|
||||
debug "Hello".writeln;
|
||||
debug writeln = "Hello"; // https://github.com/dlang/dmd/issues/20719
|
||||
debug writeln;
|
||||
|
||||
// https://github.com/dlang/dmd/pull/20720#issuecomment-2596892489
|
||||
debug pragma(msg, ""); // Came up as segfault, pragma statement became null after semantic
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=24017
|
||||
|
||||
// REQUIRED_ARGS: -debug
|
||||
|
||||
void writeln(string) {}
|
||||
|
||||
void main() nothrow
|
||||
{
|
||||
debug writeln("Hello");
|
||||
debug "Hello".writeln;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue