[testsuite] Add dg-require-stack-check
authorChristophe Lyon <christophe.lyon@linaro.org>
Thu, 6 Jul 2017 08:12:33 +0000 (08:12 +0000)
committerChristophe Lyon <clyon@gcc.gnu.org>
Thu, 6 Jul 2017 08:12:33 +0000 (10:12 +0200)
2017-07-06  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* doc/sourcebuild.texi (Test Directives, Variants of
dg-require-support): Add documentation for dg-require-stack-check.

gcc/testsuite/
* lib/target-supports-dg.exp (dg-require-stack-check): New.
* lib/target-supports.exp (check_stack_check_available): New.
* g++.dg/other/i386-9.C: Add dg-require-stack-check.
* gcc.c-torture/compile/stack-check-1.c: Likewise.
* gcc.dg/graphite/run-id-pr47653.c: Likewise.
* gcc.dg/pr47443.c: Likewise.
* gcc.dg/pr48134.c: Likewise.
* gcc.dg/pr70017.c: Likewise.
* gcc.target/aarch64/stack-checking.c: Likewise.
* gcc.target/arm/stack-checking.c: Likewise.
* gcc.target/i386/pr48723.c: Likewise.
* gcc.target/i386/pr55672.c: Likewise.
* gcc.target/i386/pr67265-2.c: Likewise.
* gcc.target/i386/pr67265.c: Likewise.
* gnat.dg/opt49.adb: Likewise.
* gnat.dg/stack_check1.adb: Likewise.
* gnat.dg/stack_check2.adb: Likewise.
* gnat.dg/stack_check3.adb: Likewise.

From-SVN: r250013

21 files changed:
gcc/ChangeLog
gcc/doc/sourcebuild.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/i386-9.C
gcc/testsuite/gcc.c-torture/compile/stack-check-1.c
gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
gcc/testsuite/gcc.dg/pr47443.c
gcc/testsuite/gcc.dg/pr48134.c
gcc/testsuite/gcc.dg/pr70017.c
gcc/testsuite/gcc.target/aarch64/stack-checking.c
gcc/testsuite/gcc.target/arm/stack-checking.c
gcc/testsuite/gcc.target/i386/pr48723.c
gcc/testsuite/gcc.target/i386/pr55672.c
gcc/testsuite/gcc.target/i386/pr67265-2.c
gcc/testsuite/gcc.target/i386/pr67265.c
gcc/testsuite/gnat.dg/opt49.adb
gcc/testsuite/gnat.dg/stack_check1.adb
gcc/testsuite/gnat.dg/stack_check2.adb
gcc/testsuite/gnat.dg/stack_check3.adb
gcc/testsuite/lib/target-supports-dg.exp
gcc/testsuite/lib/target-supports.exp

