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

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

 



A conditional only make sense on a scalar type. If not, an
error is issued but the message doesn't explain the cause.

Fix this by adding the cause 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 8841a6e48..341fed9dc 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, "incorrect type in conditional (non-scalar type)");
 		info(expr->pos, "   got %s", show_typename(ctype));
 		return NULL;
 	}
diff --git a/validation/bad-type-twice0.c b/validation/bad-type-twice0.c
index 7a9073c52..5d107a625 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: incorrect type in conditional (non-scalar type)
 bad-type-twice0.c:3:16:    got incomplete type a
  * check-error-end
  */
diff --git a/validation/conditional-type.c b/validation/conditional-type.c
index a14c05ec1..912672127 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: incorrect type in conditional (non-scalar type)
 conditional-type.c:18:18:    got void
-conditional-type.c:19:13: error: incorrect type in conditional
+conditional-type.c:19:13: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:19:13:    got struct state s
-conditional-type.c:24:18: error: incorrect type in conditional
+conditional-type.c:24:18: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:24:18:    got void
-conditional-type.c:29:21: error: incorrect type in conditional
+conditional-type.c:29:21: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:29:21:    got void
-conditional-type.c:30:16: error: incorrect type in conditional
+conditional-type.c:30:16: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:30:16:    got struct state s
-conditional-type.c:34:21: error: incorrect type in conditional
+conditional-type.c:34:21: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:34:21:    got void
-conditional-type.c:36:20: error: incorrect type in conditional
+conditional-type.c:36:20: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:36:20:    got void
-conditional-type.c:40:21: error: incorrect type in conditional
+conditional-type.c:40:21: error: incorrect type in conditional (non-scalar type)
 conditional-type.c:40:21:    got 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