* config.gcc: Remove MASK_JUMP_IN_DELAY from target_cpu_default2.
[official-gcc.git] / gcc / testsuite / g++.dg / fstack-protector-strong.C
blob5a820ed69d82b8da99ea797d8228e55da2fe1511
1 /* Test that stack protection is done on chosen functions. */
3 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
4 /* { dg-options "-O2 -fstack-protector-strong" } */
6 class A
8 public:
9   A() {}
10   ~A() {}
11   void method();
12   int state;
15 /* Frame address exposed to A::method via "this". */
16 int
17 foo1 ()
19   A a;
20   a.method ();
21   return a.state;
24 /* Possible destroying foo2's stack via &a. */
25 int
26 global_func (A& a);
28 /* Frame address exposed to global_func. */
29 int foo2 ()
31   A a;
32   return global_func (a);
35 /* Frame addressed exposed through return slot. */
37 struct B
39   /* Discourage passing this struct in registers. */
40   int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
41   int method ();
42   B return_slot();
45 B global_func ();
46 void noop ();
48 int foo3 ()
50   return global_func ().a1;
53 int foo4 ()
55   try {
56     noop ();
57     return 0;
58   } catch (...) {
59     return global_func ().a1;
60   }
63 int foo5 ()
65   try {
66     return global_func ().a1;
67   } catch (...) {
68     return 0;
69   }
72 int foo6 ()
74   B b;
75   return b.method ();
78 int foo7 (B *p)
80   return p->return_slot ().a1;
83 /* { dg-final { scan-assembler-times "stack_chk_fail" 7 } } */