index 3c66d2f4ad0b356c3e1c9002a14b2ba4ed9aede3..2acf140f4075e189fc70716f14685711373af6ff 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-06  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * doc/sourcebuild.texi (Test Directives, Variants of
+       dg-require-support): Add documentation for dg-require-stack-check.
+
 2017-07-05  Sebastian Peryt  <sebastian.peryt@intel.com>
 
        * config/i386/subst.md (mask_scalar, round_scalar,
index 4136a68a615d0e2d96111d977fc9490b7012071c..85af8778167ba6e41f2007bda5fbae80bcf8856e 100644 (file)
@@ -2311,6 +2311,11 @@ the codeset to convert to.
 Skip the test if the target does not support profiling with option
 @var{profopt}.
 
+@item dg-require-stack-check @var{check}
+Skip the test if the target does not support the @code{-fstack-check}
+option.  If @var{check} is @code{""}, support for @code{-fstack-check}
+is checked, for @code{-fstack-check=("@var{check}")} otherwise.
+
 @item dg-require-visibility @var{vis}
 Skip the test if the target does not support the @code{visibility} attribute.
 If @var{vis} is @code{""}, support for @code{visibility("hidden")} is
index 4be9f0ca074685d0d23bdfe7981f73b1ee27ee02..d629c2bd90d8a9a1411bad6edc63dd7355412027 100644 (file)
@@ -1,3 +1,24 @@
+2017-07-06  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * lib/target-supports-dg.exp (dg-require-stack-check): New.
+       * lib/target-supports.exp (check_stack_check_available): New.
+       * g++.dg/other/i386-9.C: Add dg-require-stack-check.
+       * gcc.c-torture/compile/stack-check-1.c: Likewise.
+       * gcc.dg/graphite/run-id-pr47653.c: Likewise.
+       * gcc.dg/pr47443.c: Likewise.
+       * gcc.dg/pr48134.c: Likewise.
+       * gcc.dg/pr70017.c: Likewise.
+       * gcc.target/aarch64/stack-checking.c: Likewise.
+       * gcc.target/arm/stack-checking.c: Likewise.
+       * gcc.target/i386/pr48723.c: Likewise.
+       * gcc.target/i386/pr55672.c: Likewise.
+       * gcc.target/i386/pr67265-2.c: Likewise.
+       * gcc.target/i386/pr67265.c: Likewise.
+       * gnat.dg/opt49.adb: Likewise.
+       * gnat.dg/stack_check1.adb: Likewise.
+       * gnat.dg/stack_check2.adb: Likewise.
+       * gnat.dg/stack_check3.adb: Likewise.
+
 2017-07-05  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        PR target/80103
index 79640579142333c133f6a04b911d2fcf737d0c3c..782cf875eef4383d61fc28bddd2f67c52d9a9528 100644 (file)
@@ -2,6 +2,7 @@
 // Testcase by Zdenek Sojka <zsojka@seznam.cz>
 
 // { dg-do run { target i?86-*-* x86_64-*-* } }
+/* { dg-require-stack-check "" } */
 // { dg-options "-Os -mpreferred-stack-boundary=5 -fstack-check -fno-omit-frame-pointer" }
 
 int main()
index 5c99688b35ae812020f58083c0f7c09b97365e1f..2a03f7c29ae3ef605a16c09857626dae45fcb019 100644 (file)
@@ -1,3 +1,4 @@
 /* { dg-require-effective-target untyped_assembly } */
+/* { dg-require-stack-check "" } */
 /* { dg-additional-options "-fstack-check" } */
 #include "20031023-1.c"
index cd9d8ebcb166227df411acbd43c2413d7ed35b97..ca91af471cadd4b91cff424374eeb0ae5fdcb49e 100644 (file)
@@ -1,3 +1,4 @@
+/* { dg-require-stack-check "generic" } */
 /* { dg-options "-O -fstack-check=generic -ftree-pre -fgraphite-identity" } */
 /* nvptx doesn't expose a stack.  */
 /* { dg-skip-if "" { nvptx-*-* } } */
index 47abea27dd7558061e8a0fb4d1ab76fbe6f5c4dc..5a5c43f253736618dd185f44fbbf43ebe3abcd0d 100644 (file)
@@ -1,5 +1,6 @@
 /* PR tree-optimization/47443 */
 /* { dg-do compile } */
+/* { dg-require-stack-check "generic" } */
 /* { dg-options "-O -fstack-check=generic" } */
 
 static inline int bar (char *c, int i)
index 8dc5a6d0d412618d2a2ca0e5a4a9b43706fbc99f..446ad01b45271a071167d66f84955278b7977bec 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-stack-check "specific" } */
 /* { dg-options "-O2 -fstack-check=specific -fno-tree-dse -fno-tree-fre -fno-tree-loop-optimize -g" } */
 
 struct S
index f544167612b9c396717b89ee92cc6e934ea1576c..3489d5baf48960ef4d7a02881d638c3f9657f514 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-stack-check "generic" } */
 /* { dg-options "-fstack-check=generic" } */
 
 /* Check that the expected warning is issued for large frames.  */
index 1d1530df62b4eeae889d407fe21ef217e717dd38..eaa40581c865b00a7547245d132d961dcd43780b 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do run { target { *-*-linux* } } } */
+/* { dg-require-stack-check "" } */
 /* { dg-options "-fstack-check" } */
 
 int main(void)
index 88a7e6e8286c2cc5aa07d9e9991d9c855265c590..4b53bedd97b73f8090cbe976ca72c5c11116940e 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target { *-*-linux* } } } */
+/* { dg-require-stack-check "" } */
 /* { dg-options "-fstack-check" } */
