@@ -872,6 +872,9 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator
if (is_func_type(ctype)) {
if (Waddress)
warning(expr->pos, "the address of %s will always evaluate as true", "a function");
+ } else if (is_array_type(ctype)) {
+ if (Waddress)
+ warning(expr->pos, "the address of %s will always evaluate as true", "an array");
} else if (!is_scalar_type(ctype)) {
sparse_error(expr->pos, "incorrect type in conditional");
info(expr->pos, " got %s", show_typename(ctype));
new file mode 100644
@@ -0,0 +1,26 @@
+int foo(void) {
+ extern int a[];
+
+ if (a)
+ return 1;
+ return 0;
+}
+
+int bar(void) {
+ int a[2];
+
+ if (a)
+ return 1;
+ return 0;
+}
+
+/*
+ * check-name: cond-address-array.c
+ * check-command: test-linearize -Wno-decl -Waddress $file
+ * check-output-ignore
+ *
+ * check-error-start
+cond-address-array.c:4:13: warning: the address of an array will always evaluate as true
+cond-address-array.c:12:13: warning: the address of an array will always evaluate as true
+ * check-error-end
+ */