* [PATCH] scripts/unifdef: avoid constexpr keyword
@ 2024-03-20 17:59 Arnd Bergmann
2024-03-21 15:53 ` Tony Finch
2024-03-29 9:59 ` Masahiro Yamada
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2024-03-20 17:59 UTC (permalink / raw)
To: Tony Finch, Sam Ravnborg
Cc: Arnd Bergmann, Masahiro Yamada, Nathan Chancellor,
Nicolas Schier, linux-kbuild, Michal Marek, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Starting with c23, 'constexpr' is a keyword in C like in C++ and cannot
be used as an identifier:
scripts/unifdef.c:206:25: error: 'constexpr' can only be used in variable declarations
206 | static bool constexpr; /* constant #if expression */
| ^
scripts/unifdef.c:880:13: error: expected identifier or '('
880 | constexpr = false;
| ^
Rename this instance to allow changing to C23 at some point in the future.
Fixes: d8379ab1dde3 ("unifdef: update to upstream revision 1.190")
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
scripts/unifdef.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/unifdef.c b/scripts/unifdef.c
index db00e3e30a59..1cc31448fd10 100644
--- a/scripts/unifdef.c
+++ b/scripts/unifdef.c
@@ -203,7 +203,7 @@ static int depth; /* current #if nesting */
static int delcount; /* count of deleted lines */
static unsigned blankcount; /* count of blank lines */
static unsigned blankmax; /* maximum recent blankcount */
-static bool constexpr; /* constant #if expression */
+static bool constexpression; /* constant #if expression */
static bool zerosyms = true; /* to format symdepth output */
static bool firstsym; /* ditto */
@@ -877,7 +877,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
cp = skipcomment(cp);
if (defparen && *cp++ != ')')
return (LT_ERROR);
- constexpr = false;
+ constexpression = false;
} else if (!endsym(*cp)) {
debug("eval%d symbol", ops - eval_ops);
sym = findsym(cp);
@@ -895,7 +895,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
lt = *valp ? LT_TRUE : LT_FALSE;
cp = skipargs(cp);
}
- constexpr = false;
+ constexpression = false;
} else {
debug("eval%d bad expr", ops - eval_ops);
return (LT_ERROR);
@@ -955,10 +955,10 @@ ifeval(const char **cpp)
int val = 0;
debug("eval %s", *cpp);
- constexpr = killconsts ? false : true;
+ constexpression = killconsts ? false : true;
ret = eval_table(eval_ops, &val, cpp);
debug("eval = %d", val);
- return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
+ return (constexpression ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
}
/*
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts/unifdef: avoid constexpr keyword
2024-03-20 17:59 [PATCH] scripts/unifdef: avoid constexpr keyword Arnd Bergmann
@ 2024-03-21 15:53 ` Tony Finch
2024-03-29 9:59 ` Masahiro Yamada
1 sibling, 0 replies; 3+ messages in thread
From: Tony Finch @ 2024-03-21 15:53 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Sam Ravnborg, Arnd Bergmann, Masahiro Yamada, Nathan Chancellor,
Nicolas Schier, linux-kbuild, Michal Marek, linux-kernel
Arnd Bergmann <arnd@kernel.org> wrote:
>
> Starting with c23, 'constexpr' is a keyword in C like in C++ and cannot
> be used as an identifier:
So it is! Can you please incorporate the fixup patch below? Other than
that, LGTM.
Reviewed-By: Tony Finch <dot@dotat.at>
PS. I've been reviewing some other details of C23 recently. According to
the Editor's Report https://open-std.org/jtc1/sc22/wg14/www/docs/n3221.htm
the working draft that is closest to the official C23 Draft International
Standard is https://open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
(There were significant changes and fixes even quite late in the process
so don't rely on earlier versions - I encoutered a bug when I did!)
--- scripts/unifdef.c
+++ scripts/unifdef.c
@@ -819,7 +819,7 @@ static const struct ops {
/*
* Function for evaluating the innermost parts of expressions,
* viz. !expr (expr) number defined(symbol) symbol
- * We reset the constexpr flag in the last two cases.
+ * We reset the constexpression flag in the last two cases.
*/
static Linetype
eval_unary(const struct ops *ops, int *valp, const char **cpp)
--
Tony Finch <dot@dotat.at> https://dotat.at/
South Utsire: Variable 2 to 4 becoming south or southwest 5 to 7.
Moderate or rough. Rain or showers. Moderate or good, occasionally
poor.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts/unifdef: avoid constexpr keyword
2024-03-20 17:59 [PATCH] scripts/unifdef: avoid constexpr keyword Arnd Bergmann
2024-03-21 15:53 ` Tony Finch
@ 2024-03-29 9:59 ` Masahiro Yamada
1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2024-03-29 9:59 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Tony Finch, Sam Ravnborg, Arnd Bergmann, Nathan Chancellor,
Nicolas Schier, linux-kbuild, Michal Marek, linux-kernel
On Thu, Mar 21, 2024 at 3:01 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Starting with c23, 'constexpr' is a keyword in C like in C++ and cannot
> be used as an identifier:
>
> scripts/unifdef.c:206:25: error: 'constexpr' can only be used in variable declarations
> 206 | static bool constexpr; /* constant #if expression */
> | ^
> scripts/unifdef.c:880:13: error: expected identifier or '('
> 880 | constexpr = false;
> | ^
>
> Rename this instance to allow changing to C23 at some point in the future.
>
> Fixes: d8379ab1dde3 ("unifdef: update to upstream revision 1.190")
This can be a problem only for future kernels.
Is it worth adding Fixes?
Even if the kernel bumps to C23 at some point,
such a patch will not be backported.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-29 10:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 17:59 [PATCH] scripts/unifdef: avoid constexpr keyword Arnd Bergmann
2024-03-21 15:53 ` Tony Finch
2024-03-29 9:59 ` Masahiro Yamada
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.