Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF33CC433F5 for ; Mon, 7 Mar 2022 08:02:33 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.90,161,1643670000"; d="scan'208";a="24692882" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 07 Mar 2022 09:02:31 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 2BDE3E00D3; Mon, 7 Mar 2022 09:02:31 +0100 (CET) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id C51E4E004B for ; Mon, 7 Mar 2022 09:02:28 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.90,161,1643670000"; d="scan'208";a="24692875" Received: from 203.107.68.85.rev.sfr.net (HELO hadrien) ([85.68.107.203]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 09:02:29 +0100 Date: Mon, 7 Mar 2022 09:02:28 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Eric Wheeler cc: cocci@inria.fr In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [cocci] [PATCH v2] Fix support for "complex double" in parameter lists Reply-To: Julia Lawall X-Loop: cocci@inria.fr X-Sequence: 177 Errors-To: cocci-owner@inria.fr Precedence: list Precedence: bulk Sender: cocci-request@inria.fr X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: 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 On Sun, 6 Mar 2022, Eric Wheeler wrote: > From: Eric Wheeler > Author: Eric Wheeler > 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; > } > > diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml > index 019ee3b..8c1fe8e 100644 > --- a/engine/cocci_vs_c.ml > +++ b/engine/cocci_vs_c.ml > @@ -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] > diff --git a/parsing_c/parser_c.mly b/parsing_c/parser_c.mly > index 949c0bf..22fe5e7 100644 > --- a/parsing_c/parser_c.mly > +++ b/parsing_c/parser_c.mly > @@ -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] } > >