Skip to content

Commit 45a95c3

Browse files
committed
[clang][Interp] Fix DeclRefExprs of void-typed dummy pointers
1 parent 5e06050 commit 45a95c3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3795,6 +3795,8 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
37953795
if (std::optional<unsigned> I = P.getOrCreateDummy(D)) {
37963796
if (!this->emitGetPtrGlobal(*I, E))
37973797
return false;
3798+
if (E->getType()->isVoidType())
3799+
return true;
37983800
// Convert the dummy pointer to another pointer type if we have to.
37993801
if (PrimType PT = classifyPrim(E); PT != PT_Ptr) {
38003802
if (!this->emitDecayPtr(PT_Ptr, PT, E))

clang/test/AST/Interp/c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,9 @@ void addrlabelexpr(void) {
278278
a0: ;
279279
static void *ps[] = { &&a0 }; // pedantic-warning {{use of GNU address-of-label extension}}
280280
}
281+
282+
extern void cv2;
283+
void *foo5 (void)
284+
{
285+
return &cv2; // pedantic-warning{{address of an expression of type 'void'}}
286+
}

0 commit comments

Comments
 (0)