linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 5/5] unqual: pre- & post-increment/decrement should *not* drop qualifiers
Date: Wed, 18 Nov 2020 22:11:47 +0100	[thread overview]
Message-ID: <20201118211147.10680-6-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20201118211147.10680-1-luc.vanoostenryck@gmail.com>

Increment and decrement expressions are not subjected to lvalue-conversion
and thus should *not* drop qualifiers.

However, while the lvalue-conversion is not done, the qualifiers
are dropped because the type used for the result is the one returned
by classify_type() which always return the base type.

Fix this by using the type of the operand as the result type.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 evaluate.c                      | 3 +--
 validation/eval/unqual-postop.c | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 48ce61f0302d..8599fcee6875 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1935,8 +1935,7 @@ static struct symbol *evaluate_postop(struct expression *expr)
 	if (multiply) {
 		evaluate_assign_to(op, op->ctype);
 		expr->op_value = multiply;
-		expr->ctype = ctype;
-		return ctype;
+		return expr->ctype = op->ctype;
 	}
 
 	expression_error(expr, "bad argument type for ++/--");
diff --git a/validation/eval/unqual-postop.c b/validation/eval/unqual-postop.c
index fb3082dc8836..48b6be8b8508 100644
--- a/validation/eval/unqual-postop.c
+++ b/validation/eval/unqual-postop.c
@@ -10,7 +10,6 @@ static void test_volatile(void)
 /*
  * check-name: unqual-postop
  * check-command: sparse -Wno-declaration-after-statement $file
- * check-known-to-fail
  *
  * check-error-start
 eval/unqual-postop.c:6:40: warning: incorrect type in assignment (different modifiers)
-- 
2.29.2


      parent reply	other threads:[~2020-11-18 21:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 21:11 [PATCH 0/5] fix qualifier dropping Luc Van Oostenryck
2020-11-18 21:11 ` [PATCH 1/5] unqual: add testcases Luc Van Oostenryck
2020-11-18 21:11 ` [PATCH 2/5] unqual: unqualify_type() should check for null ctypes Luc Van Oostenryck
2020-11-18 21:11 ` [PATCH 3/5] unqual: comma expressions should drop qualifiers Luc Van Oostenryck
2020-11-18 21:11 ` [PATCH 4/5] unqual: statement " Luc Van Oostenryck
2020-11-18 21:11 ` Luc Van Oostenryck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201118211147.10680-6-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).