aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/options.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-08-12 22:26:28 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-08-17 00:38:46 +0200
commit8b3cbf54ad42c68f5ea2fa5bc2cef5ce9e608571 (patch)
treed415ba8c9847ce463b0f967878d663737f6e9084 /options.c
parent8b5d92da3b1919f574decb542d93fde82693fe71 (diff)
downloadsparse-dev-8b3cbf54ad42c68f5ea2fa5bc2cef5ce9e608571.tar.gz
union-cast: teach sparse about union casts
A cast to union type is a GCC extension similar to a compound literal just for union, using the syntax of a cast. However, sparse doesn't know about them and treats them like other casts to non-scalars. So, teach sparse about them, convert them to the corresponding compound literal and add a warning flag to enable/disable the associated warning: -W[no-]union-cast. Note: a difference between union casts and compound literals is that the union casts yield rvalues while compound literals are lvalues but this distinction is not yet done in this series. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'options.c')
-rw-r--r--options.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/options.c b/options.c
index f7e81b84..b25f7150 100644
--- a/options.c
+++ b/options.c
@@ -129,6 +129,7 @@ int Wtransparent_union = 0;
int Wtypesign = 0;
int Wundef = 0;
int Wuninitialized = 1;
+int Wunion_cast = 0;
int Wuniversal_initializer = 0;
int Wunknown_attribute = 0;
int Wvla = 1;
@@ -866,6 +867,7 @@ static const struct flag warnings[] = {
{ "typesign", &Wtypesign },
{ "undef", &Wundef },
{ "uninitialized", &Wuninitialized },
+ { "union-cast", &Wunion_cast },
{ "universal-initializer", &Wuniversal_initializer },
{ "unknown-attribute", &Wunknown_attribute },
{ "vla", &Wvla },