From 321bff11a3a1f0e3ecc925304b05f25bb72c9c94 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Wed, 20 Aug 2014 09:08:57 +0200 Subject: [PATCH] options.c (gfc_init_options_struct): assert that the frontend sets flag_errno_math and flag_associative_math. gcc/fortran/ChangeLog: 2014-08-20 Joost VandeVondele * options.c (gfc_init_options_struct): assert that the frontend sets flag_errno_math and flag_associative_math. gcc/testsuite/ChangeLog: 2014-08-20 Joost VandeVondele * gfortran.dg/errnocheck_1.f90: New test. * gfortran.dg/associative_1.f90: New test. From-SVN: r214211 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/options.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/associative_1.f90 | 10 ++++++++++ gcc/testsuite/gfortran.dg/errnocheck_1.f90 | 8 ++++++++ 5 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/associative_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/errnocheck_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 53d2691c6bb2..9d939ea35c3d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2014-08-20 Joost VandeVondele + + * options.c (gfc_init_options_struct): assert that the frontend sets + flag_errno_math and flag_associative_math. + 2014-08-17 Tobias Burnus * resolve.c (gfc_resolve_finalizers): Ensure that parents are diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 508a01c57f87..2f4338e175e2 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -66,7 +66,9 @@ void gfc_init_options_struct (struct gcc_options *opts) { opts->x_flag_errno_math = 0; + opts->frontend_set_flag_errno_math = true; opts->x_flag_associative_math = -1; + opts->frontend_set_flag_associative_math = true; } /* Get ready for options handling. Keep in sync with diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc10ea9b2ff3..b8473c3a6229 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-20 Joost VandeVondele + + * gfortran.dg/errnocheck_1.f90: New test. + * gfortran.dg/associative_1.f90: New test. + 2014-08-20 Manuel López-Ibáñez PR preprocessor/51303 diff --git a/gcc/testsuite/gfortran.dg/associative_1.f90 b/gcc/testsuite/gfortran.dg/associative_1.f90 new file mode 100644 index 000000000000..c4103a7f3e4f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associative_1.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-O1 -fno-signed-zeros -fno-trapping-math -fdump-tree-optimized" } +! Fortran defaults to associative by default, +! with -fno-signed-zeros -fno-trapping-math this should optimize away all additions +SUBROUTINE S1(a) + REAL :: a + a=1+a-1 +END SUBROUTINE S1 +! { dg-final { scan-tree-dump-times " \\\+ " 0 "optimized" } } +! { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/gfortran.dg/errnocheck_1.f90 b/gcc/testsuite/gfortran.dg/errnocheck_1.f90 new file mode 100644 index 000000000000..d9cf994e164f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/errnocheck_1.f90 @@ -0,0 +1,8 @@ +! { dg-do compile { target x86_64-*-* } } +! Fortran should default to -fno-math-errno +! and thus no call to sqrt in asm +subroutine mysqrt(a) + real(KIND=KIND(0.0D0)) :: a + a=sqrt(a) +end subroutine +! { dg-final { scan-assembler-times "call" 0 } } -- 2.47.3