From 0c6124ba82063b05b9c85b63bb29ec354aa1be0b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 3 Dec 2015 01:36:22 +0000 Subject: PR17381: Treat undefined behavior during expression evaluation as an unmodeled side-effect, so that we don't allow speculative evaluation of such expressions during code generation. This caused a diagnostic quality regression, so fix constant expression diagnostics to prefer either the first "can't be constant folded" diagnostic or the first "not a constant expression" diagnostic depending on the kind of evaluation we're doing. This was always the intent, but didn't quite work correctly before. This results in certain initializers that used to be constant initializers to no longer be; in particular, things like: float f = 1e100; are no longer accepted in C. This seems appropriate, as such constructs would lead to code being executed if sanitizers are enabled. llvm-svn: 254574 --- clang/test/Sema/integer-overflow.c | 1 + 1 file changed, 1 insertion(+) (limited to 'clang/test/Sema/integer-overflow.c') diff --git a/clang/test/Sema/integer-overflow.c b/clang/test/Sema/integer-overflow.c index 44fbcd4c818..8f74873ed94 100644 --- a/clang/test/Sema/integer-overflow.c +++ b/clang/test/Sema/integer-overflow.c @@ -7,6 +7,7 @@ uint64_t f1(uint64_t, uint32_t); uint64_t f2(uint64_t, ...); static const uint64_t overflow = 1 * 4608 * 1024 * 1024; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}} +// expected-error@-1 {{not a compile-time constant}} uint64_t check_integer_overflows(int i) { // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} -- cgit v1.2.3