mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Do not generate context for assert(0)
(#15625)
This commit is contained in:
parent
8a65dd7cbc
commit
a6285c26c0
3 changed files with 28 additions and 1 deletions
|
@ -6427,7 +6427,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
const generateMsg = !exp.msg &&
|
||||
sc.needsCodegen() && // let ctfe interpreter handle the error message
|
||||
global.params.checkAction == CHECKACTION.context &&
|
||||
global.params.useAssert == CHECKENABLE.on;
|
||||
global.params.useAssert == CHECKENABLE.on &&
|
||||
!((exp.e1.isIntegerExp() && (exp.e1.toInteger() == 0)) ||
|
||||
exp.e1.isNullExp());
|
||||
Expression temporariesPrefix;
|
||||
|
||||
if (generateMsg)
|
||||
|
|
10
compiler/test/compilable/checkaction-context-assert-0.d
Normal file
10
compiler/test/compilable/checkaction-context-assert-0.d
Normal file
|
@ -0,0 +1,10 @@
|
|||
module checkaction_context_assert_0;
|
||||
/*
|
||||
REQUIRED_ARGS: -vcg-ast -o- -checkaction=context
|
||||
OUTPUT_FILES: compilable/checkaction-context-assert-0.d.cg
|
||||
TEST_OUTPUT_FILE: extra-files/checkaction-context-assert-0.d.cg
|
||||
*/
|
||||
|
||||
void a() { assert(0); }
|
||||
void b() { assert(false); }
|
||||
void c() { assert(null); }
|
|
@ -0,0 +1,15 @@
|
|||
=== compilable/checkaction-context-assert-0.d.cg
|
||||
module checkaction_context_assert_0;
|
||||
import object;
|
||||
void a()
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
void b()
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
void c()
|
||||
{
|
||||
assert(null);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue