aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-08-08 17:56:06 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-09-02 17:34:00 +0200
commitb8c706f3d0116b79f3935f36162fae610311c163 (patch)
tree8aefbf720af76b0c574883ca1df0b230c700c767 /validation
parent3c748099b5a79d74461c142248920316504c5cb0 (diff)
downloadsparse-dev-b8c706f3d0116b79f3935f36162fae610311c163.tar.gz
constexpr: relax constexprness of constant conditionals
Currently, sparse emits a warning when a conditional expression with a constant condition is used where an "Integer Constant Expression" is expected and only the false-side operand (which is not evaluated) is not constant. The standard are especially unclear about this situation. However, GCC silently accept those as ICEs when they evaluate to a compile-time known value (in other words, when the conditional and the corresponding true/false sub-expression are themselves constant). The standard are especially unclear about the situation when the unevaluated side is non-constant. So, relax sparse to match GCC's behaviour. Reported-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/constexpr-constcond.c10
-rw-r--r--validation/ioc-typecheck.c4
2 files changed, 10 insertions, 4 deletions
diff --git a/validation/constexpr-constcond.c b/validation/constexpr-constcond.c
new file mode 100644
index 00000000..d98da3dc
--- /dev/null
+++ b/validation/constexpr-constcond.c
@@ -0,0 +1,10 @@
+extern int var;
+
+static int a[] = {
+ [0 ? var : 1] = 0,
+ [1 ? 2 : var] = 0,
+};
+
+/*
+ * check-name: constexprness in constant conditionals
+ */
diff --git a/validation/ioc-typecheck.c b/validation/ioc-typecheck.c
index 34b37d31..7780773b 100644
--- a/validation/ioc-typecheck.c
+++ b/validation/ioc-typecheck.c
@@ -4,8 +4,4 @@ static unsigned iocnrs[] = {
};
/*
* check-name: integer constant & conditional expression
- * check-known-to-fail
- *
- * check-error-start
- * check-error-end
*/