testsuite: Enable fenv effective-targets for C++

Message ID 20200730102300.GL3400@redhat.com
State New
Headers show
Series
  • testsuite: Enable fenv effective-targets for C++
Related show

Commit Message

Bill Schmidt via Gcc-patches July 30, 2020, 10:23 a.m.
I recently wanted to use { dg-require-effective-target fenv } in a
libstdc++ test, but it uses -std=gnu99 which is only valid for C.

This allows C++ tests to use the fenv and fenv_exceptions
effective-target keywords.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_fenv): Use
	-std=gnu++11 instead of -std=gnu99 for C++ tests.
	(check_effective_target_fenv_exceptions): Likewise.


I don't actually need to use the 'fenv' target now, but does this seem
like a reasonable change anyway?

Comments

Bill Schmidt via Gcc-patches Aug. 25, 2020, 7:27 p.m. | #1
On Thu, 2020-07-30 at 11:23 +0100, Jonathan Wakely via Gcc-patches wrote:
> I recently wanted to use { dg-require-effective-target fenv } in a

> libstdc++ test, but it uses -std=gnu99 which is only valid for C.

> 

> This allows C++ tests to use the fenv and fenv_exceptions

> effective-target keywords.

> 

> gcc/testsuite/ChangeLog:

> 

> 	* lib/target-supports.exp (check_effective_target_fenv): Use

> 	-std=gnu++11 instead of -std=gnu99 for C++ tests.

> 	(check_effective_target_fenv_exceptions): Likewise.

> 

> 

> I don't actually need to use the 'fenv' target now, but does this seem

> like a reasonable change anyway?

It seems reasonable to me.  Selecting the right option automatically seems better
than any of the alternatives.

jeff

Patch

commit 727a3c3008038f97b0d43ebd88b2da6b4d4159f6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jul 30 10:32:03 2020

    testsuite: Enable fenv effective-targets for C++
    
    I recently wanted to use { dg-require-effective-target fenv } in a
    libstdc++ test, but it uses -std=gnu99 which is only valid for C.
    
    This allows C++ tests to use the fenv and fenv_exceptions
    effective-target keywords.
    
    gcc/testsuite/ChangeLog:
    
            * lib/target-supports.exp (check_effective_target_fenv): Use
            -std=gnu++11 instead of -std=gnu99 for C++ tests.
            (check_effective_target_fenv_exceptions): Likewise.

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 57eed3012b9..042334e3a35 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9533,9 +9533,14 @@  proc check_effective_target_avr_tiny { } {
 # Return 1 if <fenv.h> is available.
 
 proc check_effective_target_fenv {} {
+    if [check_effective_target_c++] {
+	set std "-std=gnu++11"
+    } else {
+	set std "-std=gnu99"
+    }
     return [check_no_compiler_messages fenv object {
 	#include <fenv.h>
-    } [add_options_for_ieee "-std=gnu99"]]
+    } [add_options_for_ieee "$std"]]
 }
 
 # Return 1 if <fenv.h> is available with all the standard IEEE
@@ -9544,6 +9549,11 @@  proc check_effective_target_fenv {} {
 # exceptions, those need to be specified in the testcases.)
 
 proc check_effective_target_fenv_exceptions {} {
+    if [check_effective_target_c++] {
+	set std "-std=gnu++11"
+    } else {
+	set std "-std=gnu99"
+    }
     return [check_runtime fenv_exceptions {
 	#include <fenv.h>
 	#include <stdlib.h>
@@ -9572,7 +9582,7 @@  proc check_effective_target_fenv_exceptions {} {
 	  else
 	    abort ();
 	}
-    } [add_options_for_ieee "-std=gnu99"]]
+    } [add_options_for_ieee "$std"]]
 }
 
 # Return 1 if -fexceptions is supported.