]> granicus.if.org Git - clang/commit
PR17381: Treat undefined behavior during expression evaluation as an unmodeled
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 3 Dec 2015 01:36:22 +0000 (01:36 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 3 Dec 2015 01:36:22 +0000 (01:36 +0000)
commit550a066d6e10686657b21e89ad06b47172324e77
treea8b22cb72a19726af8e8b5cc98ab286efcc55c0b
parenta50dd2aa4c0f83f429f32e30c5e2d59e549c5c8d
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254574 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ExprConstant.cpp
lib/Sema/SemaChecking.cpp
test/CXX/expr/expr.const/p2-0x.cpp
test/CodeGen/complex-init-list.c
test/CodeGen/ubsan-conditional.c [new file with mode: 0644]
test/PCH/floating-literal.c
test/Sema/const-eval.c
test/Sema/integer-overflow.c
test/Sema/switch-1.c
test/SemaCXX/constant-expression-cxx11.cpp
test/SemaCXX/constexpr-printing.cpp