linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Stefaniuc <mstefani@redhat.com>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: Josh Triplett <josh@freedesktop.org>, linux-sparse@vger.kernel.org
Subject: Re: [patchset] rewrite of initializer handling
Date: Mon, 18 Jun 2007 23:46:13 +0200	[thread overview]
Message-ID: <4676FD25.9030504@redhat.com> (raw)
In-Reply-To: <20070618191653.GG21478@ftp.linux.org.uk>

Al Viro wrote:
> On Mon, Jun 18, 2007 at 11:19:08AM -0700, Josh Triplett wrote:
>> Hopefully this would also fix the problem reported by Michael Stefaniuc in
>> <466489FD.7010405@redhat.com>:
>>> Running sparse on
>>>         int i = sizeof((const char []) {'a','a','a',0});
>>> gives
>>>         zzz.c:1:9: error: cannot size expression
> 
> Umm...  I don't think that it's related.  count_array_initializer() would
> work just fine for that one, since the straightforward list element counting
> would work as-is.
Right, it doesn't fixes this error. Actually the output of
make clean; CHECK='sparse -Wno-transparent-union -Wno-old-initializer
-Wno-non-pointer-null' make CC=cgcc > build.out 2>&1
is identical bit by bit with or without Al's patch series.

> Aha... I see what's going on - in evaluate_cast() we examine the type before
> associating it with initializer, so when we get around to evaluate_symbol()
> a bit later in the same function, it's too late - ->examined is already
> set.  I wonder if moving that examine_symbol_type() downstream (and killing
> it in EXPR_INITIALIZER branch) would be enough...  Looks like it should
> work, but I might be missing something here.
> 
> How does something like diff below look to you, folks?  It gets the
> testcase to produce expected result (and puts the right value into
> i); I'm running it on the kernel cross-builds right now, but that
> doesn't guarantee correctness, of course.
Works for Wine and removes most of the "error: cannot size expression"
errors. The 7 remaining errors are preceded by "error: bad constant
expression" in the same line. Have to condense those into a test case too.

> diff --git a/evaluate.c b/evaluate.c
> index c564ad9..6da8f3e 100644
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -2416,7 +2416,7 @@ out:
>  static struct symbol *evaluate_cast(struct expression *expr)
>  {
>  	struct expression *target = expr->cast_expression;
> -	struct symbol *ctype = examine_symbol_type(expr->cast_type);
> +	struct symbol *ctype;
>  	struct symbol *t1, *t2;
>  	int class1, class2;
>  	int as1, as2;
> @@ -2424,9 +2424,6 @@ static struct symbol *evaluate_cast(struct expression *expr)
>  	if (!target)
>  		return NULL;
>  
> -	expr->ctype = ctype;
> -	expr->cast_type = ctype;
> -
>  	/*
>  	 * Special case: a cast can be followed by an
>  	 * initializer, in which case we need to pass
> @@ -2441,7 +2438,7 @@ static struct symbol *evaluate_cast(struct expression *expr)
>  		struct symbol *sym = expr->cast_type;
>  		struct expression *addr = alloc_expression(expr->pos, EXPR_SYMBOL);
>  
> -		sym->initializer = expr->cast_expression;
> +		sym->initializer = target;
>  		evaluate_symbol(sym);
>  
>  		addr->ctype = &lazy_ptr_ctype;	/* Lazy eval */
> @@ -2455,6 +2452,10 @@ static struct symbol *evaluate_cast(struct expression *expr)
>  		return sym;
>  	}
>  
> +	ctype = examine_symbol_type(expr->cast_type);
> +	expr->ctype = ctype;
> +	expr->cast_type = ctype;
> +
>  	evaluate_expression(target);
>  	degenerate(target);
>  


bye
	michael

-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
Sr. Network Engineer            Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani@redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart

  parent reply	other threads:[~2007-06-18 21:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-18 10:19 [patchset] rewrite of initializer handling Al Viro
2007-06-18 10:26 ` Al Viro
2007-06-18 17:07 ` Linus Torvalds
2007-06-18 18:02   ` Josh Triplett
2007-06-18 19:30     ` Al Viro
2007-06-18 18:19 ` Josh Triplett
2007-06-18 19:16   ` Al Viro
2007-06-18 19:27     ` Linus Torvalds
2007-06-18 21:46     ` Michael Stefaniuc [this message]
2007-06-18 22:43       ` Al Viro
2007-06-19  9:47         ` Michael Stefaniuc
2007-06-19 20:15     ` Michael Stefaniuc
2007-06-19 22:41       ` Al Viro
2007-06-20  8:54         ` Michael Stefaniuc
2007-06-20 21:29           ` Michael Stefaniuc
  -- strict thread matches above, loose matches on Subject: below --
2007-06-19 17:12 Alexey Dobriyan
2007-06-19 17:21 ` Al Viro
2007-06-19 22:33   ` Al Viro

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=4676FD25.9030504@redhat.com \
    --to=mstefani@redhat.com \
    --cc=josh@freedesktop.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /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).