Skip to content

Commit 5c40db1

Browse files
committed
[clang][Interp] Don't retry weak declarations
1 parent 4fb02de commit 5c40db1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3795,7 +3795,8 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
37953795
}
37963796
} else {
37973797
if (const auto *VD = dyn_cast<VarDecl>(D);
3798-
VD && VD->getAnyInitializer() && VD->getType().isConstQualified()) {
3798+
VD && VD->getAnyInitializer() && VD->getType().isConstQualified() &&
3799+
!VD->isWeak()) {
37993800
if (!this->visitVarDecl(VD))
38003801
return false;
38013802
// Retry.

clang/test/AST/Interp/c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,9 @@ void *foo5 (void)
284284
{
285285
return &cv2; // pedantic-warning{{address of an expression of type 'void'}}
286286
}
287+
288+
__attribute__((weak)) const unsigned int test10_bound = 10;
289+
char test10_global[test10_bound]; // all-error {{variable length array declaration not allowed at file scope}}
290+
void test10(void) {
291+
char test10_local[test10_bound] = "help"; // all-error {{variable-sized object may not be initialized}}
292+
}

0 commit comments

Comments
 (0)