Fix support for "complex double" in parameter lists
PATCH 1/1 Fix support for "complex double" in parameter lists
From: Eric Wheeler <[email protected]>
Author: Eric Wheeler <[email protected]>
Date: Sun Mar 6 16:55:32 2022 -0800
Fix support for complex double in parameter lists
It seems that `parameter list` does _not_ support `complex double`,
but it _does_ support `double complex`. Coccinelle already supports
`double complex` and `float complex` so this commit adds grammar support
for the reverse of `complex double` and `complex float`.
With this SmPL:
@ rule1 @
type T;
identifier F, j;
typedef nec_t;
parameter list PL;
@@
T F(
+nec_t *nec,
PL
)
{
... when exists
when any
nec->j
... when exists
when any
}
This works:
void qdsrc( int is, double complex v, double complex *e )
{
is--;
i= nec->data.icon1[is];
}
but this did not:
void qdsrc( int is, complex double v, complex double *e )
{
is--;
i= nec->data.icon1[is];
}parsing_c/parser_c.mly +2 -0
@@ -1270,7 +1270,9 @@ type_spec2: | Tfloat { Right3 (BaseType (FloatType CFloat)), [$1]} | Tdouble { Right3 (BaseType (FloatType CDouble)), [$1] } | Tfloat Tcomplex { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} + | Tcomplex Tfloat { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} | Tdouble Tcomplex { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } + | Tcomplex Tdouble { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } | Tsize_t { Right3 (BaseType SizeType), [$1] } | Tssize_t { Right3 (BaseType SSizeType), [$1] } | Tptrdiff_t { Right3 (BaseType PtrDiffType), [$1] }
PATCH v2 1/1 Fix support for "complex double" in parameter lists
From: Eric Wheeler <[email protected]>
Author: Eric Wheeler <[email protected]>
Date: Sun Mar 6 16:55:32 2022 -0800
Fix support for complex double in parameter lists
It seems that `parameter list` does _not_ support `complex double`,
but it _does_ support `double complex`. Coccinelle already supports
`double complex` and `float complex` so this commit adds grammar support
for the reverse of `complex double` and `complex float`.
With this SmPL:
@ rule1 @
type T;
identifier F, j;
typedef nec_t;
parameter list PL;
@@
T F(
+nec_t *nec,
PL
)
{
... when exists
when any
nec->j
... when exists
when any
}
This works:
void qdsrc( int is, double complex v, double complex *e )
{
is--;
i= nec->data.icon1[is];
}
but this did not:
void qdsrc( int is, complex double v, complex double *e )
{
is--;
i= nec->data.icon1[is];
}
Patch v2: Fixed error: "strange type2, maybe because of weird order: complex double"
when patching this example function:
static void Near_Field_Total( complex double ex, complex double ey, complex double ez, int nfeh, int idx )
{
nec->x++;
return;
}engine/cocci_vs_c.ml +2 -0
@@ -408,7 +408,9 @@ let split_signb_baseb_ii (baseb, ii) = | B.FloatType (B.CFloat),["float",i1] -> None, [i1] | B.FloatType (B.CDouble),["double",i1] -> None, [i1] | B.FloatType (B.CFloatComplex),["float",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CFloatComplex),["complex",i1;"float",i2] -> None, [i1;i2] | B.FloatType (B.CDoubleComplex),["double",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CDoubleComplex),["complex",i1;"double",i2] -> None, [i1;i2] | B.FloatType (B.CLongDouble),["long",i1;"double",i2] -> None,[i1;i2] | B.FloatType (B.CLongDoubleComplex),["long",i1;"double",i2;"complex",i3] -> None,[i1;i2;i3]
parsing_c/parser_c.mly +2 -0
@@ -1270,7 +1270,9 @@ type_spec2: | Tfloat { Right3 (BaseType (FloatType CFloat)), [$1]} | Tdouble { Right3 (BaseType (FloatType CDouble)), [$1] } | Tfloat Tcomplex { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} + | Tcomplex Tfloat { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} | Tdouble Tcomplex { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } + | Tcomplex Tdouble { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } | Tsize_t { Right3 (BaseType SizeType), [$1] } | Tssize_t { Right3 (BaseType SSizeType), [$1] } | Tptrdiff_t { Right3 (BaseType PtrDiffType), [$1] }
Thanks for the patch. Could you resend with a Signed-off-by?
See the end of the README at the bottom of
https://github.com/coccinelle/coccinelle
thanks,
julia
Quoted 86 lines · Eric Wheeler
From: Eric Wheeler <[email protected]>
Author: Eric Wheeler <[email protected]>
Date: Sun Mar 6 16:55:32 2022 -0800Fix support for complex double in parameter lists It seems that `parameter list` does _not_ support `complex double`, but it _does_ support `double complex`. Coccinelle already supports `double complex` and `float complex` so this commit adds grammar support for the reverse of `complex double` and `complex float`. With this SmPL: @ rule1 @ type T; identifier F, j; typedef nec_t; parameter list PL; @@ T F( +nec_t *nec, PL ) { ... when exists when any nec->j ... when exists when any } This works: void qdsrc( int is, double complex v, double complex *e ) { is--; i= nec->data.icon1[is]; } but this did not: void qdsrc( int is, complex double v, complex double *e ) { is--; i= nec->data.icon1[is]; } Patch v2: Fixed error: "strange type2, maybe because of weird order: complex double" when patching this example function: static void Near_Field_Total( complex double ex, complex double ey, complex double ez, int nfeh, int idx ) { nec->x++; return; }engine/cocci_vs_c.ml +2
-0@@ -408,7 +408,9 @@ let split_signb_baseb_ii (baseb, ii) = | B.FloatType (B.CFloat),["float",i1] -> None, [i1] | B.FloatType (B.CDouble),["double",i1] -> None, [i1] | B.FloatType (B.CFloatComplex),["float",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CFloatComplex),["complex",i1;"float",i2] -> None, [i1;i2] | B.FloatType (B.CDoubleComplex),["double",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CDoubleComplex),["complex",i1;"double",i2] -> None, [i1;i2] | B.FloatType (B.CLongDouble),["long",i1;"double",i2] -> None,[i1;i2] | B.FloatType (B.CLongDoubleComplex),["long",i1;"double",i2;"complex",i3] -> None,[i1;i2;i3]parsing_c/parser_c.mly +2
-0@@ -1270,7 +1270,9 @@ type_spec2: | Tfloat { Right3 (BaseType (FloatType CFloat)), [$1]} | Tdouble { Right3 (BaseType (FloatType CDouble)), [$1] } | Tfloat Tcomplex { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} + | Tcomplex Tfloat { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} | Tdouble Tcomplex { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } + | Tcomplex Tdouble { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } | Tsize_t { Right3 (BaseType SizeType), [$1] } | Tssize_t { Right3 (BaseType SSizeType), [$1] } | Tptrdiff_t { Right3 (BaseType PtrDiffType), [$1] }
PATCH v3 1/1 Fix support for "complex double" in parameter lists
From: Eric Wheeler <[email protected]>
Author: Eric Wheeler <[email protected]>
Date: Sun Mar 6 16:55:32 2022 -0800
Fix support for complex double in parameter lists
It seems that `parameter list` does _not_ support `complex double`,
but it _does_ support `double complex`. Coccinelle already supports
`double complex` and `float complex` so this commit adds grammar support
for the reverse of `complex double` and `complex float`.
With this SmPL:
@ rule1 @
type T;
identifier F, j;
typedef nec_t;
parameter list PL;
@@
T F(
+nec_t *nec,
PL
)
{
... when exists
when any
nec->j
... when exists
when any
}
This works:
void qdsrc( int is, double complex v, double complex *e )
{
is--;
i= nec->data.icon1[is];
}
but this did not:
void qdsrc( int is, complex double v, complex double *e )
{
is--;
i= nec->data.icon1[is];
}
Patch v2: Fixed: strange type2, maybe because of weird order: complex double
when patching this example function:
static void Near_Field_Total( complex double ex, complex double ey, complex double ez, int nfeh, int idx )
{
nec->x++;
return;
}
Patch v3: Added signed-off-by.
Signed-off-by: Eric Wheeler <[email protected]>engine/cocci_vs_c.ml +2 -0
@@ -408,7 +408,9 @@ let split_signb_baseb_ii (baseb, ii) = | B.FloatType (B.CFloat),["float",i1] -> None, [i1] | B.FloatType (B.CDouble),["double",i1] -> None, [i1] | B.FloatType (B.CFloatComplex),["float",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CFloatComplex),["complex",i1;"float",i2] -> None, [i1;i2] | B.FloatType (B.CDoubleComplex),["double",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CDoubleComplex),["complex",i1;"double",i2] -> None, [i1;i2] | B.FloatType (B.CLongDouble),["long",i1;"double",i2] -> None,[i1;i2] | B.FloatType (B.CLongDoubleComplex),["long",i1;"double",i2;"complex",i3] -> None,[i1;i2;i3]
parsing_c/parser_c.mly +2 -0
@@ -1270,7 +1270,9 @@ type_spec2: | Tfloat { Right3 (BaseType (FloatType CFloat)), [$1]} | Tdouble { Right3 (BaseType (FloatType CDouble)), [$1] } | Tfloat Tcomplex { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} + | Tcomplex Tfloat { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} | Tdouble Tcomplex { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } + | Tcomplex Tdouble { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } | Tsize_t { Right3 (BaseType SizeType), [$1] } | Tssize_t { Right3 (BaseType SSizeType), [$1] } | Tptrdiff_t { Right3 (BaseType PtrDiffType), [$1] }
Julia Lawall
AppliedQuoted 5 lines · Eric Wheeler
From: Eric Wheeler <[email protected]>
Author: Eric Wheeler <[email protected]>
Date: Sun Mar 6 16:55:32 2022 -0800Fix support for complex double in parameter lists
Applied, thanks.
julia
Quoted 85 lines
It seems that `parameter list` does _not_ support `complex double`, but it _does_ support `double complex`. Coccinelle already supports `double complex` and `float complex` so this commit adds grammar support for the reverse of `complex double` and `complex float`. With this SmPL: @ rule1 @ type T; identifier F, j; typedef nec_t; parameter list PL; @@ T F( +nec_t *nec, PL ) { ... when exists when any nec->j ... when exists when any } This works: void qdsrc( int is, double complex v, double complex *e ) { is--; i= nec->data.icon1[is]; } but this did not: void qdsrc( int is, complex double v, complex double *e ) { is--; i= nec->data.icon1[is]; } Patch v2: Fixed: strange type2, maybe because of weird order: complex double when patching this example function: static void Near_Field_Total( complex double ex, complex double ey, complex double ez, int nfeh, int idx ) { nec->x++; return; } Patch v3: Added signed-off-by. Signed-off-by: Eric Wheeler <[email protected]>engine/cocci_vs_c.ml +2
-0@@ -408,7 +408,9 @@ let split_signb_baseb_ii (baseb, ii) = | B.FloatType (B.CFloat),["float",i1] -> None, [i1] | B.FloatType (B.CDouble),["double",i1] -> None, [i1] | B.FloatType (B.CFloatComplex),["float",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CFloatComplex),["complex",i1;"float",i2] -> None, [i1;i2] | B.FloatType (B.CDoubleComplex),["double",i1;"complex",i2] -> None, [i1;i2] + | B.FloatType (B.CDoubleComplex),["complex",i1;"double",i2] -> None, [i1;i2] | B.FloatType (B.CLongDouble),["long",i1;"double",i2] -> None,[i1;i2] | B.FloatType (B.CLongDoubleComplex),["long",i1;"double",i2;"complex",i3] -> None,[i1;i2;i3]parsing_c/parser_c.mly +2
-0@@ -1270,7 +1270,9 @@ type_spec2: | Tfloat { Right3 (BaseType (FloatType CFloat)), [$1]} | Tdouble { Right3 (BaseType (FloatType CDouble)), [$1] } | Tfloat Tcomplex { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} + | Tcomplex Tfloat { Right3 (BaseType (FloatType CFloatComplex)), [$1;$2]} | Tdouble Tcomplex { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } + | Tcomplex Tdouble { Right3 (BaseType (FloatType CDoubleComplex)), [$1;$2] } | Tsize_t { Right3 (BaseType SizeType), [$1] } | Tssize_t { Right3 (BaseType SSizeType), [$1] } | Tptrdiff_t { Right3 (BaseType PtrDiffType), [$1] }
Quoted 2 lines
Quoted 1 line
Fix support for complex double in parameter lists
Applied, thanks.
How does this feedback fit to a related display from your software development repository?
https://gitlab.inria.fr/coccinelle/coccinelle/-/merge_requests/173
Regards,
Markus
Quoted 1 line
Patch v2: Fixed: strange type2, maybe because of weird order: complex double
…
Quoted 1 line
Patch v3: Added signed-off-by.
…
I suggest to reconsider the detail if such patch version indications should belong to the patch description (or not).
Would you like to take another look at advice from an other information source?
Regards,
Markus
Quoted 11 lines · Markus Elfring
Quoted 2 lines
Patch v2: Fixed: strange type2, maybe because of weird order: complex double
…
Quoted 1 line
Patch v3: Added signed-off-by.
…
Quoted 7 lines
I suggest to reconsider the detail if such patch version indications should belong to the patch description (or not).
Would you like to take another look at advice from an other information source?
Good point. It was a courtesy for Julia so she could easily see the difference. Maybe only the subject needed the v3 marker.
--
Eric Wheeler
Quoted 5 lines
Regards,
Markus