diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-17 21:52:42 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-18 01:19:06 +0100 |
| commit | 626c474204e8262467a316099b6074cab964237c (patch) | |
| tree | d9777c8a74671da0a2cc78bc6005f96188504603 /validation/eval/unqual-cast.c | |
| parent | bbb3d7fcbe6d2bba07ee4664acbbab5e6e8c8b2a (diff) | |
| download | sparse-dev-626c474204e8262467a316099b6074cab964237c.tar.gz | |
casts should drop qualifiers
Casts should drop qualifiers but Sparse doesn't do this yet.
The fix seems pretty simple: after having evaluated the type of
the cast, if this type is a SYM_NODE and contains qualifiers,
make a copy of the type with the qualifiers removed and use
this copy as the type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/eval/unqual-cast.c')
| -rw-r--r-- | validation/eval/unqual-cast.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/validation/eval/unqual-cast.c b/validation/eval/unqual-cast.c new file mode 100644 index 00000000..4106ec3b --- /dev/null +++ b/validation/eval/unqual-cast.c @@ -0,0 +1,14 @@ +#define cvr const volatile restrict + +_Static_assert([typeof((cvr int) 0)] == [int]); +_Static_assert([typeof((cvr int *) 0)] == [cvr int *]); + +static int *function(volatile int x) +{ + extern typeof((typeof(x)) (x)) y; + return &y; +} + +/* + * check-name: unqual-cast + */ |
