Skip to content

Commit d33fb58

Browse files
tbaederrdvbuka
authored andcommitted
[clang][bytecode] Handle discarded AddrLabelExprs properly (llvm#165000)
emitDummyPtr() doesn't like to be called with DiscardResult set, so check this first. Fixes llvm#164979
1 parent a9992cd commit d33fb58

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
@@ -3948,6 +3948,8 @@ bool Compiler<Emitter>::VisitRecoveryExpr(const RecoveryExpr *E) {
39483948
template <class Emitter>
39493949
bool Compiler<Emitter>::VisitAddrLabelExpr(const AddrLabelExpr *E) {
39503950
assert(E->getType()->isVoidPointerType());
3951+
if (DiscardResult)
3952+
return true;
39513953

39523954
return this->emitDummyPtr(E, E);
39533955
}

clang/test/AST/ByteCode/cxx11.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,12 @@ namespace GH150709 {
370370
static_assert((e2[0].*mp)() == 1, ""); // ref-error {{constant expression}}
371371
static_assert((g.*mp)() == 1, ""); // ref-error {{constant expression}}
372372
}
373+
374+
namespace DiscardedAddrLabel {
375+
void foo(void) {
376+
L:
377+
*&&L; // both-error {{indirection not permitted}} \
378+
// both-warning {{expression result unused}}
379+
}
380+
}
381+

0 commit comments

Comments
 (0)