[PATCH] explain cause of 'incorrect type in conditional'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A conditional only makes sense on a scalar type. If not,
an error is issued.

However, the error message doesn't explain this.

Fix this by adding the explanation to the error message.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 evaluate.c                    |  2 +-
 validation/bad-type-twice0.c  |  2 +-
 validation/conditional-type.c | 16 ++++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 4d5748562..d316a3f79 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -910,7 +910,7 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator
 		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:");
+		sparse_error(expr->pos, "non-scalar type in conditional:");
 		info(expr->pos, "   %s", show_typename(ctype));
 		return NULL;
 	}
diff --git a/validation/bad-type-twice0.c b/validation/bad-type-twice0.c
index 84e0f25a4..9e834d47d 100644
--- a/validation/bad-type-twice0.c
+++ b/validation/bad-type-twice0.c
@@ -7,7 +7,7 @@ static int foo(a)
  * check-name: bad-type-twice0
  *
  * check-error-start
-bad-type-twice0.c:3:16: error: incorrect type in conditional:
+bad-type-twice0.c:3:16: error: non-scalar type in conditional:
 bad-type-twice0.c:3:16:    incomplete type a
  * check-error-end
  */
diff --git a/validation/conditional-type.c b/validation/conditional-type.c
index 7cd5672dc..6e2da9b52 100644
--- a/validation/conditional-type.c
+++ b/validation/conditional-type.c
@@ -79,21 +79,21 @@ static int good_if_ptr(void *ptr)
  * check-name: conditional-type
  *
  * check-error-start
-conditional-type.c:18:18: error: incorrect type in conditional:
+conditional-type.c:18:18: error: non-scalar type in conditional:
 conditional-type.c:18:18:    void
-conditional-type.c:19:13: error: incorrect type in conditional:
+conditional-type.c:19:13: error: non-scalar type in conditional:
 conditional-type.c:19:13:    struct state s
-conditional-type.c:24:18: error: incorrect type in conditional:
+conditional-type.c:24:18: error: non-scalar type in conditional:
 conditional-type.c:24:18:    void
-conditional-type.c:29:21: error: incorrect type in conditional:
+conditional-type.c:29:21: error: non-scalar type in conditional:
 conditional-type.c:29:21:    void
-conditional-type.c:30:16: error: incorrect type in conditional:
+conditional-type.c:30:16: error: non-scalar type in conditional:
 conditional-type.c:30:16:    struct state s
-conditional-type.c:34:21: error: incorrect type in conditional:
+conditional-type.c:34:21: error: non-scalar type in conditional:
 conditional-type.c:34:21:    void
-conditional-type.c:36:20: error: incorrect type in conditional:
+conditional-type.c:36:20: error: non-scalar type in conditional:
 conditional-type.c:36:20:    void
-conditional-type.c:40:21: error: incorrect type in conditional:
+conditional-type.c:40:21: error: non-scalar type in conditional:
 conditional-type.c:40:21:    void
  * check-error-end
  */
-- 
2.20.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux