diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2018-07-19 12:00:59 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2018-07-19 05:00:59 -0700 |
commit | ea298fe5e6de519926d4aa121885d041c191e397 (patch) | |
tree | 35f78020eb70f6e3cb8708f1495562c55af5dbcb /gcc | |
parent | 39a6a24334f95e047dcd7e0b27c2f27f6340bdc6 (diff) | |
download | gcc-ea298fe5e6de519926d4aa121885d041c191e397.zip gcc-ea298fe5e6de519926d4aa121885d041c191e397.tar.gz gcc-ea298fe5e6de519926d4aa121885d041c191e397.tar.bz2 |
i386: Test __has_attribute (__indirect_return__)
The new indirect_return attribute is intended to mark swapcontext in
<ucontext.h>. Test __has_attribute (__indirect_return__) so that it
can be backported to GCC 8.
PR target/86560
* gcc.target/i386/pr86560-4.c: New test.
* gcc.target/i386/pr86560-5.c: Likewise.
---
gcc/testsuite/gcc.target/i386/pr86560-4.c | 21 +++++++++++++++++++++
gcc/testsuite/gcc.target/i386/pr86560-5.c | 21 +++++++++++++++++++++
2 files changed, 42 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/i386/pr86560-4.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr86560-5.c
diff --git a/gcc/testsuite/gcc.target/i386/pr86560-4.c b/gcc/testsuite/gcc.target/i386/pr86560-4.c
new file mode 100644
index 00000000000..a623e3dcbeb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr86560-4.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcf-protection" } */
+/* { dg-final { scan-assembler-times {\mendbr} 2 } } */
+
+struct ucontext;
+
+extern int (*bar) (struct ucontext *)
+#ifdef __has_attribute
+# if __has_attribute (indirect_return)
+ __attribute__((__indirect_return__))
+# endif
+#endif
+;
+
+extern int res;
+
+void
+foo (struct ucontext *oucp)
+{
+ res = bar (oucp);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr86560-5.c b/gcc/testsuite/gcc.target/i386/pr86560-5.c
new file mode 100644
index 00000000000..33b0f6424c2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr86560-5.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcf-protection" } */
+/* { dg-final { scan-assembler-times {\mendbr} 2 } } */
+
+struct ucontext;
+
+extern int (*bar) (struct ucontext *)
+#ifdef __has_attribute
+# if __has_attribute (__indirect_return__)
+ __attribute__((__indirect_return__))
+# endif
+#endif
+;
+
+extern int res;
+
+void
+foo (struct ucontext *oucp)
+{
+ res = bar (oucp);
+}
--
2.17.1
From-SVN: r262878
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr86560-4.c | 21 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr86560-5.c | 21 |
3 files changed, 48 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c60524..8ffc1f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,12 @@ 2018-07-19 H.J. Lu <hongjiu.lu@intel.com> PR target/86560 + * gcc.target/i386/pr86560-4.c: New test. + * gcc.target/i386/pr86560-5.c: Likewise. + +2018-07-19 H.J. Lu <hongjiu.lu@intel.com> + + PR target/86560 * gcc.target/i386/pr86560-1.c: New test. * gcc.target/i386/pr86560-2.c: Likewise. * gcc.target/i386/pr86560-3.c: Likewise. diff --git a/gcc/testsuite/gcc.target/i386/pr86560-4.c b/gcc/testsuite/gcc.target/i386/pr86560-4.c new file mode 100644 index 0000000..a623e3d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86560-4.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection" } */ +/* { dg-final { scan-assembler-times {\mendbr} 2 } } */ + +struct ucontext; + +extern int (*bar) (struct ucontext *) +#ifdef __has_attribute +# if __has_attribute (indirect_return) + __attribute__((__indirect_return__)) +# endif +#endif +; + +extern int res; + +void +foo (struct ucontext *oucp) +{ + res = bar (oucp); +} diff --git a/gcc/testsuite/gcc.target/i386/pr86560-5.c b/gcc/testsuite/gcc.target/i386/pr86560-5.c new file mode 100644 index 0000000..33b0f64 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86560-5.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection" } */ +/* { dg-final { scan-assembler-times {\mendbr} 2 } } */ + +struct ucontext; + +extern int (*bar) (struct ucontext *) +#ifdef __has_attribute +# if __has_attribute (__indirect_return__) + __attribute__((__indirect_return__)) +# endif +#endif +; + +extern int res; + +void +foo (struct ucontext *oucp) +{ + res = bar (oucp); +} |