diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2016-11-24 18:09:47 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:44 +0800 |
| commit | e0a5962d74e9add628f012a2eb657e5512a22753 (patch) | |
| tree | 14c98fef77095fef24e183290ca67abfa2dc0e86 /cgcc | |
| parent | 548e90093d336d28f4bb00b3267417d145a6b601 (diff) | |
| download | sparse-dev-e0a5962d74e9add628f012a2eb657e5512a22753.tar.gz | |
some modifiers need to be preserved by 'typeof()'
Currently when we use typeof() all the modifiers from the source
type are ignored and thus not present in the resulting type.
This give all sort of problems. One simple example is:
const int obj;
typeof(obj) *ptr;
*ptr = 0;
We can expect that 'ptr' will have the type 'const int *' and thus
that sparse will warn on the assignment in the last line but it's
not case because 'ptr' has in fact the type 'int *'.
The patch fix this by preserving some of the modifiers when using
typeof().
WARNING: it may be that the old behaviour was so more or less on
purpose as it provide a way to remove some modifiers by casting
while still being able to use generic macros. For exmaple, it
was possible to write the following macro:
#define noconst(x) (typeof(x))
and use 'noconst()' as a cast to remove 'const' from types.
Of course, the problem with this macros is that it remove
*all* modifiers, not only 'const'.
With the patch, it won't be possible anymore to do this sort of
things, which maybe is fine for 'const' but it's why MOD_NOREFREF
is still dropped as it create problems in the Linew kernel, for example
in the macro to convert back a percpu variable into a plain one.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'cgcc')
0 files changed, 0 insertions, 0 deletions
