OSDN Git Service

cp/:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / warn / Wunreachable-code-1.C
1 /* PR17544 Incorrect -Wunreachable-code warning
2    Origin: sebor@roguewave.com
3
4    G++ appends a "return 0;" when finishing a function, but it was not
5    given a source location.  The gimplifier thinks a return statement
6    needs a locus so it would add one, making the compiler generated code
7    visible to the unreachable code warning.  */
8
9 /* { dg-do compile } */
10 /* { dg-options "-O -Wunreachable-code" } */
11
12 int
13 main (int argc, char *argv[])
14 {
15   const char* const s = argc < 2 ? "" : argv [1];
16   int i = 0;
17   do {
18     ++i;
19   } while (i < s [0]);
20   return i;
21 }
22