Commit 7ed760c7 by Fritz Reese Committed by Fritz Reese

re PR fortran/87919 (Incorrect fortran handling of -fno-* options)

2018-12-03  Fritz Reese  <fritzoreese@gmail.com>
            Mark Eggleston <mark.eggleston@codethink.co.uk>

    PR fortran/87919

    gcc/fortran/ChangeLog:

	PR fortran/87919
	* options.c (SET_FLAG, SET_BITFLAG, SET_BITFLAG2): New macros.
	(set_dec_flags): Set/unset DEC and std flags according to value.
	(set_init_local_zero): New helper for -finit-local-zero flag group.
	(gfc_init_options): Fix disabling of init flags, array temporaries
	check, and dec flags when value is zero (from -fno-*).

    gcc/testsuite/ChangeLog:

	PR fortran/87919
	* gfortran.dg/array_temporaries_5.f90: New test.
	* gfortran.dg/dec_bitwise_ops_3.f90: Ditto.
	* gfortran.dg/dec_d_lines_3.f: Ditto.
	* gfortran.dg/dec_exp_4.f90: Ditto.
	* gfortran.dg/dec_exp_5.f90: Ditto.
	* gfortran.dg/dec_io_7.f90: Ditto.
	* gfortran.dg/dec_structure_24.f90: Ditto.
	* gfortran.dg/dec_structure_25.f90: Ditto.
	* gfortran.dg/dec_structure_26.f90: Ditto.
	* gfortran.dg/dec_structure_27.f90: Ditto.
	* gfortran.dg/dec_type_print_3.f90: Ditto.
	* gfortran.dg/init_flag_20.f90: Ditto.


Co-Authored-By: Mark Eggleston <mark.eggleston@codethink.co.uk>

