diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-12-03 01:36:22 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-12-03 01:36:22 +0000 |
| commit | 0c6124ba82063b05b9c85b63bb29ec354aa1be0b (patch) | |
| tree | c5cb08e6eb95fe213116ac9bbad149a05d31577a /clang/test/CXX/expr | |
| parent | a30cee627201032bc7ea66808d057d97f52b852f (diff) | |
| download | bcm5719-llvm-0c6124ba82063b05b9c85b63bb29ec354aa1be0b.tar.gz bcm5719-llvm-0c6124ba82063b05b9c85b63bb29ec354aa1be0b.zip | |
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
Diffstat (limited to 'clang/test/CXX/expr')
| -rw-r--r-- | clang/test/CXX/expr/expr.const/p2-0x.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp index 2adefd928af..c519ecbda22 100644 --- a/clang/test/CXX/expr/expr.const/p2-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp @@ -601,11 +601,11 @@ namespace rdar13090123 { typedef __INTPTR_TYPE__ intptr_t; constexpr intptr_t f(intptr_t x) { - return (((x) >> 21) * 8); // expected-note{{subexpression not valid in a constant expression}} + return (((x) >> 21) * 8); } extern "C" int foo; constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be initialized by a constant expression}} \ - // expected-note{{in call to 'f((char*)&foo + -10)'}} + // expected-note{{reinterpret_cast}} } |

