public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
@ 2004-10-07  9:52 jakub at gcc dot gnu dot org
  2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2004-10-07  9:52 UTC (permalink / raw)
  To: gcc-bugs

/* { dg-do compile } */
/* { dg-options "-Wsequence-point" } */

int
foo (int x)
{
  unsigned int a = x;
  int b;
  b = (a += 5) > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = (a += 5) + a == 10;  /* { dg-warning "undefined" "sequence point warning" }
*/
  b = (a -= 5) > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = (a -= 5) + a == 10;  /* { dg-warning "undefined" "sequence point warning" }
*/
  b = a-- > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = a-- + a == 10;  /* { dg-warning "undefined" "sequence point warning" } */
  b = ++a > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = ++a + a == 10;  /* { dg-warning "undefined" "sequence point warning" } */
  if ((a += 5) > a) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if ((a += 5) + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if ((a -= 5) > a) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if ((a -= 5) + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if (a-- > a) return -1;  /* { dg-warning "undefined" "sequence point warning" }
*/
  if (a-- + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if (++a > a) return -1;  /* { dg-warning "undefined" "sequence point warning" }
*/
  if (++a + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  do {} while ((a += 5) > a);  /* { dg-warning "undefined" "sequence point
warning" } */
  while ((a += 5) > a);  /* { dg-warning "undefined" "sequence point warning" }
*/
  for (b = (a += 5) > a;;);  /* { dg-warning "undefined" "sequence point warning"
} */
  for (; (a += 5) > a;);  /* { dg-warning "undefined" "sequence point warning" }
*/
  for (;; b = (a += 5) > a);  /* { dg-warning "undefined" "sequence point
warning" } */
  return 0;
}

While it is certainly possible to call verify_sequence_points for each condition
etc. from c-parse.in and parse.y, I think much better would be to move this
warning to say c_genericize, walk over all statements and call
verify_sequence_points where needed.

-- 
           Summary: -Wsequence-point doesn't warn inside if, while, do
                    conditions, for beg/cond/end expressions etc.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,jsm at polyomino dot org
                    dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17880


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
  2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
@ 2004-10-07 10:09 ` giovannibajo at libero dot it
  2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
  2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 5+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-07 10:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-07 10:09 -------
Notice, this is also related to PR 16202, which shows other cases where 
Wsequence-point is not working.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17880


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
  2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
  2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
@ 2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
  2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-07 12:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-07 12:19 -------
Cofirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-07 12:19:33
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17880


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
  2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
  2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
  2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
@ 2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-12 17:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-12 17:04 -------
Note for the C++ front-end at this point we don't warn for the last for statement but we do for C, I 
have a fix for the problem (I fixed while fixing another problem).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17880


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
       [not found] <bug-17880-87@http.gcc.gnu.org/bugzilla/>
@ 2008-08-09 12:40 ` manu at gcc dot gnu dot org
  0 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-09 12:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2008-08-09 12:38 -------
Subject: Bug 17880

Author: manu
Date: Sat Aug  9 12:37:32 2008
New Revision: 138904

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138904
Log:
2008-08-09  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c/17880
        * c-typeck.c (digest_init): Call verify_sequence_points from here.
        (c_finish_return): Likewise.
        (c_start_case): Likewise.
        * c-common.c (warn_for_collisions_1): Use explicit location in
        warning.
        * c-parser.c (c_parser_condition): New. Call
        verify_sequence_points.
        (c_parser_paren_condition): Call c_parser_condition.
        (c_parser_for_statement): Call c_parser_condition.
testsuite/
        * gcc.dg/sequence-pt-pr17880.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/sequence-pt-pr17880.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-parser.c
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17880


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-09 12:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
     [not found] <bug-17880-87@http.gcc.gnu.org/bugzilla/>
2008-08-09 12:40 ` manu at gcc dot gnu dot org

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 read-only IMAP folder(s) and NNTP newsgroup(s).