From-SVN: r266745
parent 509f9870
2018-12-03 Fritz Reese <fritzoreese@gmail.com>
Mark Eggleston <mark.eggleston@codethink.co.uk>
PR fortran/87919
* options.c (SET_FLAG, SET_BITFLAG, SET_BITFLAG2): New macros.
(set_dec_flags): Set/unset DEC and std flags according to value.
(set_init_local_zero): New helper for -finit-local-zero flag group.
(gfc_init_options): Fix disabling of init flags, array temporaries
check, and dec flags when value is zero (from -fno-*).
2018-11-30 Thomas Schwinge <thomas@codesourcery.com> 2018-11-30 Thomas Schwinge <thomas@codesourcery.com>
* gfortran.h (struct gfc_omp_clauses): Remove "wait". Adjust all * gfortran.h (struct gfc_omp_clauses): Remove "wait". Adjust all
......
...@@ -32,6 +32,20 @@ along with GCC; see the file COPYING3. If not see ...@@ -32,6 +32,20 @@ along with GCC; see the file COPYING3. If not see
gfc_option_t gfc_option; gfc_option_t gfc_option;
#define SET_FLAG(flag, condition, on_value, off_value) \
do \
{ \
if (condition) \
flag = (on_value); \
else \
flag = (off_value); \
} while (0)
#define SET_BITFLAG2(m) m
#define SET_BITFLAG(flag, condition, value) \
SET_BITFLAG2 (SET_FLAG (flag, condition, (flag | (value)), (flag & ~(value))))
/* Set flags that control warnings and errors for different /* Set flags that control warnings and errors for different
Fortran standards to their default values. Keep in sync with Fortran standards to their default values. Keep in sync with
...@@ -47,30 +61,55 @@ set_default_std_flags (void) ...@@ -47,30 +61,55 @@ set_default_std_flags (void)
gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY; gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY;
} }
/* Set (or unset) the DEC extension flags. */
/* Set all the DEC extension flags. */
static void static void
set_dec_flags (int value) set_dec_flags (int value)
{ {
/* Set (or unset) other DEC compatibility extensions. */
SET_BITFLAG (flag_dollar_ok, value, value);
SET_BITFLAG (flag_cray_pointer, value, value);
SET_BITFLAG (flag_dec_structure, value, value);
SET_BITFLAG (flag_dec_intrinsic_ints, value, value);
SET_BITFLAG (flag_dec_static, value, value);
SET_BITFLAG (flag_dec_math, value, value);
SET_BITFLAG (flag_dec_include, value, value);
}
/* Finalize DEC flags. */
static void
post_dec_flags (int value)
{
/* Don't warn for legacy code if -fdec is given; however, setting -fno-dec
does not force these warnings. We make one final determination on this
at the end because -std= is always set first; thus, we can avoid
clobbering the user's desired standard settings in gfc_handle_option
e.g. when -fdec and -fno-dec are both given. */
if (value) if (value)
{ {
/* Allow legacy code without warnings. */
gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_GNU | GFC_STD_LEGACY; | GFC_STD_GNU | GFC_STD_LEGACY;
gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL); gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
} }
/* Set other DEC compatibility extensions. */
flag_dollar_ok |= value;
flag_cray_pointer |= value;
flag_dec_structure |= value;
flag_dec_intrinsic_ints |= value;
flag_dec_static |= value;
flag_dec_math |= value;
flag_dec_include |= value;
} }
/* Enable (or disable) -finit-local-zero. */
static void
set_init_local_zero (int value)
{
gfc_option.flag_init_integer_value = 0;
gfc_option.flag_init_character_value = (char)0;
SET_FLAG (gfc_option.flag_init_integer, value, GFC_INIT_INTEGER_ON,
GFC_INIT_INTEGER_OFF);
SET_FLAG (gfc_option.flag_init_logical, value, GFC_INIT_LOGICAL_FALSE,
GFC_INIT_LOGICAL_OFF);
SET_FLAG (gfc_option.flag_init_character, value, GFC_INIT_CHARACTER_ON,
GFC_INIT_CHARACTER_OFF);
SET_FLAG (flag_init_real, value, GFC_INIT_REAL_ZERO, GFC_INIT_REAL_OFF);
}
/* Return language mask for Fortran options. */ /* Return language mask for Fortran options. */
......
2018-12-03 Fritz Reese <fritzoreese@gmail.com>
Mark Eggleston <mark.eggleston@codethink.co.uk>
PR fortran/87919
* gfortran.dg/array_temporaries_5.f90: New test.
* gfortran.dg/dec_bitwise_ops_3.f90: Ditto.
* gfortran.dg/dec_d_lines_3.f: Ditto.
* gfortran.dg/dec_exp_4.f90: Ditto.
* gfortran.dg/dec_exp_5.f90: Ditto.
* gfortran.dg/dec_io_7.f90: Ditto.
* gfortran.dg/dec_structure_24.f90: Ditto.
* gfortran.dg/dec_structure_25.f90: Ditto.
* gfortran.dg/dec_structure_26.f90: Ditto.
* gfortran.dg/dec_structure_27.f90: Ditto.
* gfortran.dg/dec_type_print_3.f90: Ditto.
* gfortran.dg/init_flag_20.f90: Ditto.
2018-12-03 Jeff Law <law@redhat.com> 2018-12-03 Jeff Law <law@redhat.com>
* gcc.dg/pr59963-2.c: Make testnames unique. * gcc.dg/pr59963-2.c: Make testnames unique.
......
! { dg-do run }
! { dg-options "-fcheck-array-temporaries -fno-check-array-temporaries" }
!
! PR fortran/87919
!
! Ensure -fno-check-array-temporaries disables array temporary checking.
!
! Note that 'include' drops the dg-output check from the original test case.
include 'array_temporaries_2.f90'
! { dg-do compile }
! { dg-options "-std=legacy -fdec -fno-dec" }
!
! PR fortran/87919
!
! Make sure -fno-dec disables bitwise ops and check for the right errors.
! -std=legacy is added to avoid the .XOR. extension warning.
!
include 'dec_bitwise_ops_1.f90'
! { dg-error "Operands of logical operator" " " { target *-*-* } 33 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 34 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 35 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 46 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 47 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 48 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 59 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 60 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 61 }
! { dg-error "Operand of .not. operator" " " { target *-*-* } 72 }
! { dg-error "Operand of .not. operator" " " { target *-*-* } 73 }
! { dg-error "Operand of .not. operator" " " { target *-*-* } 74 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 85 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 86 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 87 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 98 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 99 }
! { dg-error "Operands of logical operator" " " { target *-*-* } 100 }
! { dg-do compile }
! { dg-options "-ffixed-form -fdec -fno-dec" }
!
! PR fortran/87919
!
! Ensure -fno-dec disables -fdec, leaving d-lines as code by default.
!
include 'dec_d_lines_2.f'
! { dg-error "character in statement label" " " { target *-*-*} 6 }
! { dg-error "Unclassifiable statement" " " { target *-*-*} 6 }
! { dg-error "character in statement label" " " { target *-*-*} 7 }
! { dg-error "Unclassifiable statement" " " { target *-*-*} 7 }
! { dg-do compile }
! { dg-options "-fdec -fno-dec" }
!
! PR fortran/87919
!
! Make sure -fno-dec disables -fdec as with dec_exp_2.
!
include 'dec_exp_2.f90'
! { dg-error "Missing exponent" "" { target *-*-* } 9 }
! { dg-error "Missing exponent" "" { target *-*-* } 11 }
! { dg-do run "xfail *-*-*" }
! { dg-options "-fdec -fno-dec" }
!
! PR fortran/87919
!
! Make sure -fno-dec disables -fdec as with dec_exp_3.
!
include 'dec_exp_3.f90'
! { XFAIL "Bad real number" "" { target *-*-* } 13 }
! { dg-do compile }
! { dg-options "-fdec -fno-dec" }
!
! PR fortran/87919
!
! Make sure -fno-dec rejects -fdec I/O specifiers as with dec_io_1.
!
include 'dec_io_1.f90'
! { dg-error "is a DEC extension" "" { target *-*-* } 12 }
! { dg-error "is a DEC extension" "" { target *-*-* } 24 }
! { dg-error "is a DEC extension" "" { target *-*-* } 58 }
! { dg-error "is a DEC extension" "" { target *-*-* } 64 }
! { dg-error "is a DEC extension" "" { target *-*-* } 68 }
! { dg-error "is a DEC extension" "" { target *-*-* } 74 }
! { dg-error "is a DEC extension" "" { target *-*-* } 78 }
! { dg-error "is a DEC extension" "" { target *-*-* } 84 }
! { dg-error "is a DEC extension" "" { target *-*-* } 90 }
! { dg-error "is a DEC extension" "" { target *-*-* } 96 }
! { dg-do compile }
!
! PR fortran/87919
!
! Should fail to compile without the -fdec or -fdec-structure options.
!
! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
include 'dec_structure_1.f90'
! { dg-error "-fdec-structure" " " { target *-*-* } 14 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 19 }
! { dg-error "-fdec-structure" " " { target *-*-* } 21 }
! { dg-error "-fdec-structure" " " { target *-*-* } 22 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 25 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 26 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 27 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 28 }
! { dg-error "is not a variable" " " { target *-*-* } 30 }
! { dg-error "Bad character" " " { target *-*-* } 32 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 34 }
! { dg-error "Bad character" " " { target *-*-* } 36 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 38 }
! { dg-error "Bad character" " " { target *-*-* } 40 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 42 }
! { dg-error "Bad character" " " { target *-*-* } 44 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 46 }
! { dg-error "Bad character" " " { target *-*-* } 48 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 50 }
! { dg-error "Bad character" " " { target *-*-* } 52 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 54 }
! { dg-error "function result" " " { target *-*-* } 29 }
! { dg-do run }
! { dg-options "-fdec" }
!
! PR fortran/87919
!
! Should compile and run with the -fdec option.
!
! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
!
include 'dec_structure_1.f90'
! { dg-do compile }
! { dg-options "-fdec -fno-dec-structure" }
!
! PR fortran/87919
!
! Should fail to compile with -fdec and -fno-dec-structure.
!
! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
!
include 'dec_structure_1.f90'
! { dg-error "-fdec-structure" " " { target *-*-* } 14 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 19 }
! { dg-error "-fdec-structure" " " { target *-*-* } 21 }
! { dg-error "-fdec-structure" " " { target *-*-* } 22 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 25 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 26 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 27 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 28 }
! { dg-error "is not a variable" " " { target *-*-* } 30 }
! { dg-error "Bad character" " " { target *-*-* } 32 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 34 }
! { dg-error "Bad character" " " { target *-*-* } 36 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 38 }
! { dg-error "Bad character" " " { target *-*-* } 40 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 42 }
! { dg-error "Bad character" " " { target *-*-* } 44 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 46 }
! { dg-error "Bad character" " " { target *-*-* } 48 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 50 }
! { dg-error "Bad character" " " { target *-*-* } 52 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 54 }
! { dg-error "function result" " " { target *-*-* } 29 }
! { dg-do compile }
! { dg-options "-fdec-structure -fno-dec-structure" }
!
! PR fortran/87919
!
! Should fail to compile with -fdec-structure and -fno-dec-structure.
!
! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
!
include 'dec_structure_1.f90'
! { dg-error "-fdec-structure" " " { target *-*-* } 14 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 19 }
! { dg-error "-fdec-structure" " " { target *-*-* } 21 }
! { dg-error "-fdec-structure" " " { target *-*-* } 22 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 25 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 26 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 27 }
! { dg-error "Unclassifiable statement" " " { target *-*-* } 28 }
! { dg-error "is not a variable" " " { target *-*-* } 30 }
! { dg-error "Bad character" " " { target *-*-* } 32 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 34 }
! { dg-error "Bad character" " " { target *-*-* } 36 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 38 }
! { dg-error "Bad character" " " { target *-*-* } 40 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 42 }
! { dg-error "Bad character" " " { target *-*-* } 44 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 46 }
! { dg-error "Bad character" " " { target *-*-* } 48 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 50 }
! { dg-error "Bad character" " " { target *-*-* } 52 }
! { dg-error "Expecting END PROGRAM" " " { target *-*-* } 54 }
! { dg-error "function result" " " { target *-*-* } 29 }
! { dg-do compile }
! { dg-options "-fdec -fno-dec" }
!
! PR fortran/87919
!
! Ensure that -fno-dec disables the usage of TYPE as an alias for PRINT.
!
include 'dec_type_print.f90'
! { dg-error "Invalid character in name" "" { target *-*-* } 52 }
! { dg-error "Invalid character in name" "" { target *-*-* } 53 }
! { dg-error "Invalid character in name" "" { target *-*-* } 54 }
! { dg-error "Invalid character in name" "" { target *-*-* } 55 }
! { dg-error "Invalid character in name" "" { target *-*-* } 56 }
! { dg-error "Invalid character in name" "" { target *-*-* } 57 }
! { dg-error "Invalid character in name" "" { target *-*-* } 58 }
! { dg-error "Unclassifiable statement" "" { target *-*-* } 59 }
! { dg-error "conflicts with PROCEDURE" "" { target *-*-* } 60 }
! { dg-error "Cannot assign to a named constant" "" { target *-*-* } 80 }
! { dg-do compile }
! { dg-options "-fbackslash -finit-local-zero -fno-init-local-zero -fdump-tree-original" }
!
! PR fortran/87919
!
! Make sure -fno-init-local-zero disables -finit-local-zero.
!
include 'init_flag_1.f90'
! Make sure no initialization code is generated.
! { dg-final { scan-tree-dump-times "r\[1-4] *= *\[0\{]" 0 "original" } }
! { dg-final { scan-tree-dump-times "l\[12] *= *\[0\{]" 0 "original" } }
! { dg-final { scan-tree-dump-times "i\[1-4] *= *\[0\{]" 0 "original" } }
! { dg-final { scan-tree-dump-times "memmove *\[(]\[^,]*c\[1-4]" 0 "original" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment