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
[parent not found: <bug-17880-87@http.gcc.gnu.org/bugzilla/>]

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).