Linux SPARSE checker discussions
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	linux-sparse@vger.kernel.org
Subject: Re: [PATCH v1 01/28] misc: fix testcase typeof-safe
Date: Wed, 20 May 2020 16:34:53 +0100	[thread overview]
Message-ID: <2de08a4e-ce53-8694-da00-c2c90334da65@ramsayjones.plus.com> (raw)
In-Reply-To: <422723ea-00aa-ee89-72aa-f4dddbd8da06@ramsayjones.plus.com>



On 20/05/2020 01:33, Ramsay Jones wrote:
> On 19/05/2020 01:57, Luc Van Oostenryck wrote:
>> This testcase was marked as known-to-fail but it was
>> simply the expected error messages that were missing.
>>
>> So, slightly reorganize the test a little bit, add the
>> expected messages and remove the 'known-to-fail' tag.
>>
>> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
>> ---
>>  validation/typeof-safe.c | 26 ++++++++++++++++++++------
>>  1 file changed, 20 insertions(+), 6 deletions(-)
>>
>> diff --git a/validation/typeof-safe.c b/validation/typeof-safe.c
>> index 614863fba381..508bd39204c5 100644
>> --- a/validation/typeof-safe.c
>> +++ b/validation/typeof-safe.c
>> @@ -2,16 +2,24 @@
>>  
>>  static void test_safe(void)
>>  {
>> -	int __safe obj, *ptr;
>> -	typeof(obj) var = obj;
>> -	typeof(ptr) ptr2 = ptr;
>> +	int obj;
>> +	int __safe *ptr;
>> +
>> +	int __safe *ptr2 = ptr;
>> +	typeof(ptr) ptr3 = ptr;
>>  	typeof(*ptr) var2 = obj;
>> -	typeof(*ptr) *ptr3 = ptr;
>> -	typeof(obj) *ptr4 = ptr;
>> +	int __safe  var3 = obj;
>> +	int *ptr4 = &obj;
>> +	int *ptr4 = ptr;		// KO
> 
> ptr4 declared twice - and sparse didn't complain?

Heh, I had a slightly different example in the test case
for my '{0}' initializer patch (but involving different
types as well).

I had a quick look at this and tried to use 'git-bisect' to
isolate the change which broke this. However, I couldn't find
a version of sparse that worked correctly! :D (I went all the
way back to v0.4.2 before giving up - several tagged releases
didn't even compile without some fix-ups, including v0.4.2).

Just FYI, this was my test-case:

  $ cat -n test-dup-decl.c
       1	#ifdef WORKS_OK
       2	static int sobj;
       3	static int *sptr4 = &sobj;
       4	static int *sptr4 = 0;
       5	#endif
       6	
       7	static void func(void)
       8	{
       9		int obj, *ptr;
      10		int *ptr4 = &obj;
      11		int *ptr4 = ptr;
      12		int a;
      13		float a;
      14	}
  $ 

  $ gcc -c test-dup-decl.c
  test-dup-decl.c: In function ‘func’:
  test-dup-decl.c:11:7: error: redefinition of ‘ptr4’
    int *ptr4 = ptr;
         ^~~~
  test-dup-decl.c:10:7: note: previous definition of ‘ptr4’ was here
    int *ptr4 = &obj;
         ^~~~
  test-dup-decl.c:13:8: error: conflicting types for ‘a’
    float a;
          ^
  test-dup-decl.c:12:6: note: previous declaration of ‘a’ was here
    int a;
        ^
  $ 

  $ ./sparse test-dup-decl.c
  $ 

ATB,
Ramsay Jones

  reply	other threads:[~2020-05-20 15:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  0:57 [SPARSE v2 00/28] detect invalid branches Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 01/28] misc: fix testcase typeof-safe Luc Van Oostenryck
2020-05-20  0:33   ` Ramsay Jones
2020-05-20 15:34     ` Ramsay Jones [this message]
2020-05-20 16:12       ` Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 02/28] misc: s/fntype/rettype/ Luc Van Oostenryck
2020-05-20  0:35   ` Ramsay Jones
2020-05-20 16:39     ` Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 03/28] misc: always use the node for current_fn Luc Van Oostenryck
2020-05-20  0:37   ` Ramsay Jones
2020-05-19  0:57 ` [PATCH v1 04/28] bad-goto: add testcase for 'jump inside discarded expression statement' Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 05/28] bad-goto: add testcases for linearization of invalid labels Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 06/28] bad-goto: reorganize testcases and add some more Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 07/28] bad-goto: do not linearize if the IR will be invalid Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 08/28] bad-goto: reorg test in evaluate_goto_statement() Luc Van Oostenryck
2020-05-19  0:57   ` Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 09/28] bad-goto: simplify testing of undeclared labels Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 10/28] bad-goto: do not linearize function with " Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 11/28] bad-goto: catch labels with reserved names Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 12/28] scope: no memset() needed after __alloc_scope() Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 13/28] scope: move scope opening/ending inside compound_statement() Luc Van Oostenryck
2020-05-19  0:57   ` Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 14/28] scope: extract bind_symbol_with_scope() from bind_symbol() Luc Van Oostenryck
2020-05-20  0:44   ` Ramsay Jones
2020-05-19  0:57 ` [PATCH v1 15/28] scope: __func__ is special Luc Van Oostenryck
2020-05-20  0:45   ` Ramsay Jones
2020-05-19  0:57 ` [PATCH v1 16/28] scope: __label__ " Luc Van Oostenryck
2020-05-20  0:47   ` Ramsay Jones
2020-05-19  0:57 ` [PATCH v1 17/28] scope: s/{start,end}_symbol_scope/{start,end}_block_scope/ Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 18/28] scope: make function_scope invalid outside functions Luc Van Oostenryck
2020-05-19  1:38   ` Linus Torvalds
2020-05-19 20:57     ` Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 19/28] scope: let labels have their own scope Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 20/28] scope: add is_in_scope() Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 21/28] scope: give a scope for labels & gotos Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 22/28] bad-goto: jumping inside a statemet expression is an error Luc Van Oostenryck
2020-05-20  0:53   ` Ramsay Jones
2020-05-20 16:37     ` Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 23/28] bad-goto: label expression inside a statement expression is UB Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 24/28] bad-goto: extract check_label_declaration() Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 25/28] bad-goto: check declaration of label expressions Luc Van Oostenryck
2020-05-20  0:56   ` Ramsay Jones
2020-05-19  0:57 ` [PATCH v1 26/28] bad-label: check for unused labels Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 27/28] bad-label: mark labels as used when needed Luc Van Oostenryck
2020-05-19  0:57 ` [PATCH v1 28/28] bad-label: respect attribute((unused)) Luc Van Oostenryck
2020-05-19  1:41 ` [SPARSE v2 00/28] detect invalid branches Linus Torvalds
2020-05-19 21:16   ` Luc Van Oostenryck

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=2de08a4e-ce53-8694-da00-c2c90334da65@ramsayjones.plus.com \
    --to=ramsay@ramsayjones.plus.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    /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