Commit 654b6073 by Francois-Xavier Coudert Committed by François-Xavier Coudert

re PR fortran/31629 (option to make module entities PRIVATE by default)

	PR fortran/31629

	* lang.opt (-fmodule-private): New option.
	* gfortran.h (gfc_option_t): Add flag_module_private member.
	* invoke.texi (-fmodule-private): Document the new option.
	* module.c (gfc_check_access): Allow the -fmodule-private option
	to modify the default behaviour.
	* options.c (gfc_init_options): Initialize flag_module_private.
	(gfc_handle_option): Handle -fmodule-private.

	* gfortran.dg/module_private_1.f90: New test.

From-SVN: r127381
parent 5cda5098
2007-08-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2007-08-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31629
* lang.opt (-fmodule-private): New option.
* gfortran.h (gfc_option_t): Add flag_module_private member.
* invoke.texi (-fmodule-private): Document the new option.
* module.c (gfc_check_access): Allow the -fmodule-private option
to modify the default behaviour.
* options.c (gfc_init_options): Initialize flag_module_private.
(gfc_handle_option): Handle -fmodule-private.
2007-08-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/29600 PR fortran/29600
* intrinsic.c (add_functions): Add KIND arguments to COUNT, * intrinsic.c (add_functions): Add KIND arguments to COUNT,
IACHAR, ICHAR, INDEX, LBOUND, LEN, LEN_TRIM, SCAN, SIZE, UBOUND IACHAR, ICHAR, INDEX, LBOUND, LEN, LEN_TRIM, SCAN, SIZE, UBOUND
......
...@@ -1865,6 +1865,7 @@ typedef struct ...@@ -1865,6 +1865,7 @@ typedef struct
int flag_d_lines; int flag_d_lines;
int flag_openmp; int flag_openmp;
int flag_sign_zero; int flag_sign_zero;
int flag_module_private;
int fpe; int fpe;
......
...@@ -121,7 +121,7 @@ by type. Explanations are in the following sections. ...@@ -121,7 +121,7 @@ by type. Explanations are in the following sections.
-ffixed-line-length-@var{n} -ffixed-line-length-none @gol -ffixed-line-length-@var{n} -ffixed-line-length-none @gol
-ffree-line-length-@var{n} -ffree-line-length-none @gol -ffree-line-length-@var{n} -ffree-line-length-none @gol
-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 @gol -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 @gol
-fcray-pointer -fopenmp -frange-check -fno-backslash } -fcray-pointer -fopenmp -frange-check -fno-backslash -fmodule-private}
@item Error and Warning Options @item Error and Warning Options
@xref{Error and Warning Options,,Options to request or suppress errors @xref{Error and Warning Options,,Options to request or suppress errors
...@@ -238,6 +238,14 @@ Allow @samp{$} as a valid character in a symbol name. ...@@ -238,6 +238,14 @@ Allow @samp{$} as a valid character in a symbol name.
Change the interpretation of backslashes in string literals from Change the interpretation of backslashes in string literals from
``C-style'' escape characters to a single backslash character. ``C-style'' escape characters to a single backslash character.
@item -fmodule-private
@opindex @code{fmodule-private}
@cindex module entities
@cindex private
Set the default accessibility of module entities to @code{PRIVATE}.
Use-associated entities will not be accessible unless they are explicitly
declared as @code{PUBLIC}.
@item -ffixed-line-length-@var{n} @item -ffixed-line-length-@var{n}
@opindex @code{ffixed-line-length-}@var{n} @opindex @code{ffixed-line-length-}@var{n}
@cindex file format, fixed @cindex file format, fixed
......
...@@ -212,6 +212,10 @@ fmax-stack-var-size= ...@@ -212,6 +212,10 @@ fmax-stack-var-size=
Fortran RejectNegative Joined UInteger Fortran RejectNegative Joined UInteger
-fmax-stack-var-size=<n> Size in bytes of the largest array that will be put on the stack -fmax-stack-var-size=<n> Size in bytes of the largest array that will be put on the stack
fmodule-private
Fortran
Set default accessibility of module entities to PRIVATE.
fopenmp fopenmp
Fortran Fortran
Enable OpenMP Enable OpenMP
......
...@@ -3714,7 +3714,10 @@ gfc_check_access (gfc_access specific_access, gfc_access default_access) ...@@ -3714,7 +3714,10 @@ gfc_check_access (gfc_access specific_access, gfc_access default_access)
if (specific_access == ACCESS_PRIVATE) if (specific_access == ACCESS_PRIVATE)
return FALSE; return FALSE;
return default_access != ACCESS_PRIVATE; if (gfc_option.flag_module_private)
return default_access == ACCESS_PUBLIC;
else
return default_access != ACCESS_PRIVATE;
} }
......
...@@ -93,6 +93,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED, ...@@ -93,6 +93,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
gfc_option.flag_preprocessed = 0; gfc_option.flag_preprocessed = 0;
gfc_option.flag_automatic = 1; gfc_option.flag_automatic = 1;
gfc_option.flag_backslash = 1; gfc_option.flag_backslash = 1;
gfc_option.flag_module_private = 0;
gfc_option.flag_backtrace = 0; gfc_option.flag_backtrace = 0;
gfc_option.flag_allow_leading_underscore = 0; gfc_option.flag_allow_leading_underscore = 0;
gfc_option.flag_dump_core = 0; gfc_option.flag_dump_core = 0;
...@@ -575,6 +576,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -575,6 +576,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_option.flag_max_stack_var_size = value; gfc_option.flag_max_stack_var_size = value;
break; break;
case OPT_fmodule_private:
gfc_option.flag_module_private = value;
break;
case OPT_frange_check: case OPT_frange_check:
gfc_option.flag_range_check = value; gfc_option.flag_range_check = value;
break; break;
......
2007-08-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2007-08-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31629
* gcc/testsuite/gfortran.dg/module_private_1.f90: New test.
2007-08-12 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/29600 PR fortran/29600
* gfortran.dg/intrinsics_kind_argument_1.f90: New test. * gfortran.dg/intrinsics_kind_argument_1.f90: New test.
* gfortran.dg/pure_dummy_length_1.f90: Adapt to new error wording. * gfortran.dg/pure_dummy_length_1.f90: Adapt to new error wording.
! { dg-do compile }
! { dg-options "-fmodule-private" }
module bar
implicit none
public :: i
integer :: i
end module bar
module foo
implicit none
integer :: j
end module foo
program main
use bar, only : i
use foo, only : j ! { dg-error "not found in module" }
i = 1
j = 1
print *, i, j
end program main
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