summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wunreachable-code-1.C
blob: 23fc86dfbb28617d7ae93c4d9b26cd658a6a92a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* PR17544 Incorrect -Wunreachable-code warning
   Origin: sebor@roguewave.com

   G++ appends a "return 0;" when finishing a function, but it was not
   given a source location.  The gimplifier thinks a return statement
   needs a locus so it would add one, making the compiler generated code
   visible to the unreachable code warning.  */

/* { dg-do compile } */
/* { dg-options "-O -Wunreachable-code" } */

int
main (int argc, char *argv[])
{
  const char* const s = argc < 2 ? "" : argv [1];
  int i = 0;
  do {
    ++i;
  } while (i < s [0]);
  return i;
}