Hi! On 2019-11-27T19:53:32+0000, Jozef Lawrynowicz <joze...@mittosystems.com> wrote: > --- a/gcc/testsuite/lib/target-supports.exp > +++ b/gcc/testsuite/lib/target-supports.exp | # Return 1 if -fexceptions is supported. | | proc check_effective_target_exceptions {} { | if { [istarget amdgcn*-*-*] } { | return 0 | } > return 1 > } > > +# Used to check if the testing configuration supports exceptions. > +# Returns 0 if exceptions are unsupported or disabled (e.g. by passing > +# -fno-exceptions). Returns 1 if exceptions are enabled. > +proc check_effective_target_exceptions_enabled {} { > + return [check_cached_effective_target exceptions_enabled { > + if { [check_effective_target_exceptions] } { > + return [check_no_compiler_messages exceptions_enabled assembly { > + void foo (void) > + { > + throw 1; > + } > + }] > + } else { > + # If exceptions aren't supported, then they're not enabled. > + return 0 > + } > + }] > +}
Pushed to trunk branch commit 9f4feba699f3b3fef29bc8199db69a8eb7d64d07 "Clarify that effective-targets 'exceptions' and 'exceptions_enabled' are orthogonal", see attached. Grüße Thomas
>From 9f4feba699f3b3fef29bc8199db69a8eb7d64d07 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Thu, 6 Feb 2025 22:46:51 +0100 Subject: [PATCH] Clarify that effective-targets 'exceptions' and 'exceptions_enabled' are orthogonal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Subversion r268025 (Git commit 3f21b8e3f7be32dd2b3624a2ece12f84bed545bb) "Add dg-require-effective-target exceptions", effective-target 'exceptions' was added, which "says that AMD GCN does not support [exception handling]". In Subversion r279246 (Git commit a9046e9853024206bec092dd63e21e152cb5cbca) "MSP430: Add -fno-exceptions multilib", effective-target 'exceptions_enabled' was added "to check if the testing configuration supports exceptions". Testing "if exceptions are unsupported or disabled (e.g. by passing -fno-exceptions)" works as expected if exception handling is disabled at the front-end level ('-fno-exceptions'; the "exceptions are [...] disabled" case): exceptions_enabled2066068.cc: In function ‘void foo()’: exceptions_enabled2066068.cc:3:27: error: exception handling disabled, use ‘-fexceptions’ to enable However, effective-target 'exceptions_enabled' additionally assumes that "If exceptions aren't supported [by the target], then they're not enabled". This is not correct: it's not unlikely that, in presence of explicit/implicit '-fexceptions', exception handling code gets fully optimized away by the compiler, and therefore effective-target 'exceptions_enabled' test cases may PASS even for targets that don't support effective-target 'exceptions'; these two effective-targets are orthogonal concepts. (For completeness: code with trivial instances of C++ exception handling may translate into simple '__cxa_allocate_exception', '__cxa_throw' function calls without requiring any back end-level "exceptions magic", and then trigger unresolved symbols at link time, if these functions are not available.) This change only affects GCN, as that one currently is the only target declared as not supporting effective-target 'exceptions'. gcc/ * doc/sourcebuild.texi (Effective-Target Keywords): Clarify that effective-target 'exceptions' and 'exceptions_enabled' are orthogonal. gcc/testsuite/ * lib/gcc-dg.exp (gcc-dg-prune): Clarify effective-target 'exceptions_enabled'. * lib/target-supports.exp (check_effective_target_exceptions_enabled): Don't consider effective-target 'exceptions'. libstdc++-v3/ * testsuite/lib/prune.exp (libstdc++-dg-prune): Clarify effective-target 'exceptions_enabled'. --- gcc/doc/sourcebuild.texi | 7 ++++--- gcc/testsuite/lib/gcc-dg.exp | 3 +-- gcc/testsuite/lib/target-supports.exp | 30 +++++++++++++-------------- libstdc++-v3/testsuite/lib/prune.exp | 3 +-- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 98ede70f23c..797775e90de 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2996,11 +2996,12 @@ Target uses @code{__cxa_atexit}. Target has packed layout of structure members by default. @item exceptions -Target supports exceptions. +Target supports exception handling. +Note that this is orthogonal to effective-target @code{exceptions_enabled}. @item exceptions_enabled -Target supports exceptions and they are enabled in the current -testing configuration. +Testing configuration has exception handling enabled. +Note that this is orthogonal to effective-target @code{exceptions}. @item fgraphite Target supports Graphite optimizations. diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 65a5f3f1dbe..07a996a4466 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -434,8 +434,7 @@ proc gcc-dg-prune { system text } { return "::unsupported::large return values" } - # If exceptions are disabled, mark tests expecting exceptions to be enabled - # as unsupported. + # If exception handling is disabled, expectant tests are UNSUPPORTED. if { ![check_effective_target_exceptions_enabled] } { if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] { return "::unsupported::exception handling disabled" diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 60e24129bd5..aed2b79c4af 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -12559,7 +12559,8 @@ proc check_effective_target_fenv_exceptions_long_double {} { } [add_options_for_ieee "-std=gnu99"]] } -# Return 1 if -fexceptions is supported. +# Check whether the target supports exception handling. +# Note that this is orthogonal to effective-target 'exceptions_enabled'. proc check_effective_target_exceptions {} { if { [istarget amdgcn*-*-*] } { @@ -12568,23 +12569,20 @@ proc check_effective_target_exceptions {} { return 1 } -# Used to check if the testing configuration supports exceptions. -# Returns 0 if exceptions are unsupported or disabled (e.g. by passing -# -fno-exceptions). Returns 1 if exceptions are enabled. +# Check whether the testing configuration has exception handling enabled. +# Returns 0 if exception handling is disabled (e.g. by passing +# -fno-exceptions). Returns 1 if exception handling is enabled. +# Note that this is orthogonal to effective-target 'exceptions'. + proc check_effective_target_exceptions_enabled {} { return [check_cached_effective_target exceptions_enabled { - if { [check_effective_target_exceptions] } { - return [check_no_compiler_messages exceptions_enabled assembly { - // C++ - void foo (void) - { - throw 1; - } - }] - } else { - # If exceptions aren't supported, then they're not enabled. - return 0 - } + return [check_no_compiler_messages exceptions_enabled assembly { + // C++ + void foo (void) + { + throw 1; + } + }] }] } diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp index 3048ffffdb2..593b74985fb 100644 --- a/libstdc++-v3/testsuite/lib/prune.exp +++ b/libstdc++-v3/testsuite/lib/prune.exp @@ -89,8 +89,7 @@ proc libstdc++-dg-prune { system text } { # the single uncapitalized "in function" line. regsub -all "(^|\n)\[^\n\]*: in function\[^\n\]*" $text "" text - # If exceptions are disabled, mark tests expecting exceptions to be enabled - # as unsupported. + # If exception handling is disabled, expectant tests are UNSUPPORTED. if { ![check_effective_target_exceptions_enabled] } { if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] { return "::unsupported::exception handling disabled" -- 2.34.1