Bug 28280

Summary: [4.2 regression] bogus "statement with no effect" warning with VLA and typeof
Product: gcc Reporter: Martin Michlmayr <tbm>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: debian-gcc, fche, gcc-bugs, mikestump
Priority: P2 Keywords: diagnostic
Version: 4.2.0   
Target Milestone: 4.2.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-07-06 15:13:05

Description Martin Michlmayr 2006-07-06 09:13:53 UTC
gcc 4.2 shows the following bogus warning message.  I'm not sure whether this is a regression or a new warning but it would be great if this could be improved.  The warning shows up in elfutils, the minimal testcase was extracted by Eugeniy Meshcheryakov.
41714:tbm@deprecation: ~] /usr/lib/gcc-snapshot/bin/gcc -c -W -Wall test.c
test.c: In function 'fun':
test.c:9: warning: statement with no effect
41715:tbm@deprecation: ~] gcc-4.1 -c -W -Wall test.c
41716:tbm@deprecation: ~] cat test.c
#include <inttypes.h>

void * fun(char *desc, int descsz)
{
        struct
        {
                uint32_t os;
                uint32_t version[descsz / 4 - 1];
        } *tag = (__typeof (tag)) desc;

        return tag;
}
Comment 1 Andrew Pinski 2006-07-06 14:51:17 UTC
This is not a debug issue.
Comment 2 Andrew Pinski 2006-07-06 15:12:01 UTC
We are warning inside the typeof.
Here is a shorter testcase:
void f(__SIZE_TYPE__ d)
{
  typedef int t[d];
  t *g = (__typeof(g))d;
}
Comment 3 Andrew Pinski 2006-07-06 15:13:05 UTC
Most likely caused by:
2006-05-18  Mike Stump  <mrs@apple.com>

        Fix up vla, vm and [*] sematics.
Comment 4 Mike Stump 2006-07-08 10:10:05 UTC
Fix submitted.
Comment 5 mrs@gcc.gnu.org 2006-07-12 13:12:17 UTC
Subject: Bug 28280

Author: mrs
Date: Wed Jul 12 13:12:08 2006
New Revision: 115369

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115369
Log:
	PR c/28280
	* c-parser.c (c_parser_typeof_specifier): Don't use
	c_finish_expr_stmt, open code desired semantics instead.

Added:
    trunk/gcc/testsuite/gcc.dg/vla-9.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c

Comment 6 Mike Stump 2006-07-12 13:13:53 UTC
I have checked in a fix for this.
Comment 7 Andrew Pinski 2006-07-12 17:23:16 UTC
Fixed.
Comment 8 mrs@gcc.gnu.org 2006-07-15 17:03:52 UTC
Subject: Bug 28280

Author: mrs
Date: Sat Jul 15 17:03:44 2006
New Revision: 115479

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115479
Log:
Revert:
        PR c/28280
        * c-parser.c (c_parser_typeof_specifier): Don't use
        c_finish_expr_stmt, open code desired semantics instead.

Removed:
    trunk/gcc/testsuite/gcc.dg/vla-9.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c

Comment 9 Mike Stump 2006-07-15 18:52:22 UTC
THis bug should be reopened.
Comment 10 Andrew Pinski 2006-07-15 18:58:24 UTC
Reopening because Mike cannot do it himself as he does not know the trick of using his @gcc.gnu.org. 
Comment 11 Joseph S. Myers 2006-08-15 16:16:40 UTC
The patch http://gcc.gnu.org/ml/gcc-patches/2006-07/txt00017.txt is OK.
Comment 12 mrs@gcc.gnu.org 2006-08-15 18:01:27 UTC
Subject: Bug 28280

Author: mrs
Date: Tue Aug 15 18:01:19 2006
New Revision: 116163

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116163
Log:
	PR c/28280
	* c-parser.c (c_parser_typeof_specifier): Don't use
	c_finish_expr_stmt, open code desired semantics instead.

Added:
    trunk/gcc/testsuite/gcc.dg/vla-9.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c

Comment 13 Andrew Pinski 2006-08-15 18:04:36 UTC
Fixed.