-/* { dg-skip-if "" { arm_thumb1 } } */
 
 int main(void)
 {
index ad102090e9f9e3d830106047780d49238ea02534..222c075fbf7e0d5cfabd0ffbbe971260256e7ae4 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-stack-check "" } */
 /* { dg-options "-fstack-check -mavx" } */
 
 struct S0
index 6f1c898c748ee5eb9d6cc2643ab2d33b60854dc1..f7b0d717e011e94d77f8f6c7a4065d5c0ccf5768 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-stack-check "generic" } */
 /* { dg-options "-O -fstack-check=generic" } */
 
 int main ()
index a9f2eb460ef4fa3f144d3ea96df9af67d6631eb7..690a78455572d17bc8dec0cb35caae9f62ff1e67 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-stack-check "" } */
 /* { dg-options "-O -fstack-check" } */
 
 void foo (int n)
index 7827685fe5f140e933da4abe6d16f4fbe9f3be03..2671acc043ad88285ce9c991ce4360ec24574408 100644 (file)
@@ -2,6 +2,7 @@
 /* Reduced testcase by Johannes Dewender <gnu@JonnyJD.net> */
 
 /* { dg-do compile } */
+/* { dg-require-stack-check "" } */
 /* { dg-options "-O -fstack-check -fPIC" } */
 
 int a, b, c, d, e;
index 4b91973a19d3472e2299be35af35172eedc27255..42ab953a2e05f0237bdc00359510665012681d42 100644 (file)
@@ -1,4 +1,5 @@
 -- { dg-do run }
+-- { dg-require-stack-check "" }
 -- { dg-options "-O -fstack-check" }
 
 procedure Opt49 is
index 51ee1a633b31696ce63f8f3aee109fd62cce9dc7..eaad745bdf60a41fb26645f2739cf8989f71c399 100644 (file)
@@ -1,4 +1,5 @@
 -- { dg-do run }
+-- { dg-require-stack-check "" }
 -- { dg-options "-fstack-check" }
 
 -- This test requires architecture- and OS-specific support code for unwinding
index 4a3008ba02b2bcdf8d9a15bf37515c36267a27a5..f34d647c862cdb94c943ce201a39eae3ee5040fc 100644 (file)
@@ -1,4 +1,5 @@
 -- { dg-do run }
+-- { dg-require-stack-check "" }
 -- { dg-options "-fstack-check" }
 
 -- This test requires architecture- and OS-specific support code for unwinding
index 734ed4227337e19f19210cc910e19a284c566332..3bb859c82f804c20e1a0b8c2b4e2444267db3016 100644 (file)
@@ -1,4 +1,5 @@
 -- { dg-do compile }
+-- { dg-require-stack-check "" }
 -- { dg-options "-O -fstack-check" }
 
 package body Stack_Check3 is
index 6400d6434094373f5d54c3b45f75bfc35f8d9fda..d50d8b07ada525aaeb58100908e47aaec53bc26f 100644 (file)
@@ -265,6 +265,21 @@ proc dg-require-linker-plugin { args } {
     }
 }
 
+# If this target does not support the "stack-check" option, skip this
+# test.
+
+proc dg-require-stack-check { args } {
+    set stack_check_available [ check_stack_check_available [lindex $args 1 ] ]
+    if { $stack_check_available == -1 } {
+       upvar name name
+       unresolved "$name"
+    }
+    if { $stack_check_available != 1 } {
+       upvar dg-do-what dg-do-what
+       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    }
+}
+
 # Add any target-specific flags needed for accessing the given list
 # of features.  This must come after all dg-options.
 
index fe5e77756404d603f04d674bb5ca872956d4b7ad..d19892e88d549c7f46b8a639567b9e5f65dcdddf 100644 (file)
@@ -1063,6 +1063,17 @@ proc check_effective_target_fstack_protector {} {
     } "-fstack-protector"]
 }
 
+# Return 1 if the target supports -fstack-check or -fstack-check=$stack_kind
+proc check_stack_check_available { stack_kind } {
+    if [string match "" $stack_kind] then {
+       set stack_opt "-fstack-check"
+    } else { set stack_opt "-fstack-check=$stack_kind" }
+
+    return [check_no_compiler_messages stack_check executable {
+       int main (void) { return 0; }
+    } "$stack_opt"]
+}
+
 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
 # for trivial code, 0 otherwise.  As some targets (ARM for example) only
 # warn when -fprofile-use is also supplied we test that combination too.