diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-12 22:26:28 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-17 00:38:46 +0200 |
| commit | 8b3cbf54ad42c68f5ea2fa5bc2cef5ce9e608571 (patch) | |
| tree | d415ba8c9847ce463b0f967878d663737f6e9084 /validation | |
| parent | 8b5d92da3b1919f574decb542d93fde82693fe71 (diff) | |
| download | sparse-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 'validation')
| -rw-r--r-- | validation/eval/union-cast-no.c | 1 | ||||
| -rw-r--r-- | validation/eval/union-cast.c | 1 |
2 files changed, 0 insertions, 2 deletions
diff --git a/validation/eval/union-cast-no.c b/validation/eval/union-cast-no.c index d06b348d..6ba38db8 100644 --- a/validation/eval/union-cast-no.c +++ b/validation/eval/union-cast-no.c @@ -16,7 +16,6 @@ static union u bar(long l) /* * check-name: union-cast-no * check-command: sparse -Wno-union-cast $file - * check-known-to-fail * * check-error-start eval/union-cast-no.c:13:17: warning: cast to non-scalar diff --git a/validation/eval/union-cast.c b/validation/eval/union-cast.c index 1d816753..5bee9e0d 100644 --- a/validation/eval/union-cast.c +++ b/validation/eval/union-cast.c @@ -16,7 +16,6 @@ static union u bar(long a) /* * check-name: union-cast * check-command: sparse -Wunion-cast $file - * check-known-to-fail * * check-error-start eval/union-cast.c:8:17: warning: cast to union type |
