https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/102136
... if it can't be expressed as a constant initializer. >From 741c0bb89bc50a2a1bf270a2ac3717eb5c7f4666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Tue, 6 Aug 2024 15:04:13 +0200 Subject: [PATCH] [clang][Interp] Ignore ObjCBoxedExpr subexpr... ... if it can't be expressed as a constant initializer. --- clang/lib/AST/Interp/Compiler.cpp | 5 +++-- clang/test/AST/Interp/objc.mm | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 02cbe38f5fb1f..95f4fe9bd0bec 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -3161,10 +3161,11 @@ bool Compiler<Emitter>::VisitExtVectorElementExpr( template <class Emitter> bool Compiler<Emitter>::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { + const Expr *SubExpr = E->getSubExpr(); if (!E->isExpressibleAsConstantInitializer()) - return this->emitInvalid(E); + return this->discard(SubExpr) && this->emitInvalid(E); - return this->delegate(E->getSubExpr()); + return this->delegate(SubExpr); } template <class Emitter> diff --git a/clang/test/AST/Interp/objc.mm b/clang/test/AST/Interp/objc.mm index 6402c8ae098fd..f6c4ba12dc5d1 100644 --- a/clang/test/AST/Interp/objc.mm +++ b/clang/test/AST/Interp/objc.mm @@ -11,3 +11,28 @@ @interface NSString @end constexpr NSString *t0 = @"abc"; constexpr NSString *t1 = @("abc"); + + +#if __LP64__ +typedef unsigned long NSUInteger; +typedef long NSInteger; +#else +typedef unsigned int NSUInteger; +typedef int NSInteger; +#endif + + +@class NSNumber; + + +@interface NSObject ++ (NSObject*)nsobject; +@end + +@interface NSNumber : NSObject ++ (NSNumber *)numberWithInt:(int)value; +@end + +int main(void) { + NSNumber *bv = @(1391126400 * 1000); // both-warning {{overflow in expression; result is -443'003'904 with type 'int'}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits