Re: [Cocci] Not pointer expression

2018-02-08 Thread Francois-Xavier Le Bail
On 08/02/2018 15:44, Julia Lawall wrote:
> 
> 
> On Thu, 8 Feb 2018, Francois-Xavier Le Bail wrote:
> 
>> Hi,
>>
>> expression *e;
>> define 'e' is a pointer expression.
>>
>> Is there a way to define 'e' is *not* a pointer expression?
> 
> @@
> expression *e;
> expression e1;
> @@
> 
> (
> e
> |
> *e1
> )
> 
> The above will highlight all expressions that have not been inferred to
> have a pointer type.  But note that that doesn't mean that it has been
> inferred that the expression as a non-pointer type.  It could be that not
> enough information is available.
> 
> Another option would be:
> 
> @@
> expression *e;
> type T;
> T e1;
> @@
> 
> (
> e
> |
> *e1
> )
> 
> Now it should require that e1 actually has a known type and it is not a
> pointer type.
> 
> Another approach would be:
> 
> @bad@
> position p;
> expression *e;
> @@
> 
> e@p
> 
> @ok@
> position p != bad.p;
> type T;
> T e;
> @@
> 
> *e@p
> 
> If you are actually interested in structure types, you could also say
> 
> struct e;

Thanks, I will do some tests with these different approaches.

-- 
Francois-Xavier
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] Not pointer expression

2018-02-08 Thread Julia Lawall


On Thu, 8 Feb 2018, Francois-Xavier Le Bail wrote:

> Hi,
>
> expression *e;
> define 'e' is a pointer expression.
>
> Is there a way to define 'e' is *not* a pointer expression?

@@
expression *e;
expression e1;
@@

(
e
|
*e1
)

The above will highlight all expressions that have not been inferred to
have a pointer type.  But note that that doesn't mean that it has been
inferred that the expression as a non-pointer type.  It could be that not
enough information is available.

Another option would be:

@@
expression *e;
type T;
T e1;
@@

(
e
|
*e1
)

Now it should require that e1 actually has a known type and it is not a
pointer type.

Another approach would be:

@bad@
position p;
expression *e;
@@

e@p

@ok@
position p != bad.p;
type T;
T e;
@@

*e@p

If you are actually interested in structure types, you could also say

struct e;

julia



> --
> Francois-Xavier
> ___
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci