From: Nicolai Stange <nicstange@xxxxxxxxx> Introduce support for recognizing string literals as address constants. Make evaluate_string() unconditionally tag the *-preop wrapped symbol expression as being an address constant. Signed-off-by: Nicolai Stange <nicstange@xxxxxxxxx> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- evaluate.c | 1 + validation/constexpr-string.c | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 validation/constexpr-string.c diff --git a/evaluate.c b/evaluate.c index 9a7d432b8..cdbc08ef2 100644 --- a/evaluate.c +++ b/evaluate.c @@ -108,6 +108,7 @@ static struct symbol *evaluate_string(struct expression *expr) addr->symbol = sym; addr->ctype = &lazy_ptr_ctype; + addr->flags = CEF_ADDR; expr->type = EXPR_PREOP; expr->op = '*'; diff --git a/validation/constexpr-string.c b/validation/constexpr-string.c new file mode 100644 index 000000000..e641a83eb --- /dev/null +++ b/validation/constexpr-string.c @@ -0,0 +1,9 @@ +static char *a = "foobar"; // OK + +/* + * check-name: string literal constness verification. + * check-command: sparse -Wconstexpr-not-const $file + * + * check-error-start + * check-error-end + */ -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html