|
| 1 | +From 10f94d8fcc0880c93d7697184fe199022792a61c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Arnd Bergmann < [email protected]> |
| 3 | +Date: Mon, 8 Apr 2024 09:17:52 +0200 |
| 4 | +Subject: [PATCH] scripts/unifdef: avoid constexpr keyword |
| 5 | + |
| 6 | +Starting with c23, 'constexpr' is a keyword in C like in C++ and cannot |
| 7 | +be used as an identifier: |
| 8 | + |
| 9 | +scripts/unifdef.c:206:25: error: 'constexpr' can only be used in variable declarations |
| 10 | + 206 | static bool constexpr; /* constant #if expression */ |
| 11 | + | ^ |
| 12 | +scripts/unifdef.c:880:13: error: expected identifier or '(' |
| 13 | + 880 | constexpr = false; |
| 14 | + | ^ |
| 15 | + |
| 16 | +Rename this instance to allow changing to C23 at some point in the future. |
| 17 | + |
| 18 | +Signed-off-by: Arnd Bergmann < [email protected]> |
| 19 | +Reviewed-By: Tony Finch < [email protected]> |
| 20 | +Reviewed-by: Nicolas Schier < [email protected]> |
| 21 | +Signed-off-by: Masahiro Yamada < [email protected]> |
| 22 | +--- |
| 23 | + scripts/unifdef.c | 12 ++++++------ |
| 24 | + 1 file changed, 6 insertions(+), 6 deletions(-) |
| 25 | + |
| 26 | +diff --git a/scripts/unifdef.c b/scripts/unifdef.c |
| 27 | +index db00e3e30a59d7..ff15efd6e7d749 100644 |
| 28 | +--- a/scripts/unifdef.c |
| 29 | ++++ b/scripts/unifdef.c |
| 30 | +@@ -203,7 +203,7 @@ static int depth; /* current #if nesting */ |
| 31 | + static int delcount; /* count of deleted lines */ |
| 32 | + static unsigned blankcount; /* count of blank lines */ |
| 33 | + static unsigned blankmax; /* maximum recent blankcount */ |
| 34 | +-static bool constexpr; /* constant #if expression */ |
| 35 | ++static bool constexpression; /* constant #if expression */ |
| 36 | + static bool zerosyms = true; /* to format symdepth output */ |
| 37 | + static bool firstsym; /* ditto */ |
| 38 | + |
| 39 | +@@ -819,7 +819,7 @@ static const struct ops { |
| 40 | + /* |
| 41 | + * Function for evaluating the innermost parts of expressions, |
| 42 | + * viz. !expr (expr) number defined(symbol) symbol |
| 43 | +- * We reset the constexpr flag in the last two cases. |
| 44 | ++ * We reset the constexpression flag in the last two cases. |
| 45 | + */ |
| 46 | + static Linetype |
| 47 | + eval_unary(const struct ops *ops, int *valp, const char **cpp) |
| 48 | +@@ -877,7 +877,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp) |
| 49 | + cp = skipcomment(cp); |
| 50 | + if (defparen && *cp++ != ')') |
| 51 | + return (LT_ERROR); |
| 52 | +- constexpr = false; |
| 53 | ++ constexpression = false; |
| 54 | + } else if (!endsym(*cp)) { |
| 55 | + debug("eval%d symbol", ops - eval_ops); |
| 56 | + sym = findsym(cp); |
| 57 | +@@ -895,7 +895,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp) |
| 58 | + lt = *valp ? LT_TRUE : LT_FALSE; |
| 59 | + cp = skipargs(cp); |
| 60 | + } |
| 61 | +- constexpr = false; |
| 62 | ++ constexpression = false; |
| 63 | + } else { |
| 64 | + debug("eval%d bad expr", ops - eval_ops); |
| 65 | + return (LT_ERROR); |
| 66 | +@@ -955,10 +955,10 @@ ifeval(const char **cpp) |
| 67 | + int val = 0; |
| 68 | + |
| 69 | + debug("eval %s", *cpp); |
| 70 | +- constexpr = killconsts ? false : true; |
| 71 | ++ constexpression = killconsts ? false : true; |
| 72 | + ret = eval_table(eval_ops, &val, cpp); |
| 73 | + debug("eval = %d", val); |
| 74 | +- return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret); |
| 75 | ++ return (constexpression ? LT_IF : ret == LT_ERROR ? LT_IF : ret); |
| 76 | + } |
| 77 | + |
| 78 | + /* |
0 commit comments