Re: [PATCH 3/8] riscv: init: merge split string literals in preprocessor directive

From: Luc Van Oostenryck
Date: Fri Oct 18 2019 - 01:47:14 EST


On Thu, Oct 17, 2019 at 09:38:18PM -0700, Paul Walmsley wrote:
> On Fri, 18 Oct 2019, Luc Van Oostenryck wrote:
>
> > On Thu, Oct 17, 2019 at 05:49:24PM -0700, Paul Walmsley wrote:
> > > sparse complains loudly when string literals associated with
> > > preprocessor directives are split into multiple, separately quoted
> > > strings across different lines:
> >
> > ...
> >
> > > #ifndef __riscv_cmodel_medany
> > > -#error "setup_vm() is called from head.S before relocate so it should "
> > > - "not use absolute addressing."
> > > +#error "setup_vm() is called from head.S before relocate so it should not use absolute addressing."
> > > #endif

...

> On the other hand, gcc seems to support the non-backslashed syntax. So if
> the intention is for sparse to follow the gcc practice, and to be used
> beyond the kernel, maybe it's worth aligning sparse to gcc? Only if
> you're bored, I suppose...

I quickly checked and gcc also complain about the second line:
$ cat y.c
#ifndef __riscv_cmodel_medany
#error "setup_vm() is called from head.S before relocate so it should "
"not use absolute addressing."
#endif

$ gcc -c y.c
y.c:2:2: error: #error "setup_vm() is called from head.S before relocate so it should "
#error "setup_vm() is called from head.S before relocate so it should "
^~~~~
y.c:3:8: error: expected identifier or '(' before string constant
"not use absolute addressing."
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So it seems that gcc doesn't join these lines.
Fell free to add my:
Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>

-- Luc