[PATCH 3/6] show-parse: do not display base type's redundant specifiers

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

 



In do_show_type(), builtin_typename() is used to display builtin
(base) types and modifier_string() is used to display modifiers.

However, most base types contains some intrinsic modifiers, the
type specifiers. So, a type like 'unsigned long' is displayed as
'unsigned long [unsigned] [long]'.

Fix this redundancy by not displaying the specifiers when displaying
a base_type (or an enum).

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 show-parse.c                       |  2 +
 validation/bad-type-twice1.c       |  2 +-
 validation/builtin-overflow.c      | 60 +++++++++++++++---------------
 validation/cast-bad-00.c           |  4 +-
 validation/choose_expr.c           |  4 +-
 validation/expand/builtin-expect.c |  4 +-
 6 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/show-parse.c b/show-parse.c
index e8a0b4dcb..36b447421 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -298,6 +298,8 @@ deeper:
 		if (as)
 			prepend(name, "%s ", show_as(as));
 
+		if (sym->type == SYM_BASETYPE || sym->type == SYM_ENUM)
+			mod &= ~MOD_SPECIFIER;
 		s = modifier_string(mod);
 		len = strlen(s);
 		name->start -= len;    
diff --git a/validation/bad-type-twice1.c b/validation/bad-type-twice1.c
index 95cfd9e01..cc81662af 100644
--- a/validation/bad-type-twice1.c
+++ b/validation/bad-type-twice1.c
@@ -10,7 +10,7 @@ static unsigned long foo(unsigned long val, void *ref)
  *
  * check-error-start
 bad-type-twice1.c:3:17: error: incompatible types for operation (>=)
-bad-type-twice1.c:3:17:    left side has type unsigned long [unsigned] val
+bad-type-twice1.c:3:17:    left side has type unsigned long val
 bad-type-twice1.c:3:17:    right side has type void *ref
  * check-error-end
  */
diff --git a/validation/builtin-overflow.c b/validation/builtin-overflow.c
index 798868a31..c3d1d3aa8 100644
--- a/validation/builtin-overflow.c
+++ b/validation/builtin-overflow.c
@@ -139,15 +139,15 @@ builtin-overflow.c:59:37: error: not enough arguments for __builtin_add_overflow
 builtin-overflow.c:60:37: error: not enough arguments for __builtin_add_overflow
 builtin-overflow.c:61:37: error: too many arguments for __builtin_add_overflow
 builtin-overflow.c:62:38: error: invalid type for argument 1:
-builtin-overflow.c:62:38:         int enum e [signed] e
+builtin-overflow.c:62:38:         int enum e e
 builtin-overflow.c:63:41: error: invalid type for argument 2:
-builtin-overflow.c:63:41:         int enum e [signed] e
+builtin-overflow.c:63:41:         int enum e e
 builtin-overflow.c:64:45: error: invalid type for argument 3:
 builtin-overflow.c:64:45:         int enum e *
 builtin-overflow.c:65:38: error: invalid type for argument 1:
-builtin-overflow.c:65:38:         bool [unsigned] [usertype] b
+builtin-overflow.c:65:38:         bool [usertype] b
 builtin-overflow.c:66:41: error: invalid type for argument 2:
-builtin-overflow.c:66:41:         bool [unsigned] [usertype] b
+builtin-overflow.c:66:41:         bool [usertype] b
 builtin-overflow.c:67:45: error: invalid type for argument 3:
 builtin-overflow.c:67:45:         bool *
 builtin-overflow.c:68:44: error: invalid type for argument 3:
@@ -157,17 +157,17 @@ builtin-overflow.c:71:39: error: not enough arguments for __builtin_add_overflow
 builtin-overflow.c:72:39: error: not enough arguments for __builtin_add_overflow_p
 builtin-overflow.c:73:39: error: too many arguments for __builtin_add_overflow_p
 builtin-overflow.c:74:40: error: invalid type for argument 1:
-builtin-overflow.c:74:40:         int enum e [signed] [addressable] e
+builtin-overflow.c:74:40:         int enum e [addressable] e
 builtin-overflow.c:75:43: error: invalid type for argument 2:
-builtin-overflow.c:75:43:         int enum e [signed] [addressable] e
+builtin-overflow.c:75:43:         int enum e [addressable] e
 builtin-overflow.c:76:46: error: invalid type for argument 3:
-builtin-overflow.c:76:46:         int enum e [signed] [addressable] e
+builtin-overflow.c:76:46:         int enum e [addressable] e
 builtin-overflow.c:77:40: error: invalid type for argument 1:
-builtin-overflow.c:77:40:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:77:40:         bool [addressable] [usertype] b
 builtin-overflow.c:78:43: error: invalid type for argument 2:
