[clang] 5c40db1 - [clang][Interp] Don't retry weak declarations
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Fri May 24 11:01:04 PDT 2024
Author: Timm Bäder
Date: 2024-05-24T20:00:54+02:00
New Revision: 5c40db1da3a5ee1ed27b2ed874353dd80b294c15
URL: https://github.com/llvm/llvm-project/commit/5c40db1da3a5ee1ed27b2ed874353dd80b294c15
DIFF: https://github.com/llvm/llvm-project/commit/5c40db1da3a5ee1ed27b2ed874353dd80b294c15.diff
LOG: [clang][Interp] Don't retry weak declarations
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 f73eaeebf9fe8..6607727b5246f 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -3795,7 +3795,8 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
}
} else {
if (const auto *VD = dyn_cast<VarDecl>(D);
- VD && VD->getAnyInitializer() && VD->getType().isConstQualified()) {
+ VD && VD->getAnyInitializer() && VD->getType().isConstQualified() &&
+ !VD->isWeak()) {
if (!this->visitVarDecl(VD))
return false;
// Retry.
diff --git a/clang/test/AST/Interp/c.c b/clang/test/AST/Interp/c.c
index d680dbc912ab4..f4c7bf16f2f95 100644
--- a/clang/test/AST/Interp/c.c
+++ b/clang/test/AST/Interp/c.c
@@ -284,3 +284,9 @@ void *foo5 (void)
{
return &cv2; // pedantic-warning{{address of an expression of type 'void'}}
}
+
+__attribute__((weak)) const unsigned int test10_bound = 10;
+char test10_global[test10_bound]; // all-error {{variable length array declaration not allowed at file scope}}
+void test10(void) {
+ char test10_local[test10_bound] = "help"; // all-error {{variable-sized object may not be initialized}}
+}
More information about the cfe-commits
mailing list