On 05/05/2025 1:57 pm, Nicola Vetrini wrote: > On 2025-05-05 14:46, Andrew Cooper wrote: >> In macros it is common to declare local variables using typeof(param) >> in order >> to ensure that side effects are only evaluated once. A consequence >> of this is >> double textural expansion of the parameter, which can get out of hand >> very >> quickly with nested macros. >> >> A GCC extension, __auto_type, is now avaialble in the new toolchain >> baseline >> and avoids the double textural expansion. >> >> Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com> >> --- >> CC: Anthony PERARD <anthony.per...@vates.tech> >> CC: Michal Orzel <michal.or...@amd.com> >> CC: Jan Beulich <jbeul...@suse.com> >> CC: Julien Grall <jul...@xen.org> >> CC: Roger Pau Monné <roger....@citrix.com> >> CC: Stefano Stabellini <sstabell...@kernel.org> >> CC: Roberto Bagnara <roberto.bagn...@bugseng.com> >> CC: Nicola Vetrini <nicola.vetr...@bugseng.com> >> CC: consult...@bugseng.com <consult...@bugseng.com> >> >> The resulting build is identical. >> >> RFC. This requires a MISRA change, as it currently manifests as a R1.1 >> violation. Nevertheless, I think we want to start using in places >> where we >> currently use typeof(expression of <initilaiser>). >> >> Eclair run on this patch (expecting a failure): >> >> https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1800631949 >> > > Hi, > > to make the analysis pass you need a couple of hunks in > eclair_analysis/ECLAIR/toolchain.ecl: > > -name_selector+={auto_type, "^__auto_type$"} > > and add auto_type to the STD.tokenext config below around line 25, > then later > > -name_selector+={ext_auto_type, "^ext_auto_type$"} > > and add "ext_auto_type" to the -config lines below > > around line 125, along with a reference to the gcc docs above the > configurations and in C-language-toolchain.rst > > This is an extension, so it's usable without further MISRA impact.
Excellent, thankyou. I'll leave this email out for discussion, and if it goes in a positive direction, I'll submit a v2 with (hopefully) all the MISRA/Eclair changes required. ~Andrew