2019-06-04 11:11:38 +03:00
// SPDX-License-Identifier: GPL-2.0-only
2012-04-21 22:23:48 +04:00
/// sizeof when applied to a pointer typed expression gives the size of
/// the pointer
///
// Confidence: High
2019-06-04 11:11:38 +03:00
// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
2012-04-21 22:23:48 +04:00
// URL: http://coccinelle.lip6.fr/
// Comments:
2013-06-20 15:10:56 +04:00
// Options: --no-includes --include-headers
2012-04-21 22:23:48 +04:00
virtual org
virtual report
virtual context
virtual patch
@depends on patch@
expression *x;
expression f;
2016-05-24 07:19:17 +03:00
expression i;
2012-04-21 22:23:48 +04:00
type T;
@@
(
x = <+... sizeof(
- x
+ *x
) ...+>
|
f(...,(T)(x),...,sizeof(
- x
+ *x
),...)
|
2016-05-24 07:19:17 +03:00
f(...,sizeof(
- x
+ *x
),...,(T)(x),...)
|
f(...,(T)(x),...,i*sizeof(
2012-04-21 22:23:48 +04:00
- x
+ *x
),...)
2016-05-24 07:19:17 +03:00
|
f(...,i*sizeof(
- x
+ *x
),...,(T)(x),...)
2012-04-21 22:23:48 +04:00
)
@r depends on !patch@
expression *x;
expression f;
2016-05-24 07:19:17 +03:00
expression i;
2012-04-21 22:23:48 +04:00
position p;
type T;
@@
(
*x = <+... sizeof@p(x) ...+>
|
*f(...,(T)(x),...,sizeof@p(x),...)
|
*f(...,sizeof@p(x),...,(T)(x),...)
2016-05-24 07:19:17 +03:00
|
*f(...,(T)(x),...,i*sizeof@p(x),...)
|
*f(...,i*sizeof@p(x),...,(T)(x),...)
2012-04-21 22:23:48 +04:00
)
@script:python depends on org@
p << r.p;
@@
cocci.print_main("application of sizeof to pointer",p)
@script:python depends on report@
p << r.p;
@@
msg = "ERROR: application of sizeof to pointer"
coccilib.report.print_report(p[0],msg)