Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/g++.dg/warn/pr81275-2.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/g++.dg/warn/pr81275-2.C Thu Oct 25 07:37:49 2018 +0900 @@ -0,0 +1,165 @@ +// PR sanitizer/81875 +// { dg-do compile } +// { dg-options "-Wreturn-type" } + +struct C { C (); ~C (); }; + +int +f1 (int a, int b) +{ + C f; + switch (a) + { + case 0: + switch (b) + { + case 13: + return 7; + case 24: + return 19; + case 25: + return 0; + } + break; + default: + return 0; + case 9: + return 17; + } +} // { dg-warning "control reaches end of non-void function" } + +int +f2 (int a, int b, int c, int d) +{ + C f; + switch (a) + { + case 0: + switch (b) + { + case 13: + while (c >= 10) + { + if (c == d) + break; + c--; + } + return 7; + case 29: + switch (d) + { + case 35: + break; + default: + return 9; + } + return 8; + case 24: + do + { + if (c == d) + break; + c--; + } + while (c >= 10); + return 19; + case 25: + for (int e = 0; e < c; ++e) + if (e == d) + break; + return 0; + } + break; + default: + return 0; + case 9: + return 17; + } +} // { dg-warning "control reaches end of non-void function" } + +template <int N> +int +f3 (int a, int b) +{ + C f; + switch (a) + { + case 0: + switch (b) + { + case 13: + return 7; + case 24: + return 19; + case 25: + return 0; + } + break; + default: + return 0; + case 9: + return 17; + } +} // { dg-warning "control reaches end of non-void function" } + +template <int N> +int +f4 (int a, int b, int c, int d) +{ + C f; + switch (a) + { + case 0: + switch (b) + { + case 13: + while (c >= 10) + { + if (c == d) + break; + c--; + } + return 7; + case 29: + switch (d) + { + case 35: + break; + default: + return 9; + } + return 8; + case 24: + do + { + if (c == d) + break; + c--; + } + while (c >= 10); + return 19; + case 25: + for (int e = 0; e < c; ++e) + if (e == d) + break; + return 0; + } + break; + default: + return 0; + case 9: + return 17; + } +} // { dg-warning "control reaches end of non-void function" } + +int +f5 (int a, int b) +{ + return f3 <0> (a, b); +} + +int +f6 (int a, int b, int c, int d) +{ + return f4 <2> (a, b, c, d); +}