From: Manuel López-Ibáñez Date: Fri, 29 Aug 2008 00:06:19 +0000 (+0000) Subject: re PR c/18050 (-Wsequence-point reports false positives) X-Git-Tag: releases/gcc-4.4.0~2814 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=528c22f4c7be52c1a285c7b0b9e49180ba8785f6;p=thirdparty%2Fgcc.git re PR c/18050 (-Wsequence-point reports false positives) 2008-08-28 Manuel Lopez-Ibanez Andrew Pinski PR 18050 * c-common.c (verify_tree): Fix handling of ADDR_EXPR. testsuite/ * gcc.dg/Wsequence-point-pr18050.c: New. * g++.dg/warn/Wsequence-point-pr18050.C: New. Co-Authored-By: Andrew Pinski From-SVN: r139742 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7ad57299baa6..5b0147c176fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-28 Manuel Lopez-Ibanez + Andrew Pinski + + PR 18050 + * c-common.c (verify_tree): Fix handling of ADDR_EXPR. + 2008-08-28 Paolo Carlini * gtrh-posix.h: Fix uses of _POSIX_TIMEOUTS per the normal Posix diff --git a/gcc/c-common.c b/gcc/c-common.c index e0a0829ec58e..4493a4ba45d3 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2189,6 +2189,13 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp, return; } + case ADDR_EXPR: + x = TREE_OPERAND (x, 0); + if (DECL_P (x)) + return; + writer = 0; + goto restart; + default: /* For other expressions, simply recurse on their operands. Manual tail recursion for unary expressions. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19816c0bf4a9..ccc35c83d143 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2008-08-28 Manuel Lopez-Ibanez + Andrew Pinski + + PR 18050 + * gcc.dg/Wsequence-point-pr18050.c: New. + * g++.dg/warn/Wsequence-point-pr18050.C: New. + 2008-08-28 Paolo Carlini PR c++/37260 diff --git a/gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C b/gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C new file mode 100644 index 000000000000..63aecd0f3ed0 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C @@ -0,0 +1,24 @@ +/* PR 18050 : bogus warning with -Wsequence-point */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +struct x +{ + int i; +}; +void bar(struct x*, int *); + +void foo(struct x *y) +{ + bar(y++, &y->i); /* { dg-warning "operation on 'y' may be undefined" } */ +} + +void zz(int a, int *b) +{ + *b = a; +} + +void baz(void) { + int a = 5; + zz(++a, &a); /* { dg-bogus "operation on 'a' may be undefined" } */ +} diff --git a/gcc/testsuite/gcc.dg/Wsequence-point-pr18050.c b/gcc/testsuite/gcc.dg/Wsequence-point-pr18050.c new file mode 100644 index 000000000000..63aecd0f3ed0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wsequence-point-pr18050.c @@ -0,0 +1,24 @@ +/* PR 18050 : bogus warning with -Wsequence-point */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +struct x +{ + int i; +}; +void bar(struct x*, int *); + +void foo(struct x *y) +{ + bar(y++, &y->i); /* { dg-warning "operation on 'y' may be undefined" } */ +} + +void zz(int a, int *b) +{ + *b = a; +} + +void baz(void) { + int a = 5; + zz(++a, &a); /* { dg-bogus "operation on 'a' may be undefined" } */ +}