Author: Timm Bäder Date: 2024-05-23T13:47:54+02:00 New Revision: 84729c9df30b29d5f4e903ad71235a6aa0c764d6
URL: https://github.com/llvm/llvm-project/commit/84729c9df30b29d5f4e903ad71235a6aa0c764d6 DIFF: https://github.com/llvm/llvm-project/commit/84729c9df30b29d5f4e903ad71235a6aa0c764d6.diff LOG: [clang][Interp] Don't diagnose ObjCIvarDecls as invalid reads Added: clang/test/AST/Interp/objc.mm Modified: clang/lib/AST/Interp/Interp.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp index cac678352e2ce..de5390596d632 100644 --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -18,6 +18,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" #include "clang/AST/CXXInheritance.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "llvm/ADT/APSInt.h" @@ -101,6 +102,11 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC, return; } + // Rather random, but this is to match the diagnostic output of the current + // interpreter. + if (isa<ObjCIvarDecl>(VD)) + return; + if (VD->getType()->isIntegralOrEnumerationType()) { S.FFDiag(Loc, diag::note_constexpr_ltor_non_const_int, 1) << VD; S.Note(VD->getLocation(), diag::note_declared_at); diff --git a/clang/test/AST/Interp/objc.mm b/clang/test/AST/Interp/objc.mm new file mode 100644 index 0000000000000..44b74d193b66a --- /dev/null +++ b/clang/test/AST/Interp/objc.mm @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s +// RUN: %clang_cc1 -verify=ref,both %s + +@interface A { + int a; + static_assert(a, ""); // both-error {{static assertion expression is not an integral constant expression}} +} +@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits