]> granicus.if.org Git - clang/commit
"Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
authorChris Lattner <sabre@nondot.org>
Mon, 6 Oct 2008 05:42:39 +0000 (05:42 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 Oct 2008 05:42:39 +0000 (05:42 +0000)
commit46cfefa8a4e486ee6a9b8960f232237bf7a4b1f9
treee3798cfdb9395012fd23fe69f6915d25d0f80b11
parent019f4e858e78587f2241ff1a76c747d7bcd7578c
"Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
condition as a constant even if the unevaluated side is a not a constant.
We don't do this when extensions are off, and we emit a warning when this
happens:

t.c:22:11: warning: expression is not a constant, but is accepted as one by GNU extensions
short t = __builtin_constant_p(5353) ? 42 : somefunc();
          ^                                 ~~~~~~~~~~

suggestions for improvement are welcome.  This is obviously horrible, but
is required for real-world code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57153 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDecl.cpp
test/Sema/constant-builtins.c