* for (int i = expr; ....)
@ 2008-02-21 15:05 Pierre Habouzit
2008-02-22 20:26 ` Chris Li
0 siblings, 1 reply; 3+ messages in thread
From: Pierre Habouzit @ 2008-02-21 15:05 UTC (permalink / raw)
To: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
Sparse doesn't support the C99 construct `for (int i = expr; ....)` properly.
for example, the following C code:
#include <stdlib.h>
int main(void)
{
for (int i = atoi("12"); i < 10; i++);
return 0;
}
make sparse spit:
$ sparse -Wall test.c
test.c:5:22: warning: call with no type!
In fact sparse doesn't support 'expr' to be a complex enough expression
(expressions that can be folded work, but not any other afaict).
I assume something has to be done in parser.c, but I'm not really sure it's the
sole place…
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: for (int i = expr; ....)
2008-02-21 15:05 for (int i = expr; ....) Pierre Habouzit
@ 2008-02-22 20:26 ` Chris Li
2008-02-23 13:33 ` Pierre Habouzit
0 siblings, 1 reply; 3+ messages in thread
From: Chris Li @ 2008-02-22 20:26 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 755 bytes --]
On Thu, Feb 21, 2008 at 7:05 AM, Pierre Habouzit
<pierre.habouzit@m4x.org> wrote:
> Sparse doesn't support the C99 construct `for (int i = expr; ....)` properly.
> for example, the following C code:
>
> #include <stdlib.h>
>
> int main(void)
> {
> for (int i = atoi("12"); i < 10; i++);
> return 0;
> }
>
> make sparse spit:
>
> $ sparse -Wall test.c
> test.c:5:22: warning: call with no type!
>
> In fact sparse doesn't support 'expr' to be a complex enough expression
> (expressions that can be folded work, but not any other afaict).
Nah, sparse supports expression in initializer all right.
It just need to evaluate them to give it the correct ctype.
Please try the this one line patch I attached.
Chris
[-- Attachment #2: init-notype --]
[-- Type: application/octet-stream, Size: 723 bytes --]
evaluate iterator symbols
evaluate.c forgets to evaluate iterator_syms, which
might have some expression in initializer.
Signed-Off-By: Christopher Li <sparse@chrisli.org>
Index: sparse/evaluate.c
===================================================================
--- sparse.orig/evaluate.c 2008-02-13 09:25:21.000000000 -0800
+++ sparse/evaluate.c 2008-02-22 10:07:10.000000000 -0800
@@ -3093,6 +3093,7 @@ static void evaluate_if_statement(struct
static void evaluate_iterator(struct statement *stmt)
{
+ evaluate_symbol_list(stmt->iterator_syms);
evaluate_conditional(stmt->iterator_pre_condition, 1);
evaluate_conditional(stmt->iterator_post_condition,1);
evaluate_statement(stmt->iterator_pre_statement);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: for (int i = expr; ....)
2008-02-22 20:26 ` Chris Li
@ 2008-02-23 13:33 ` Pierre Habouzit
0 siblings, 0 replies; 3+ messages in thread
From: Pierre Habouzit @ 2008-02-23 13:33 UTC (permalink / raw)
To: Chris Li; +Cc: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]
On Fri, Feb 22, 2008 at 08:26:30PM +0000, Chris Li wrote:
> On Thu, Feb 21, 2008 at 7:05 AM, Pierre Habouzit
> <pierre.habouzit@m4x.org> wrote:
> > Sparse doesn't support the C99 construct `for (int i = expr; ....)` properly.
> > for example, the following C code:
> >
> > #include <stdlib.h>
> >
> > int main(void)
> > {
> > for (int i = atoi("12"); i < 10; i++);
> > return 0;
> > }
> >
> > make sparse spit:
> >
> > $ sparse -Wall test.c
> > test.c:5:22: warning: call with no type!
> >
> > In fact sparse doesn't support 'expr' to be a complex enough expression
> > (expressions that can be folded work, but not any other afaict).
>
> Nah, sparse supports expression in initializer all right.
> It just need to evaluate them to give it the correct ctype.
>
> Please try the this one line patch I attached.
Works for me, thanks.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-23 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 15:05 for (int i = expr; ....) Pierre Habouzit
2008-02-22 20:26 ` Chris Li
2008-02-23 13:33 ` Pierre Habouzit
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).