Skip to content

Commit afba3da

Browse files
committed
[clang][Interp] Add basic support for AddrLabelExprs
Just create a local variable for them.
1 parent 1d43ec8 commit afba3da

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,16 @@ bool ByteCodeExprGen<Emitter>::VisitRecoveryExpr(const RecoveryExpr *E) {
24882488
return this->emitError(E);
24892489
}
24902490

2491+
template <class Emitter>
2492+
bool ByteCodeExprGen<Emitter>::VisitAddrLabelExpr(const AddrLabelExpr *E) {
2493+
assert(E->getType()->isVoidPointerType());
2494+
2495+
unsigned Offset = allocateLocalPrimitive(
2496+
E->getLabel(), PT_Ptr, /*IsConst=*/true, /*IsExtended=*/false);
2497+
2498+
return this->emitGetLocal(PT_Ptr, Offset, E);
2499+
}
2500+
24912501
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
24922502
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/true,
24932503
/*NewInitializing=*/false);

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
122122
bool VisitPseudoObjectExpr(const PseudoObjectExpr *E);
123123
bool VisitPackIndexingExpr(const PackIndexingExpr *E);
124124
bool VisitRecoveryExpr(const RecoveryExpr *E);
125+
bool VisitAddrLabelExpr(const AddrLabelExpr *E);
125126

126127
protected:
127128
bool visitExpr(const Expr *E) override;

clang/test/AST/Interp/c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,8 @@ int test3(void) {
273273
/// This tests that we have full type info, even for values we cannot read.
274274
int dummyarray[5];
275275
_Static_assert(&dummyarray[0] < &dummyarray[1], ""); // pedantic-warning {{GNU extension}}
276+
277+
void addrlabelexpr(void) {
278+
a0: ;
279+
static void *ps[] = { &&a0 }; // pedantic-warning {{use of GNU address-of-label extension}}
280+
}

0 commit comments

Comments
 (0)