Author: Timm Bäder Date: 2024-05-23T11:56:23+02:00 New Revision: 45a95c3c543c88a669cffd3f7ee2a1b7e02b44e8
URL: https://github.com/llvm/llvm-project/commit/45a95c3c543c88a669cffd3f7ee2a1b7e02b44e8 DIFF: https://github.com/llvm/llvm-project/commit/45a95c3c543c88a669cffd3f7ee2a1b7e02b44e8.diff LOG: [clang][Interp] Fix DeclRefExprs of void-typed dummy pointers Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/c.c Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 0c514236d4ca7..b885cbe2c4b0e 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -3795,6 +3795,8 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) { if (std::optional<unsigned> I = P.getOrCreateDummy(D)) { if (!this->emitGetPtrGlobal(*I, E)) return false; + if (E->getType()->isVoidType()) + return true; // Convert the dummy pointer to another pointer type if we have to. if (PrimType PT = classifyPrim(E); PT != PT_Ptr) { if (!this->emitDecayPtr(PT_Ptr, PT, E)) diff --git a/clang/test/AST/Interp/c.c b/clang/test/AST/Interp/c.c index 2a75457a4693f..d680dbc912ab4 100644 --- a/clang/test/AST/Interp/c.c +++ b/clang/test/AST/Interp/c.c @@ -278,3 +278,9 @@ void addrlabelexpr(void) { a0: ; static void *ps[] = { &&a0 }; // pedantic-warning {{use of GNU address-of-label extension}} } + +extern void cv2; +void *foo5 (void) +{ + return &cv2; // pedantic-warning{{address of an expression of type 'void'}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits