Hi!

On 2018-09-05T12:52:10+0100, <a...@codesourcery.com> wrote:
> There are a number of tests that fail because they assume that exceptions are
> available, but [BPF, GCN, nvptx] does not support them, yet.

To make this explicit for GCN, nvptx (José: can BPF do the same?), I've
pushed to trunk branch commit 6312165650091a4df34668d8e2aaa0bbc4008a66
"GCN, nvptx: 'sorry, unimplemented: exception handling not supported'",
see attached.

For GCN, this avoids ICEs further down the compilation pipeline.  For
nvptx, there's effectively no change: in presence of exception handling
constructs, instead of
'sorry, unimplemented: target cannot support nonlocal goto', we now emit
'sorry, unimplemented: exception handling not supported'.

> This patch adds "dg-require-effective-target exceptions" in all the affected
> tests.  There's probably an automatic way to test for exceptions, but the
> current implementation simply says that AMD GCN does not support them.  This
> should ensure that no other targets are affected by the change.

Via my commit's 'gcc/testsuite/lib/gcc-dg.exp:gcc-dg-prune' and
corresponding libstdc++-v3 changes, we now also turn test cases into
UNSUPPORTED if running into
'sorry, unimplemented: exception handling not supported'.

José: if BPF also emitted this same diagnostic (I'm not set up for BPF
target testing; probably just need to add the very same 'sorry'
'define_expand "exception_receiver"'?), we could go one step further, and
again remove all the manual 'dg-require-effective-target exceptions'
markup, and instead let 'gcc-dg-prune' handle that, automatically.

Actually, for some test cases, 'dg-require-effective-target exceptions'
should (nowadays) be removed either way, because they don't actually run
into UNSUPPORTED exception handling constructs, but actually PASS.
(I assume that GCC got smarter about optimizing away exception handling
constructs.)


Grüße
 Thomas


> 2018-09-05  Andrew Stubbs  <a...@codesourcery.com>
>           Kwok Cheung Yeung  <k...@codesourcery.com>
>           Julian Brown  <jul...@codesourcery.com>
>           Tom de Vries  <t...@codesourcery.com>
>
>       gcc/testsuite/
>       * c-c++-common/ubsan/pr71512-1.c: Require exceptions.
>       * c-c++-common/ubsan/pr71512-2.c: Require exceptions.
>       * gcc.c-torture/compile/pr34648.c: Require exceptions.
>       * gcc.c-torture/compile/pr41469.c: Require exceptions.
>       * gcc.dg/20111216-1.c: Require exceptions.
>       * gcc.dg/cleanup-10.c: Require exceptions.
>       * gcc.dg/cleanup-11.c: Require exceptions.
>       * gcc.dg/cleanup-12.c: Require exceptions.
>       * gcc.dg/cleanup-13.c: Require exceptions.
>       * gcc.dg/cleanup-5.c: Require exceptions.
>       * gcc.dg/cleanup-8.c: Require exceptions.
>       * gcc.dg/cleanup-9.c: Require exceptions.
>       * gcc.dg/gomp/pr29955.c: Require exceptions.
>       * gcc.dg/lto/pr52097_0.c: Require exceptions.
>       * gcc.dg/nested-func-5.c: Require exceptions.
>       * gcc.dg/pch/except-1.c: Require exceptions.
>       * gcc.dg/pch/valid-2.c: Require exceptions.
>       * gcc.dg/pr41470.c: Require exceptions.
>       * gcc.dg/pr42427.c: Require exceptions.
>       * gcc.dg/pr44545.c: Require exceptions.
>       * gcc.dg/pr47086.c: Require exceptions.
>       * gcc.dg/pr51481.c: Require exceptions.
>       * gcc.dg/pr51644.c: Require exceptions.
>       * gcc.dg/pr52046.c: Require exceptions.
>       * gcc.dg/pr54669.c: Require exceptions.
>       * gcc.dg/pr56424.c: Require exceptions.
>       * gcc.dg/pr64465.c: Require exceptions.
>       * gcc.dg/pr65802.c: Require exceptions.
>       * gcc.dg/pr67563.c: Require exceptions.
>       * gcc.dg/tree-ssa/pr41469-1.c: Require exceptions.
>       * gcc.dg/tree-ssa/ssa-dse-28.c: Require exceptions.
>       * gcc.dg/vect/pr46663.c: Require exceptions.
>       * lib/target-supports.exp (check_effective_target_exceptions): New.
> ---
>  gcc/testsuite/c-c++-common/ubsan/pr71512-1.c  |  1 +
>  gcc/testsuite/c-c++-common/ubsan/pr71512-2.c  |  1 +
>  gcc/testsuite/gcc.c-torture/compile/pr34648.c |  1 +
>  gcc/testsuite/gcc.c-torture/compile/pr41469.c |  1 +
>  gcc/testsuite/gcc.dg/20111216-1.c             |  1 +
>  gcc/testsuite/gcc.dg/cleanup-10.c             |  1 +
>  gcc/testsuite/gcc.dg/cleanup-11.c             |  1 +
>  gcc/testsuite/gcc.dg/cleanup-12.c             |  1 +
>  gcc/testsuite/gcc.dg/cleanup-13.c             |  1 +
>  gcc/testsuite/gcc.dg/cleanup-5.c              |  1 +
>  gcc/testsuite/gcc.dg/cleanup-8.c              |  1 +
>  gcc/testsuite/gcc.dg/cleanup-9.c              |  1 +
>  gcc/testsuite/gcc.dg/gomp/pr29955.c           |  1 +
>  gcc/testsuite/gcc.dg/lto/pr52097_0.c          |  1 +
>  gcc/testsuite/gcc.dg/nested-func-5.c          |  1 +
>  gcc/testsuite/gcc.dg/pch/except-1.c           |  1 +
>  gcc/testsuite/gcc.dg/pch/valid-2.c            |  2 +-
>  gcc/testsuite/gcc.dg/pr41470.c                |  1 +
>  gcc/testsuite/gcc.dg/pr42427.c                |  1 +
>  gcc/testsuite/gcc.dg/pr44545.c                |  1 +
>  gcc/testsuite/gcc.dg/pr47086.c                |  1 +
>  gcc/testsuite/gcc.dg/pr51481.c                |  1 +
>  gcc/testsuite/gcc.dg/pr51644.c                |  1 +
>  gcc/testsuite/gcc.dg/pr52046.c                |  1 +
>  gcc/testsuite/gcc.dg/pr54669.c                |  1 +
>  gcc/testsuite/gcc.dg/pr56424.c                |  1 +
>  gcc/testsuite/gcc.dg/pr64465.c                |  1 +
>  gcc/testsuite/gcc.dg/pr65802.c                |  1 +
>  gcc/testsuite/gcc.dg/pr67563.c                |  1 +
>  gcc/testsuite/gcc.dg/tree-ssa/pr41469-1.c     |  1 +
>  gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c    |  1 +
>  gcc/testsuite/gcc.dg/vect/pr46663.c           |  1 +
>  gcc/testsuite/lib/target-supports.exp         | 10 ++++++++++
>  33 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c 
> b/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c
> index 2a90ab1..8af9365 100644
> --- a/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c
> +++ b/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c
> @@ -1,5 +1,6 @@
>  /* PR c/71512 */
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fnon-call-exceptions -ftrapv -fexceptions 
> -fsanitize=undefined" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  #include "../../gcc.dg/pr44545.c"
> diff --git a/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c 
> b/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c
> index 1c95593..0c16934 100644
> --- a/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c
> +++ b/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c
> @@ -1,5 +1,6 @@
>  /* PR c/71512 */
>  /* { dg-do compile } */
>  /* { dg-options "-O -fexceptions -fnon-call-exceptions -ftrapv 
> -fsanitize=undefined" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  #include "../../gcc.dg/pr47086.c"
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34648.c 
> b/gcc/testsuite/gcc.c-torture/compile/pr34648.c
> index 8bcdae0..90a88b9 100644
> --- a/gcc/testsuite/gcc.c-torture/compile/pr34648.c
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr34648.c
> @@ -1,6 +1,7 @@
>  /* PR tree-optimization/34648 */
>  
>  /* { dg-options "-fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern const unsigned short int **bar (void) __attribute__ ((const));
>  const char *a;
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr41469.c 
> b/gcc/testsuite/gcc.c-torture/compile/pr41469.c
> index 5917794..923bca2 100644
> --- a/gcc/testsuite/gcc.c-torture/compile/pr41469.c
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr41469.c
> @@ -1,5 +1,6 @@
>  /* { dg-options "-fexceptions" } */
>  /* { dg-skip-if "requires alloca" { ! alloca } { "-O0" } { "" } } */
> +/* { dg-require-effective-target exceptions } */
>  
>  void
>  af (void *a)
> diff --git a/gcc/testsuite/gcc.dg/20111216-1.c 
> b/gcc/testsuite/gcc.dg/20111216-1.c
> index cd82cf9..7f9395e 100644
> --- a/gcc/testsuite/gcc.dg/20111216-1.c
> +++ b/gcc/testsuite/gcc.dg/20111216-1.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O -fexceptions -fnon-call-exceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern void f2 () __attribute__ ((noreturn));
>  void
> diff --git a/gcc/testsuite/gcc.dg/cleanup-10.c 
> b/gcc/testsuite/gcc.dg/cleanup-10.c
> index 16035b1..1af63ea 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-10.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-10.c
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* 
> *-*-darwin[912]* } } */
>  /* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify that cleanups work with exception handling through signal frames
>     on alternate stack.  */
>  
> diff --git a/gcc/testsuite/gcc.dg/cleanup-11.c 
> b/gcc/testsuite/gcc.dg/cleanup-11.c
> index ccc61ed..c1f19fe 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-11.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-11.c
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* 
> *-*-darwin[912]* } } */
>  /* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify that cleanups work with exception handling through realtime signal
>     frames on alternate stack.  */
>  
> diff --git a/gcc/testsuite/gcc.dg/cleanup-12.c 
> b/gcc/testsuite/gcc.dg/cleanup-12.c
> index efb9a58..2171e35 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-12.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-12.c
> @@ -4,6 +4,7 @@
>  /* { dg-options "-O2 -fexceptions" } */
>  /* { dg-skip-if "" { "ia64-*-hpux11.*" } } */
>  /* { dg-skip-if "" { ! nonlocal_goto } } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify unwind info in presence of alloca.  */
>  
>  #include <unwind.h>
> diff --git a/gcc/testsuite/gcc.dg/cleanup-13.c 
> b/gcc/testsuite/gcc.dg/cleanup-13.c
> index 8a8db27..1b7ea5c 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-13.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-13.c
> @@ -3,6 +3,7 @@
>  /* { dg-options "-fexceptions" } */
>  /* { dg-skip-if "" { "ia64-*-hpux11.*" } } */
>  /* { dg-skip-if "" { ! nonlocal_goto } } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify DW_OP_* handling in the unwinder.  */
>  
>  #include <unwind.h>
> diff --git a/gcc/testsuite/gcc.dg/cleanup-5.c 
> b/gcc/testsuite/gcc.dg/cleanup-5.c
> index 4257f9e..9ed2a7c 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-5.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-5.c
> @@ -3,6 +3,7 @@
>  /* { dg-options "-fexceptions" } */
>  /* { dg-skip-if "" { "ia64-*-hpux11.*" } } */
>  /* { dg-skip-if "" { ! nonlocal_goto } } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify that cleanups work with exception handling.  */
>  
>  #include <unwind.h>
> diff --git a/gcc/testsuite/gcc.dg/cleanup-8.c 
> b/gcc/testsuite/gcc.dg/cleanup-8.c
> index 553c038..45abdb2 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-8.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-8.c
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* 
> *-*-darwin[912]* } } */
>  /* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify that cleanups work with exception handling through signal
>     frames.  */
>  
> diff --git a/gcc/testsuite/gcc.dg/cleanup-9.c 
> b/gcc/testsuite/gcc.dg/cleanup-9.c
> index fe28072..98dc268 100644
> --- a/gcc/testsuite/gcc.dg/cleanup-9.c
> +++ b/gcc/testsuite/gcc.dg/cleanup-9.c
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* 
> *-*-darwin[912]* } } */
>  /* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */
> +/* { dg-require-effective-target exceptions } */
>  /* Verify that cleanups work with exception handling through realtime
>     signal frames.  */
>  
> diff --git a/gcc/testsuite/gcc.dg/gomp/pr29955.c 
> b/gcc/testsuite/gcc.dg/gomp/pr29955.c
> index e49c11c..102898c 100644
> --- a/gcc/testsuite/gcc.dg/gomp/pr29955.c
> +++ b/gcc/testsuite/gcc.dg/gomp/pr29955.c
> @@ -1,6 +1,7 @@
>  /* PR c/29955 */
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fopenmp -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern void bar (int);
>  
> diff --git a/gcc/testsuite/gcc.dg/lto/pr52097_0.c 
> b/gcc/testsuite/gcc.dg/lto/pr52097_0.c
> index cd4af5d..1b3fda3 100644
> --- a/gcc/testsuite/gcc.dg/lto/pr52097_0.c
> +++ b/gcc/testsuite/gcc.dg/lto/pr52097_0.c
> @@ -1,5 +1,6 @@
>  /* { dg-lto-do link } */
>  /* { dg-lto-options { { -O -flto -fexceptions -fnon-call-exceptions --param 
> allow-store-data-races=0 } } } */
> +/* { dg-require-effective-target exceptions } */
>  
>  typedef struct { unsigned int e0 : 16; } s1;
>  typedef struct { unsigned int e0 : 16; } s2;
> diff --git a/gcc/testsuite/gcc.dg/nested-func-5.c 
> b/gcc/testsuite/gcc.dg/nested-func-5.c
> index 3545f37..591f8a2 100644
> --- a/gcc/testsuite/gcc.dg/nested-func-5.c
> +++ b/gcc/testsuite/gcc.dg/nested-func-5.c
> @@ -2,6 +2,7 @@
>  /* { dg-options "-fexceptions" } */
>  /* PR28516: ICE generating ARM unwind directives for nested functions.  */
>  /* { dg-require-effective-target trampolines } */
> +/* { dg-require-effective-target exceptions } */
>  
>  void ex(int (*)(void));
>  void foo(int i)
> diff --git a/gcc/testsuite/gcc.dg/pch/except-1.c 
> b/gcc/testsuite/gcc.dg/pch/except-1.c
> index f81b098..30350ed 100644
> --- a/gcc/testsuite/gcc.dg/pch/except-1.c
> +++ b/gcc/testsuite/gcc.dg/pch/except-1.c
> @@ -1,4 +1,5 @@
>  /* { dg-options "-fexceptions -I." } */
> +/* { dg-require-effective-target exceptions } */
>  #include "except-1.h"
>  
>  int main(void) 
> diff --git a/gcc/testsuite/gcc.dg/pch/valid-2.c 
> b/gcc/testsuite/gcc.dg/pch/valid-2.c
> index 3d8cb14..15a57c9 100644
> --- a/gcc/testsuite/gcc.dg/pch/valid-2.c
> +++ b/gcc/testsuite/gcc.dg/pch/valid-2.c
> @@ -1,5 +1,5 @@
>  /* { dg-options "-I. -Winvalid-pch -fexceptions" } */
> -
> +/* { dg-require-effective-target exceptions } */
>  #include "valid-2.h" /* { dg-warning "settings for -fexceptions do not 
> match" } */
>  /* { dg-error "No such file" "no such file" { target *-*-* } 0 } */
>  /* { dg-error "they were invalid" "invalid files" { target *-*-* } 0 } */
> diff --git a/gcc/testsuite/gcc.dg/pr41470.c b/gcc/testsuite/gcc.dg/pr41470.c
> index 7ef0086..7374fac 100644
> --- a/gcc/testsuite/gcc.dg/pr41470.c
> +++ b/gcc/testsuite/gcc.dg/pr41470.c
> @@ -1,6 +1,7 @@
>  /* { dg-do compile } */
>  /* { dg-options "-fexceptions" } */
>  /* { dg-require-effective-target alloca } */
> +/* { dg-require-effective-target exceptions } */
>  
>  void cf (void *);
>  
> diff --git a/gcc/testsuite/gcc.dg/pr42427.c b/gcc/testsuite/gcc.dg/pr42427.c
> index cb43dd2..cb290fe 100644
> --- a/gcc/testsuite/gcc.dg/pr42427.c
> +++ b/gcc/testsuite/gcc.dg/pr42427.c
> @@ -2,6 +2,7 @@
>  /* { dg-options "-O2 -fexceptions -fnon-call-exceptions -fpeel-loops" } */
>  /* { dg-add-options c99_runtime } */
>  /* { dg-require-effective-target ilp32 } */
> +/* { dg-require-effective-target exceptions } */
>  
>  #include <complex.h>
>  
> diff --git a/gcc/testsuite/gcc.dg/pr44545.c b/gcc/testsuite/gcc.dg/pr44545.c
> index 8058261..37f75f1 100644
> --- a/gcc/testsuite/gcc.dg/pr44545.c
> +++ b/gcc/testsuite/gcc.dg/pr44545.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fnon-call-exceptions -ftrapv -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  void
>  DrawChunk(int *tabSize, int x) 
>  {
> diff --git a/gcc/testsuite/gcc.dg/pr47086.c b/gcc/testsuite/gcc.dg/pr47086.c
> index 71743fe..473e802 100644
> --- a/gcc/testsuite/gcc.dg/pr47086.c
> +++ b/gcc/testsuite/gcc.dg/pr47086.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O -fexceptions -fnon-call-exceptions -ftrapv" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  void
>  foo ()
> diff --git a/gcc/testsuite/gcc.dg/pr51481.c b/gcc/testsuite/gcc.dg/pr51481.c
> index d883d47..a35f8f3 100644
> --- a/gcc/testsuite/gcc.dg/pr51481.c
> +++ b/gcc/testsuite/gcc.dg/pr51481.c
> @@ -1,6 +1,7 @@
>  /* PR tree-optimization/51481 */
>  /* { dg-do compile } */
>  /* { dg-options "-O -fexceptions -fipa-cp -fipa-cp-clone" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern const unsigned short int **foo (void)
>    __attribute__ ((__nothrow__, __const__));
> diff --git a/gcc/testsuite/gcc.dg/pr51644.c b/gcc/testsuite/gcc.dg/pr51644.c
> index 2038a0c..e23c02f 100644
> --- a/gcc/testsuite/gcc.dg/pr51644.c
> +++ b/gcc/testsuite/gcc.dg/pr51644.c
> @@ -1,6 +1,7 @@
>  /* PR middle-end/51644 */
>  /* { dg-do compile } */
>  /* { dg-options "-Wall -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  #include <stdarg.h>
>  
> diff --git a/gcc/testsuite/gcc.dg/pr52046.c b/gcc/testsuite/gcc.dg/pr52046.c
> index e72061f..f0873e2 100644
> --- a/gcc/testsuite/gcc.dg/pr52046.c
> +++ b/gcc/testsuite/gcc.dg/pr52046.c
> @@ -1,6 +1,7 @@
>  /* PR tree-optimization/52046 */
>  /* { dg-do compile } */
>  /* { dg-options "-O3 -fexceptions -fnon-call-exceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern float a[], b[], c[], d[];
>  extern int k[];
> diff --git a/gcc/testsuite/gcc.dg/pr54669.c b/gcc/testsuite/gcc.dg/pr54669.c
> index b68c047..48967ed 100644
> --- a/gcc/testsuite/gcc.dg/pr54669.c
> +++ b/gcc/testsuite/gcc.dg/pr54669.c
> @@ -3,6 +3,7 @@
>  
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fexceptions -fnon-call-exceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  int a[10];
>  
> diff --git a/gcc/testsuite/gcc.dg/pr56424.c b/gcc/testsuite/gcc.dg/pr56424.c
> index a724c64..7f28f04 100644
> --- a/gcc/testsuite/gcc.dg/pr56424.c
> +++ b/gcc/testsuite/gcc.dg/pr56424.c
> @@ -2,6 +2,7 @@
>  
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fexceptions -fnon-call-exceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern long double cosl (long double);
>  extern long double sinl (long double);
> diff --git a/gcc/testsuite/gcc.dg/pr64465.c b/gcc/testsuite/gcc.dg/pr64465.c
> index acfa952..d1d1749 100644
> --- a/gcc/testsuite/gcc.dg/pr64465.c
> +++ b/gcc/testsuite/gcc.dg/pr64465.c
> @@ -1,6 +1,7 @@
>  /* PR tree-optimization/64465 */
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  extern int foo (int *);
>  extern int bar (int, int);
> diff --git a/gcc/testsuite/gcc.dg/pr65802.c b/gcc/testsuite/gcc.dg/pr65802.c
> index fcec234..0721ca8 100644
> --- a/gcc/testsuite/gcc.dg/pr65802.c
> +++ b/gcc/testsuite/gcc.dg/pr65802.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O0 -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  #include <stdarg.h>
>  
> diff --git a/gcc/testsuite/gcc.dg/pr67563.c b/gcc/testsuite/gcc.dg/pr67563.c
> index 34a78a2..5a727b8 100644
> --- a/gcc/testsuite/gcc.dg/pr67563.c
> +++ b/gcc/testsuite/gcc.dg/pr67563.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  static void
>  emit_package (int p1)
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr41469-1.c 
> b/gcc/testsuite/gcc.dg/tree-ssa/pr41469-1.c
> index 6be7cd9..eb8e1f2 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/pr41469-1.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr41469-1.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fexceptions -fdump-tree-optimized" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  void af (void *a);
>  
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c 
> b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
> index d35377b..d3a1bbc 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -fdump-tree-dse-details -fexceptions 
> -fnon-call-exceptions -fno-isolate-erroneous-paths-dereference" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  
>  int foo (int *p, int b)
> diff --git a/gcc/testsuite/gcc.dg/vect/pr46663.c 
> b/gcc/testsuite/gcc.dg/vect/pr46663.c
> index 457ceae..c2e56bb 100644
> --- a/gcc/testsuite/gcc.dg/vect/pr46663.c
> +++ b/gcc/testsuite/gcc.dg/vect/pr46663.c
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
>  /* { dg-additional-options "-O -fexceptions" } */
> +/* { dg-require-effective-target exceptions } */
>  
>  typedef __attribute__ ((const)) int (*bart) (void);
>  
> diff --git a/gcc/testsuite/lib/target-supports.exp 
> b/gcc/testsuite/lib/target-supports.exp
> index b51e8f0..e27bed0 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -8826,6 +8826,16 @@ proc check_effective_target_fenv_exceptions {} {
>      } [add_options_for_ieee "-std=gnu99"]]
>  }
>  
> +# Return 1 if -fexceptions is supported.
> +
> +proc check_effective_target_exceptions {} {
> +    if { [istarget amdgcn*-*-*] } {
> +     return 0
> +    }
> +    return 1
> +}
> +
> +
>  proc check_effective_target_tiny {} {
>      global et_target_tiny_saved
>  


>From 6312165650091a4df34668d8e2aaa0bbc4008a66 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwi...@baylibre.com>
Date: Tue, 28 Jan 2025 14:57:21 +0100
Subject: [PATCH] GCN, nvptx: 'sorry, unimplemented: exception handling not
 supported'

For GCN, this avoids ICEs further down the compilation pipeline.  For nvptx,
there's effectively no change: in presence of exception handling constructs,
instead of 'sorry, unimplemented: target cannot support nonlocal goto', we
now emit 'sorry, unimplemented: exception handling not supported'.

Additionally, turn test cases into UNSUPPORTED if running into
'sorry, unimplemented: exception handling not supported'.

	gcc/
	* config/gcn/gcn.md (exception_receiver): 'define_expand'.
	* config/nvptx/nvptx.md (exception_receiver): Likewise.
	gcc/testsuite/
	* lib/gcc-dg.exp (gcc-dg-prune): Turn
	'sorry, unimplemented: exception handling not supported' into
	UNSUPPORTED.
	* gcc.dg/pr104464.c: Remove GCN XFAIL.
	libstdc++-v3/
	* testsuite/lib/prune.exp (libstdc++-dg-prune): Turn
	'sorry, unimplemented: exception handling not supported' into
	UNSUPPORTED.
---
 gcc/config/gcn/gcn.md                | 7 +++++++
 gcc/config/nvptx/nvptx.md            | 7 +++++++
 gcc/testsuite/gcc.dg/pr104464.c      | 2 --
 gcc/testsuite/lib/gcc-dg.exp         | 7 +++++++
 libstdc++-v3/testsuite/lib/prune.exp | 7 +++++++
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md
index 9dddfca742b..695656f692d 100644
--- a/gcc/config/gcn/gcn.md
+++ b/gcc/config/gcn/gcn.md
@@ -1014,6 +1014,13 @@
   [(set_attr "type" "sopp")
    (set_attr "length" "4")])
 
+(define_expand "exception_receiver"
+  [(const_int 0)]
+  ""
+{
+  sorry ("exception handling not supported");
+})
+
 ;; }}}
 ;; {{{ Conditionals
 
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index a22a088fb3a..d3d538070c0 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -1640,6 +1640,13 @@
   DONE;
 })
 
+(define_expand "exception_receiver"
+  [(const_int 0)]
+  ""
+{
+  sorry ("exception handling not supported");
+})
+
 (define_expand "nonlocal_goto"
   [(match_operand 0 "" "")
    (match_operand 1 "" "")
diff --git a/gcc/testsuite/gcc.dg/pr104464.c b/gcc/testsuite/gcc.dg/pr104464.c
index d36a28678cb..ed6a22c39d5 100644
--- a/gcc/testsuite/gcc.dg/pr104464.c
+++ b/gcc/testsuite/gcc.dg/pr104464.c
@@ -9,5 +9,3 @@ foo(void)
 {
   f += (F)(f != (F){}[0]);
 }
-
-/* { dg-xfail-if "-fnon-call-exceptions unsupported" { amdgcn-*-* } } */
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 07a996a4466..70be7a8d5fd 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -434,6 +434,13 @@ proc gcc-dg-prune { system text } {
 	return "::unsupported::large return values"
     }
 
+    # If exception handling is not supported, expectant tests are UNSUPPORTED.
+    if { ![check_effective_target_exceptions] } {
+	if [regexp "(^|\n)\[^\n\]*: sorry, unimplemented: exception handling not supported" $text] {
+	    return "::unsupported::exception handling not supported"
+	}
+    }
+
     # If exception handling is disabled, expectant tests are UNSUPPORTED.
     if { ![check_effective_target_exceptions_enabled] } {
 	if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] {
diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp
index 593b74985fb..566572baa6d 100644
--- a/libstdc++-v3/testsuite/lib/prune.exp
+++ b/libstdc++-v3/testsuite/lib/prune.exp
@@ -89,6 +89,13 @@ proc libstdc++-dg-prune { system text } {
     # the single uncapitalized "in function" line.
     regsub -all "(^|\n)\[^\n\]*: in function\[^\n\]*" $text "" text
 
+    # If exception handling is not supported, expectant tests are UNSUPPORTED.
+    if { ![check_effective_target_exceptions] } {
+	if [regexp "(^|\n)\[^\n\]*: sorry, unimplemented: exception handling not supported" $text] {
+	    return "::unsupported::exception handling not supported"
+	}
+    }
+
     # If exception handling is disabled, expectant tests are UNSUPPORTED.
     if { ![check_effective_target_exceptions_enabled] } {
 	if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] {
-- 
2.34.1

Reply via email to