Skip to content

Commit d27278a

Browse files
authored
[clang][bytecode] Discard NullToPointer cast SubExpr (#104782)
So we still properly abort if they fail.
1 parent 7a06ebd commit d27278a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
327327

328328
case CK_NullToPointer:
329329
case CK_NullToMemberPointer: {
330+
if (!this->discard(SubExpr))
331+
return false;
330332
if (DiscardResult)
331333
return true;
332334

clang/test/AST/ByteCode/codegen.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,12 @@ namespace Bitfield {
6464
// CHECK: store ptr @_ZGRN8Bitfield1rE_, ptr @_ZN8Bitfield1rE, align 8
6565
int &&r = S().a;
6666
}
67+
68+
namespace Null {
69+
decltype(nullptr) null();
70+
// CHECK: call {{.*}} @_ZN4Null4nullEv(
71+
int *p = null();
72+
struct S {};
73+
// CHECK: call {{.*}} @_ZN4Null4nullEv(
74+
int S::*q = null();
75+
}

0 commit comments

Comments
 (0)