-builtin-overflow.c:78:43:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:78:43:         bool [addressable] [usertype] b
 builtin-overflow.c:79:46: error: invalid type for argument 3:
-builtin-overflow.c:79:46:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:79:46:         bool [addressable] [usertype] b
 builtin-overflow.c:80:46: error: invalid type for argument 3:
 builtin-overflow.c:80:46:         void *p
 builtin-overflow.c:82:37: error: not enough arguments for __builtin_sub_overflow
@@ -175,15 +175,15 @@ builtin-overflow.c:83:37: error: not enough arguments for __builtin_sub_overflow
 builtin-overflow.c:84:37: error: not enough arguments for __builtin_sub_overflow
 builtin-overflow.c:85:37: error: too many arguments for __builtin_sub_overflow
 builtin-overflow.c:86:38: error: invalid type for argument 1:
-builtin-overflow.c:86:38:         int enum e [signed] [addressable] e
+builtin-overflow.c:86:38:         int enum e [addressable] e
 builtin-overflow.c:87:41: error: invalid type for argument 2:
-builtin-overflow.c:87:41:         int enum e [signed] [addressable] e
+builtin-overflow.c:87:41:         int enum e [addressable] e
 builtin-overflow.c:88:45: error: invalid type for argument 3:
 builtin-overflow.c:88:45:         int enum e *
 builtin-overflow.c:89:38: error: invalid type for argument 1:
-builtin-overflow.c:89:38:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:89:38:         bool [addressable] [usertype] b
 builtin-overflow.c:90:41: error: invalid type for argument 2:
-builtin-overflow.c:90:41:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:90:41:         bool [addressable] [usertype] b
 builtin-overflow.c:91:45: error: invalid type for argument 3:
 builtin-overflow.c:91:45:         bool *
 builtin-overflow.c:92:44: error: invalid type for argument 3:
@@ -193,17 +193,17 @@ builtin-overflow.c:95:39: error: not enough arguments for __builtin_sub_overflow
 builtin-overflow.c:96:39: error: not enough arguments for __builtin_sub_overflow_p
 builtin-overflow.c:97:39: error: too many arguments for __builtin_sub_overflow_p
 builtin-overflow.c:98:40: error: invalid type for argument 1:
-builtin-overflow.c:98:40:         int enum e [signed] [addressable] e
+builtin-overflow.c:98:40:         int enum e [addressable] e
 builtin-overflow.c:99:43: error: invalid type for argument 2:
-builtin-overflow.c:99:43:         int enum e [signed] [addressable] e
+builtin-overflow.c:99:43:         int enum e [addressable] e
 builtin-overflow.c:100:46: error: invalid type for argument 3:
-builtin-overflow.c:100:46:         int enum e [signed] [addressable] e
+builtin-overflow.c:100:46:         int enum e [addressable] e
 builtin-overflow.c:101:40: error: invalid type for argument 1:
-builtin-overflow.c:101:40:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:101:40:         bool [addressable] [usertype] b
 builtin-overflow.c:102:43: error: invalid type for argument 2:
-builtin-overflow.c:102:43:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:102:43:         bool [addressable] [usertype] b
 builtin-overflow.c:103:46: error: invalid type for argument 3:
-builtin-overflow.c:103:46:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:103:46:         bool [addressable] [usertype] b
 builtin-overflow.c:104:46: error: invalid type for argument 3:
 builtin-overflow.c:104:46:         void *p
 builtin-overflow.c:106:37: error: not enough arguments for __builtin_mul_overflow
@@ -211,15 +211,15 @@ builtin-overflow.c:107:37: error: not enough arguments for __builtin_mul_overflo
 builtin-overflow.c:108:37: error: not enough arguments for __builtin_mul_overflow
 builtin-overflow.c:109:37: error: too many arguments for __builtin_mul_overflow
 builtin-overflow.c:110:38: error: invalid type for argument 1:
-builtin-overflow.c:110:38:         int enum e [signed] [addressable] e
+builtin-overflow.c:110:38:         int enum e [addressable] e
 builtin-overflow.c:111:41: error: invalid type for argument 2:
-builtin-overflow.c:111:41:         int enum e [signed] [addressable] e
+builtin-overflow.c:111:41:         int enum e [addressable] e
 builtin-overflow.c:112:45: error: invalid type for argument 3:
 builtin-overflow.c:112:45:         int enum e *
 builtin-overflow.c:113:38: error: invalid type for argument 1:
-builtin-overflow.c:113:38:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:113:38:         bool [addressable] [usertype] b
 builtin-overflow.c:114:41: error: invalid type for argument 2:
-builtin-overflow.c:114:41:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:114:41:         bool [addressable] [usertype] b
 builtin-overflow.c:115:45: error: invalid type for argument 3:
 builtin-overflow.c:115:45:         bool *
 builtin-overflow.c:116:44: error: invalid type for argument 3:
