aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2016-11-24 18:09:47 +0100
committerChristopher Li <sparse@chrisli.org>2017-02-13 09:34:44 +0800
commite0a5962d74e9add628f012a2eb657e5512a22753 (patch)
tree14c98fef77095fef24e183290ca67abfa2dc0e86 /validation
parent548e90093d336d28f4bb00b3267417d145a6b601 (diff)
downloadsparse-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 'validation')
-rw-r--r--validation/typeof-mods.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/validation/typeof-mods.c b/validation/typeof-mods.c
index 8c98ab8c..9822e96f 100644
--- a/validation/typeof-mods.c
+++ b/validation/typeof-mods.c
@@ -102,7 +102,6 @@ static void test_nocast(void)
/*
* check-name: typeof-mods
- * check-known-to-fail
*
* check-error-start
* check-error-end