yann@1: --- /dev/null Sat Dec 14 13:56:51 2002 yann@1: +++ gcc-3.3.1/gcc/testsuite/gcc.dg/pr11736-1.c Sun Sep 14 14:26:33 2003 yann@1: @@ -0,0 +1,45 @@ yann@1: +/* PR optimization/11736 yann@1: + * Reporter: marcus@mc.pp.se yann@1: + * Summary: Stackpointer messed up on SuperH yann@1: + * Keywords: wrong-code yann@1: + * Description: yann@1: + * When a function with 5 arguments is called in both branches of a yann@1: + * conditional, and only the last argument differs, the code to push that yann@1: + * last argument on the stack gets confused. yann@1: + * Space for the fifth argument is reserved on the stack by the yann@1: + * instruction I have marked as "A". However, if the else-branch is yann@1: + * taken the stackpointer is decremented _again_ at "B". This yann@1: + * decrementation is never restored, and it is only due to the yann@1: + * restoration of r15 from r14 that the function works at all. With yann@1: + * -fomit-frame-pointer it will crash. yann@1: + * yann@1: + * Testcase tweaked by dank@kegel.com yann@1: + * Not marked as xfail since it's a regression from hardhat 2.0 gcc-2.97 yann@1: + * and dodes gcc-3.0.2 yann@1: + */ yann@1: + yann@1: +/* { dg-do run } */ yann@1: +/* { dg-options "-O1 -fomit-frame-pointer" } */ yann@1: + yann@1: +int expected_e; yann@1: + yann@1: +void bar(int a, int b, int c, int d, int e) yann@1: +{ yann@1: + if (e != expected_e) yann@1: + abort(); yann@1: +} yann@1: + yann@1: +void foo(int a) yann@1: +{ yann@1: + if (a) yann@1: + bar(0, 0, 0, 0, 1); yann@1: + else yann@1: + bar(0, 0, 0, 0, 0); /* stack pointer decremented extra time here, causing segfault */ yann@1: +} yann@1: + yann@1: +int main(int argc, char **argv) yann@1: +{ yann@1: + for (expected_e = 0; expected_e < 2; expected_e++) yann@1: + foo(expected_e); yann@1: + return 0; yann@1: +}