Skip to contentSkip to conversation

Fix support for "complex double" in parameter lists

PATCH Superseded Eric Wheeler 3 participants 8 messages Mar 7, 2022 – Mar 9, 2022

lore
Share & tools
lore
#0 lore raw

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
index 949c0bf..22fe5e7 100644
@@ -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] }
#1 lore raw

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
index 019ee3b..8c1fe8e 100644
@@ -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
index 949c0bf..22fe5e7 100644
@@ -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] }
#2 lore raw

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 -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
index 019ee3b..8c1fe8e 100644
@@ -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
index 949c0bf..22fe5e7 100644
@@ -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] }
#3 lore raw

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
index 019ee3b..8c1fe8e 100644
@@ -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
index 949c0bf..22fe5e7 100644
@@ -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] }
Applied
#4 lore raw
Quoted 5 lines · Eric Wheeler

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

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
index 019ee3b..8c1fe8e 100644
@@ -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
index 949c0bf..22fe5e7 100644
@@ -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] }
#6 lore raw
In reply to Eric Wheeler
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?

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/process/submitting-patches.rst?h=v5.16.12#n705

Regards,
Markus

#7 lore raw
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?

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/process/submitting-patches.rst?h=v5.16.12#n705

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