[PATCH 8/8] teach sparse about _Floatn and _Floatnx

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

 



It seems that some system headers (Debian x32's glibc) use
these type based on GCC's version without checking one of
the '__STDC_IEC_60559_<something>' macro. This, of course,
creates warnings and errors when using sparse on them.

Avoid these errors & warnings by adding basic support for
these types.

Note: full support would requires change in the parsing to
      recognize the suffixes '[fF]32', ... for constants
      and most probably many others things which are
      outside the scope of this patch.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 parse.c  |  5 +++++
 symbol.c | 14 ++++++++++++++
 symbol.h |  3 +++
 3 files changed, 22 insertions(+)

diff --git a/parse.c b/parse.c
index bb504d21a..0a2e1b526 100644
--- a/parse.c
+++ b/parse.c
@@ -458,6 +458,11 @@ static struct init_keyword {
 	{ "__builtin_ms_va_list", NS_TYPEDEF, .type = &ptr_ctype, .op = &spec_op },
 	{ "__int128_t",	NS_TYPEDEF, .type = &lllong_ctype, .op = &spec_op },
 	{ "__uint128_t",NS_TYPEDEF, .type = &ulllong_ctype, .op = &spec_op },
+	{ "_Float32",	NS_TYPEDEF, .type = &float32_ctype, .op = &spec_op },
+	{ "_Float32x",	NS_TYPEDEF, .type = &float32x_ctype, .op = &spec_op },
+	{ "_Float64",	NS_TYPEDEF, .type = &float64_ctype, .op = &spec_op },
+	{ "_Float64x",	NS_TYPEDEF, .type = &float64x_ctype, .op = &spec_op },
+	{ "_Float128",	NS_TYPEDEF, .type = &float128_ctype, .op = &spec_op },
 
 	/* Extended types */
 	{ "typeof", 	NS_TYPEDEF, .op = &typeof_op },
diff --git a/symbol.c b/symbol.c
index 6cfaf2c8f..df9fd651d 100644
--- a/symbol.c
+++ b/symbol.c
@@ -696,6 +696,9 @@ struct symbol	bool_ctype, void_ctype, type_ctype,
 		string_ctype, ptr_ctype, lazy_ptr_ctype,
 		incomplete_ctype, label_ctype, bad_ctype,
 		null_ctype;
+struct symbol	float32_ctype, float32x_ctype;
+struct symbol	float64_ctype, float64x_ctype;
+struct symbol	float128_ctype;
 struct symbol	const_void_ctype, const_char_ctype;
 struct symbol	const_ptr_ctype, const_string_ctype;
 
@@ -719,6 +722,11 @@ void init_symbols(void)
 	init_builtins(stream);
 }
 
+// For fix-sized types
+static int bits_in_type32 = 32;
+static int bits_in_type64 = 64;
+static int bits_in_type128 = 128;
+
 #define MOD_ESIGNED (MOD_SIGNED | MOD_EXPLICITLY_SIGNED)
 #define MOD_LL (MOD_LONG | MOD_LONGLONG)
 #define MOD_LLL MOD_LONGLONGLONG
@@ -759,6 +767,12 @@ static const struct ctype_declare {
 	{ &double_ctype,    SYM_BASETYPE, MOD_LONG,		    &bits_in_double,         &max_fp_alignment,  &fp_type },
 	{ &ldouble_ctype,   SYM_BASETYPE, MOD_LONG | MOD_LONGLONG,  &bits_in_longdouble,     &max_fp_alignment,  &fp_type },
 
+	{ &float32_ctype,   SYM_BASETYPE,  0,			    &bits_in_type32,          &max_fp_alignment, &fp_type },
+	{ &float32x_ctype,  SYM_BASETYPE, MOD_LONG,		    &bits_in_double,         &max_fp_alignment,  &fp_type },
+	{ &float64_ctype,   SYM_BASETYPE,  0,			    &bits_in_type64,          &max_fp_alignment, &fp_type },
+	{ &float64x_ctype,  SYM_BASETYPE, MOD_LONG | MOD_LONGLONG,  &bits_in_longdouble,     &max_fp_alignment,  &fp_type },
+	{ &float128_ctype,  SYM_BASETYPE,  0,			    &bits_in_type128,         &max_alignment,    &fp_type },
+
 	{ &string_ctype,    SYM_PTR,	  0,			    &bits_in_pointer,        &pointer_alignment, &char_ctype },
 	{ &ptr_ctype,	    SYM_PTR,	  0,			    &bits_in_pointer,        &pointer_alignment, &void_ctype },
 	{ &null_ctype,	    SYM_PTR,	  0,			    &bits_in_pointer,        &pointer_alignment, &void_ctype },
diff --git a/symbol.h b/symbol.h
index dc6de8fa4..09f7340b1 100644
--- a/symbol.h
+++ b/symbol.h
@@ -267,6 +267,9 @@ extern struct symbol	bool_ctype, void_ctype, type_ctype,
 			string_ctype, ptr_ctype, lazy_ptr_ctype,
 			incomplete_ctype, label_ctype, bad_ctype,
 			null_ctype;
+extern struct symbol	float32_ctype, float32x_ctype;
+extern struct symbol	float64_ctype, float64x_ctype;
+extern struct symbol	float128_ctype;
 extern struct symbol	const_void_ctype, const_char_ctype;
 extern struct symbol	const_ptr_ctype, const_string_ctype;
 
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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