aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2016-01-05 17:25:53 +0100
committerChristopher Li <sparse@chrisli.org>2016-02-23 02:26:42 +0800
commit7647c775497f8c0f5841051377fba8cbb495c275 (patch)
treeac8e83eec823f60c26e4fa4032087870f344ff53 /Makefile
parent8efbac18a251580615e3a5c587155fd7233b1b13 (diff)
downloadsparse-dev-7647c775497f8c0f5841051377fba8cbb495c275.tar.gz
Do not drop 'nocast' modifier when taking the address.
With the following code: typedef unsigned long __nocast cputime_t; void task_cputime_adjusted(cputime_t *); void current_task_runtime_100ns(void) { cputime_t utime; task_cputime_adjusted(&utime); } sparse emits the following message: x.c:16:32: warning: incorrect type in argument 1 (different modifiers) x.c:16:32: expected unsigned long [nocast] [usertype] *<noident> x.c:16:32: got unsigned long *<noident> x.c:16:32: warning: implicit cast to nocast type In other words, when taking the address of 'utime', sparse drops the 'nocast' modifier and then complains that task_cputime_adjusted() is not given a 'nocast' pointer as expected ... This feels wrong to me. The proposed fix is to simply not dropping the 'nocast' modifier when taking the address, like done for a normal type qualifier. This gives very reasonable behaviour for all the test cases I could think of: - taking the address or dereferencing doesn't drop the nocast - arithmetic operations on nocast give a nocast result. - implicit to/from cast is OK only if the base type are the same - implicit to/from pointer cast is OK only if the base type are the same This still gives a "leaky" semantic: the nocast modifier can be lost via an implicit cast to a non-qualified value. Explicit cast to or from nocast values doesn't give any warning, maybe it's OK, maybe it's not but it's orthogonal to the current issue. Is this the wanted semantic for the nocast modifier? Reported-by: Roman Kagan <rkagan@virtuozzo.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions