aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.7/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
authorAndrew Hsieh <andrewhsieh@google.com>2012-11-01 13:52:01 -0700
committerAndrew Hsieh <andrewhsieh@google.com>2012-11-01 13:52:01 -0700
commit243108374cd6483ff1dde26732806066456ec8a7 (patch)
treeef9dd9fb6c91371283e2ccb7ff92987390e9ce2c /gcc-4.7/gcc/testsuite/g++.dg
parentefb5994e8cb17f9b2347baff9d731af0338e5d5e (diff)
downloadtoolchain_gcc-243108374cd6483ff1dde26732806066456ec8a7.tar.gz
toolchain_gcc-243108374cd6483ff1dde26732806066456ec8a7.tar.bz2
toolchain_gcc-243108374cd6483ff1dde26732806066456ec8a7.zip
Add -fstack-protector-strong to GCC 4.7
See http://patchwork.ozlabs.org/patch/165025/ Change-Id: I369d8459cfe5baaf42ae9861fd7d8df8f90e48c2
Diffstat (limited to 'gcc-4.7/gcc/testsuite/g++.dg')
-rw-r--r--gcc-4.7/gcc/testsuite/g++.dg/fstack-protector-strong.C35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc-4.7/gcc/testsuite/g++.dg/fstack-protector-strong.C b/gcc-4.7/gcc/testsuite/g++.dg/fstack-protector-strong.C
new file mode 100644
index 000000000..a4f0f8163
--- /dev/null
+++ b/gcc-4.7/gcc/testsuite/g++.dg/fstack-protector-strong.C
@@ -0,0 +1,35 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fstack-protector-strong" } */
+
+class A
+{
+public:
+ A() {}
+ ~A() {}
+ void method();
+ int state;
+};
+
+/* Frame address exposed to A::method via "this". */
+int
+foo1 ()
+{
+ A a;
+ a.method ();
+ return a.state;
+}
+
+/* Possible destroying foo2's stack via &a. */
+int
+global_func (A& a);
+
+/* Frame address exposed to global_func. */
+int foo2 ()
+{
+ A a;
+ return global_func (a);
+}
+
+/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */