Skip to content

Commit 84729c9

Browse files
committed
[clang][Interp] Don't diagnose ObjCIvarDecls as invalid reads
1 parent 5b5af52 commit 84729c9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/lib/AST/Interp/Interp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/AST/ASTContext.h"
1919
#include "clang/AST/ASTDiagnostic.h"
2020
#include "clang/AST/CXXInheritance.h"
21+
#include "clang/AST/DeclObjC.h"
2122
#include "clang/AST/Expr.h"
2223
#include "clang/AST/ExprCXX.h"
2324
#include "llvm/ADT/APSInt.h"
@@ -101,6 +102,11 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
101102
return;
102103
}
103104

105+
// Rather random, but this is to match the diagnostic output of the current
106+
// interpreter.
107+
if (isa<ObjCIvarDecl>(VD))
108+
return;
109+
104110
if (VD->getType()->isIntegralOrEnumerationType()) {
105111
S.FFDiag(Loc, diag::note_constexpr_ltor_non_const_int, 1) << VD;
106112
S.Note(VD->getLocation(), diag::note_declared_at);

clang/test/AST/Interp/objc.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s
2+
// RUN: %clang_cc1 -verify=ref,both %s
3+
4+
@interface A {
5+
int a;
6+
static_assert(a, ""); // both-error {{static assertion expression is not an integral constant expression}}
7+
}
8+
@end

0 commit comments

Comments
 (0)