@@ -229,17 +229,17 @@ builtin-overflow.c:119:39: error: not enough arguments for __builtin_mul_overflo
 builtin-overflow.c:120:39: error: not enough arguments for __builtin_mul_overflow_p
 builtin-overflow.c:121:39: error: too many arguments for __builtin_mul_overflow_p
 builtin-overflow.c:122:40: error: invalid type for argument 1:
-builtin-overflow.c:122:40:         int enum e [signed] [addressable] e
+builtin-overflow.c:122:40:         int enum e [addressable] e
 builtin-overflow.c:123:43: error: invalid type for argument 2:
-builtin-overflow.c:123:43:         int enum e [signed] [addressable] e
+builtin-overflow.c:123:43:         int enum e [addressable] e
 builtin-overflow.c:124:46: error: invalid type for argument 3:
-builtin-overflow.c:124:46:         int enum e [signed] [addressable] e
+builtin-overflow.c:124:46:         int enum e [addressable] e
 builtin-overflow.c:125:40: error: invalid type for argument 1:
-builtin-overflow.c:125:40:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:125:40:         bool [addressable] [usertype] b
 builtin-overflow.c:126:43: error: invalid type for argument 2:
-builtin-overflow.c:126:43:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:126:43:         bool [addressable] [usertype] b
 builtin-overflow.c:127:46: error: invalid type for argument 3:
-builtin-overflow.c:127:46:         bool [unsigned] [addressable] [usertype] b
+builtin-overflow.c:127:46:         bool [addressable] [usertype] b
 builtin-overflow.c:128:46: error: invalid type for argument 3:
 builtin-overflow.c:128:46:         void *p
  * check-error-end
diff --git a/validation/cast-bad-00.c b/validation/cast-bad-00.c
index 30aae2375..6d15485d4 100644
--- a/validation/cast-bad-00.c
+++ b/validation/cast-bad-00.c
@@ -38,10 +38,10 @@ void struct_to_int(u16 val)
  *
  * check-error-start
 cast-bad-00.c:25:18: warning: incorrect type in argument 2 (different base types)
-cast-bad-00.c:25:18:    expected unsigned int [unsigned] [usertype]
+cast-bad-00.c:25:18:    expected unsigned int [usertype]
 cast-bad-00.c:25:18:    got union u [assigned] u
 cast-bad-00.c:33:18: warning: incorrect type in argument 2 (different base types)
-cast-bad-00.c:33:18:    expected unsigned int [unsigned] [usertype]
+cast-bad-00.c:33:18:    expected unsigned int [usertype]
 cast-bad-00.c:33:18:    got struct s [assigned] s
  * check-error-end
  */
diff --git a/validation/choose_expr.c b/validation/choose_expr.c
index b075e6562..b5d2b4e6f 100644
--- a/validation/choose_expr.c
+++ b/validation/choose_expr.c
@@ -7,10 +7,10 @@ static int z = 1/(sizeof(__builtin_choose_expr(1,s,0)) - 42);
  * check-name: choose expr builtin
  * check-error-start
 choose_expr.c:1:51: warning: incorrect type in initializer (different base types)
-choose_expr.c:1:51:    expected int static [signed] [toplevel] x
+choose_expr.c:1:51:    expected int static [toplevel] x
 choose_expr.c:1:51:    got void
 choose_expr.c:2:41: warning: incorrect type in initializer (different base types)
-choose_expr.c:2:41:    expected int static [signed] [toplevel] y
+choose_expr.c:2:41:    expected int static [toplevel] y
 choose_expr.c:2:41:    got char *
 choose_expr.c:4:17: warning: division by zero
  * check-error-end
diff --git a/validation/expand/builtin-expect.c b/validation/expand/builtin-expect.c
index 1207c1326..f4e0664bb 100644
--- a/validation/expand/builtin-expect.c
+++ b/validation/expand/builtin-expect.c
@@ -86,10 +86,10 @@ fptr:
  *
  * check-error-start
 expand/builtin-expect.c:33:33: warning: incorrect type in argument 1 (different base types)
-expand/builtin-expect.c:33:33:    expected long [signed]
+expand/builtin-expect.c:33:33:    expected long
 expand/builtin-expect.c:33:33:    got void *a
 expand/builtin-expect.c:33:36: warning: incorrect type in argument 2 (different base types)
-expand/builtin-expect.c:33:36:    expected long [signed]
+expand/builtin-expect.c:33:36:    expected long
 expand/builtin-expect.c:33:36:    got void *a
 expand/builtin-expect.c:33:32: warning: incorrect type in return expression (different base types)
 expand/builtin-expect.c:33:32:    expected void *
-- 
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