From patchwork Mon Dec 15 22:15:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 421695 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46EF11400B7 for ; Tue, 16 Dec 2014 09:15:55 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=bpHde5hnd7EjRxTQ9plmPqsc3xUXTSQa7i/mwvoUrVHxQZ kO9IYD15mdNQDrv7Y5RnuLnlfBvZijLje1ZneIfxFetQdwciFqx3W//MYybv9jMe YehbTO+EG6kRq09G9rXJ5nAVJJeWmteh1PCSySpYbp/4gjVzmNlqaMlUOWGGw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Osp5vq8GDxFuaAbplgoq6EfrwDo=; b=O6MmU5y31pjEnspDpI9e mpSRNIayCpVXEr0c3ePCDex4XoDCnitC+/z6IgXGn6IKc3GLDZ4jxFGlenCLHoj0 g6/Fc291NwJAKt5KLnpU3eHUcK7VsNdyvpdeTif0wFpjuj2Aayfjd5F3awFIHFPK ehfYAbcdFyAh56x9e1S+8Ao= Received: (qmail 32116 invoked by alias); 15 Dec 2014 22:15:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32075 invoked by uid 89); 15 Dec 2014 22:15:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx01.qsc.de Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 15 Dec 2014 22:15:28 +0000 Received: from tux.net-b.de (port-92-194-124-106.dynamic.qsc.de [92.194.124.106]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPSA id CD2883CEC8; Mon, 15 Dec 2014 23:15:22 +0100 (CET) Message-ID: <548F5D79.2090700@net-b.de> Date: Mon, 15 Dec 2014 23:15:21 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: gcc-patches , gfortran , FX Subject: [Patch, Fortran] PR54687 - Fortran options cleanup (part 2) This patch is a follow up to https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01068.html and converts more flags to the common diagnostic handing. I think the rest can only be converted by modifiying the *.opt syntax, but I might be wrong. The patch is relative to the Fortran-part approved patch https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01068.html - and fixes some minor issues I found there compared to the old version (e.g. missing ToLower in *opt or < vs. > for fmax-array-constructor). Built and currently regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2014-12-15 Tobias Burnus * lang.opt (fsecond-underscore, frecord-marker=8, frecord-marker=4, frealloc-lhs, freal-8-real-16, freal-8-real-10, freal-8-real-4, freal-4-real-16, freal-4-real-10, freal-4-real-8, fprotect-parens, fstack-arrays, fmax-stack-var-size=, fmax-subrecord-length=, ffrontend-optimize, ffree-line-length-, ffixed-line-length-, finteger-4-integer-8, fdefault-real-8, fdefault-integer-8, fdefault-double-8): Add Var() and Init(). (finit-real=): Add ToLower. * gfortran.h (gfc_option_t): Remove moved flags. * options.c (gfc_init_options, gfc_handle_option): Ditto. (gfc_post_options): Update for name change. * decl.c (gfc_match_old_kind_spec, gfc_match_kind_spec): Handle flag-name change. * frontend-passes.c (gfc_run_passes): Ditto. * module.c (use_iso_fortran_env_module): Ditto. * primary.c (match_integer_constant, match_real_constant): Ditto. * resolve.c (resolve_ordinary_assign): Ditto. * scanner.c (gfc_next_char_literal, load_line): Ditto. * trans-array.c (gfc_trans_allocate_array_storage, gfc_conv_resolve_dependencies, gfc_trans_auto_array_allocation, gfc_conv_ss_startstride): Ditto. * trans-common.c (gfc_sym_mangled_common_id): Ditto. * trans-decl.c (gfc_sym_mangled_function_id, create_main_function): Ditto. * trans-expr.c (gfc_conv_expr_op, gfc_conv_procedure_call, arrayfunc_assign_needs_temporary, gfc_trans_arrayfunc_assign, gfc_trans_assignment_1): Ditto. * trans-stmt.c (gfc_trans_allocate): Ditto. * trans-types.c (gfc_init_kinds): Ditto. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f33d65c..8d01c45 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2140,28 +2140,28 @@ gfc_match_old_kind_spec (gfc_typespec *ts) } - if (ts->type == BT_INTEGER && ts->kind == 4 && gfc_option.flag_integer4_kind == 8) + if (ts->type == BT_INTEGER && ts->kind == 4 && flag_integer4_kind == 8) ts->kind = 8; if (ts->type == BT_REAL || ts->type == BT_COMPLEX) { if (ts->kind == 4) { - if (gfc_option.flag_real4_kind == 8) + if (flag_real4_kind == 8) ts->kind = 8; - if (gfc_option.flag_real4_kind == 10) + if (flag_real4_kind == 10) ts->kind = 10; - if (gfc_option.flag_real4_kind == 16) + if (flag_real4_kind == 16) ts->kind = 16; } if (ts->kind == 8) { - if (gfc_option.flag_real8_kind == 4) + if (flag_real8_kind == 4) ts->kind = 4; - if (gfc_option.flag_real8_kind == 10) + if (flag_real8_kind == 10) ts->kind = 10; - if (gfc_option.flag_real8_kind == 16) + if (flag_real8_kind == 16) ts->kind = 16; } } @@ -2311,28 +2311,28 @@ kind_expr: if(m == MATCH_ERROR) gfc_current_locus = where; - if (ts->type == BT_INTEGER && ts->kind == 4 && gfc_option.flag_integer4_kind == 8) + if (ts->type == BT_INTEGER && ts->kind == 4 && flag_integer4_kind == 8) ts->kind = 8; if (ts->type == BT_REAL || ts->type == BT_COMPLEX) { if (ts->kind == 4) { - if (gfc_option.flag_real4_kind == 8) + if (flag_real4_kind == 8) ts->kind = 8; - if (gfc_option.flag_real4_kind == 10) + if (flag_real4_kind == 10) ts->kind = 10; - if (gfc_option.flag_real4_kind == 16) + if (flag_real4_kind == 16) ts->kind = 16; } if (ts->kind == 8) { - if (gfc_option.flag_real8_kind == 4) + if (flag_real8_kind == 4) ts->kind = 4; - if (gfc_option.flag_real8_kind == 10) + if (flag_real8_kind == 10) ts->kind = 10; - if (gfc_option.flag_real8_kind == 16) + if (flag_real8_kind == 16) ts->kind = 16; } } diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 02f8e89..7d59f2e 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -104,7 +104,7 @@ gfc_run_passes (gfc_namespace *ns) doloop_warn (ns); doloop_list.release (); - if (gfc_option.flag_frontend_optimize) + if (flag_frontend_optimize) { optimize_namespace (ns); optimize_reduction (ns); @@ -376,7 +376,7 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, temporary variable to hold the intermediate result, but only if allocation on assignment is active. */ - if ((*e)->rank > 0 && (*e)->shape == NULL && !gfc_option.flag_realloc_lhs) + if ((*e)->rank > 0 && (*e)->shape == NULL && !flag_realloc_lhs) return 0; /* Skip the test for pure functions if -faggressive-function-elimination diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 23f5bb5..41c6c57 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2406,42 +2406,19 @@ typedef struct { char *module_dir; gfc_source_form source_form; - /* Maximum line lengths in fixed- and free-form source, respectively. - When fixed_line_length or free_line_length are 0, the whole line is used, - regardless of length. - - If the user requests a fixed_line_length <7 then gfc_init_options() - emits a fatal error. */ - int fixed_line_length; - int free_line_length; - /* Maximum number of continuation lines in fixed- and free-form source, - respectively. */ int max_continue_fixed; int max_continue_free; int max_identifier_length; int max_errors; - int flag_default_double; - int flag_default_integer; - int flag_default_real; - int flag_integer4_kind; - int flag_real4_kind; - int flag_real8_kind; - int flag_second_underscore; - int flag_max_stack_var_size; int flag_preprocessed; int flag_d_lines; - int flag_stack_arrays; - int flag_init_local_zero; int flag_init_integer; int flag_init_integer_value; int flag_init_logical; int flag_init_character; char flag_init_character_value; - int flag_protect_parens; - int flag_realloc_lhs; - int flag_frontend_optimize; int fpe; int fpe_summary; @@ -2449,8 +2426,6 @@ typedef struct int warn_std; int allow_std; - int record_marker; - int max_subrecord_length; } gfc_option_t; diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index a5f43d1..95be3658 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -413,15 +413,15 @@ Fortran RejectNegative Treat lines with 'D' in column one as comments fdefault-double-8 -Fortran +Fortran Var(flag_default_double) Set the default double precision kind to an 8 byte wide type fdefault-integer-8 -Fortran +Fortran Var(flag_default_integer) Set the default integer kind to an 8 byte wide type fdefault-real-8 -Fortran +Fortran Var(flag_default_real) Set the default real kind to an 8 byte wide type fdollar-ok @@ -457,7 +457,7 @@ Fortran RejectNegative Assume that the source file is fixed form finteger-4-integer-8 -Fortran RejectNegative +Fortran RejectNegative Var(flag_integer4_kind,8) Interpret any INTEGER(4) as an INTEGER(8) fintrinsic-modules-path @@ -469,11 +469,11 @@ Fortran RejectNegative Joined Specify where to find the compiled intrinsic modules ffixed-line-length-none -Fortran RejectNegative +Fortran RejectNegative Var(flag_fixed_line_length,0) Allow arbitrary character line width in fixed mode ffixed-line-length- -Fortran RejectNegative Joined UInteger +Fortran RejectNegative Joined UInteger Var(flag_fixed_line_length) Init(72) -ffixed-line-length- Use n as character line width in fixed mode ffpe-trap= @@ -489,15 +489,15 @@ Fortran RejectNegative Assume that the source file is free form ffree-line-length-none -Fortran RejectNegative +Fortran RejectNegative Var(flag_free_line_length,0) Allow arbitrary character line width in free mode ffree-line-length- -Fortran RejectNegative Joined UInteger +Fortran RejectNegative Joined UInteger Var(flag_free_line_length) Init(132) -ffree-line-length- Use n as character line width in free mode ffrontend-optimize -Fortran +Fortran Var(flag_frontend_optimize) Init(-1) Enable front end optimization fimplicit-none @@ -521,7 +521,7 @@ Fortran RejectNegative Joined -finit-logical= Initialize local logical variables finit-real= -Fortran RejectNegative Joined Enum(gfc_init_local_real) Var(flag_init_real) Init(GFC_INIT_REAL_OFF) +Fortran RejectNegative ToLower Joined Enum(gfc_init_local_real) Var(flag_init_real) Init(GFC_INIT_REAL_OFF) -finit-real= Initialize local real variables Enum @@ -551,15 +551,15 @@ Fortran RejectNegative Joined UInteger -fmax-identifier-length= Maximum identifier length fmax-subrecord-length= -Fortran RejectNegative Joined UInteger +Fortran RejectNegative Joined UInteger Var(flag_max_subrecord_length) -fmax-subrecord-length= Maximum length for subrecords fmax-stack-var-size= -Fortran RejectNegative Joined UInteger +Fortran RejectNegative Joined UInteger Var(flag_max_stack_var_size) Init(-2) -fmax-stack-var-size= Size in bytes of the largest array that will be put on the stack fstack-arrays -Fortran +Fortran Var(flag_stack_arrays) Init(-1) Put all local arrays on stack. fmodule-private @@ -583,7 +583,7 @@ Fortran ; Documented in C fprotect-parens -Fortran +Fortran Var(flag_protect_parens) Init(-1) Protect parentheses in expressions frange-check @@ -591,39 +591,39 @@ Fortran Var(flag_range_check) Init(1) Enable range checking during compilation freal-4-real-8 -Fortran RejectNegative +Fortran RejectNegative Var(flag_real4_kind,8) Interpret any REAL(4) as a REAL(8) freal-4-real-10 -Fortran RejectNegative +Fortran RejectNegative Var(flag_real4_kind,10) Interpret any REAL(4) as a REAL(10) freal-4-real-16 -Fortran RejectNegative +Fortran RejectNegative Var(flag_real4_kind,16) Interpret any REAL(4) as a REAL(16) freal-8-real-4 -Fortran RejectNegative +Fortran RejectNegative Var(flag_real8_kind,4) Interpret any REAL(8) as a REAL(4) freal-8-real-10 -Fortran RejectNegative +Fortran RejectNegative Var(flag_real8_kind,10) Interpret any REAL(8) as a REAL(10) freal-8-real-16 -Fortran RejectNegative +Fortran RejectNegative Var(flag_real8_kind,16) Interpret any REAL(8) as a REAL(16) frealloc-lhs -Fortran +Fortran Var(flag_realloc_lhs) Init(-1) Reallocate the LHS in assignments frecord-marker=4 -Fortran RejectNegative +Fortran RejectNegative Var(flag_record_marker,4) Use a 4-byte record marker for unformatted files frecord-marker=8 -Fortran RejectNegative +Fortran RejectNegative Var(flag_record_marker,8) Use an 8-byte record marker for unformatted files frecursive @@ -655,7 +655,7 @@ Fortran RejectNegative JoinedOrMissing -fcheck=[...] Specify which runtime checks are to be performed fsecond-underscore -Fortran +Fortran Var(flag_second_underscore) Init(-1) Append a second underscore if the name already contains an underscore fshort-enums diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 53ebb55..f6e5eec 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -6597,13 +6597,13 @@ use_iso_fortran_env_module (void) "standard", symbol[i].name, &u->where)) continue; - if ((gfc_option.flag_default_integer || gfc_option.flag_default_real) + if ((flag_default_integer || flag_default_real) && symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE) gfc_warning_now ("Use of the NUMERIC_STORAGE_SIZE named " "constant from intrinsic module " "ISO_FORTRAN_ENV at %L is incompatible with " "option %qs", &u->where, - gfc_option.flag_default_integer + flag_default_integer ? "-fdefault-integer-8" : "-fdefault-real-8"); switch (symbol[i].id) @@ -6664,12 +6664,12 @@ use_iso_fortran_env_module (void) if ((gfc_option.allow_std & symbol[i].standard) == 0) continue; - if ((gfc_option.flag_default_integer || gfc_option.flag_default_real) + if ((flag_default_integer || flag_default_real) && symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE) gfc_warning_now ("Use of the NUMERIC_STORAGE_SIZE named constant " "from intrinsic module ISO_FORTRAN_ENV at %C is " "incompatible with option %s", - gfc_option.flag_default_integer + flag_default_integer ? "-fdefault-integer-8" : "-fdefault-real-8"); switch (symbol[i].id) diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index b0adb1b..6543481 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -81,28 +81,12 @@ gfc_init_options (unsigned int decoded_options_count, gfc_source_file = NULL; gfc_option.module_dir = NULL; gfc_option.source_form = FORM_UNKNOWN; - gfc_option.fixed_line_length = 72; - gfc_option.free_line_length = 132; gfc_option.max_continue_fixed = 255; gfc_option.max_continue_free = 255; gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN; - gfc_option.max_subrecord_length = 0; - gfc_option.record_marker = 0; gfc_option.max_errors = 25; - gfc_option.flag_default_double = 0; - gfc_option.flag_default_integer = 0; - gfc_option.flag_default_real = 0; - gfc_option.flag_integer4_kind = 0; - gfc_option.flag_real4_kind = 0; - gfc_option.flag_real8_kind = 0; - gfc_option.flag_second_underscore = -1; - - /* Default value of flag_max_stack_var_size is set in gfc_post_options. */ - gfc_option.flag_max_stack_var_size = -2; - gfc_option.flag_stack_arrays = -1; - gfc_option.flag_preprocessed = 0; gfc_option.flag_d_lines = -1; gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF; @@ -110,9 +94,6 @@ gfc_init_options (unsigned int decoded_options_count, gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF; gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF; gfc_option.flag_init_character_value = (char)0; - gfc_option.flag_protect_parens = -1; - gfc_option.flag_realloc_lhs = -1; - gfc_option.flag_frontend_optimize = -1; gfc_option.fpe = 0; /* All except GFC_FPE_INEXACT. */ @@ -232,20 +213,20 @@ gfc_post_options (const char **pfilename) if (flag_associative_math == -1) flag_associative_math = (!flag_trapping_math && !flag_signed_zeros); - if (gfc_option.flag_protect_parens == -1) - gfc_option.flag_protect_parens = !optimize_fast; + if (flag_protect_parens == -1) + flag_protect_parens = !optimize_fast; - if (gfc_option.flag_stack_arrays == -1) - gfc_option.flag_stack_arrays = optimize_fast; + if (flag_stack_arrays == -1) + flag_stack_arrays = optimize_fast; /* By default, disable (re)allocation during assignment for -std=f95, and enable it for F2003/F2008/GNU/Legacy. */ - if (gfc_option.flag_realloc_lhs == -1) + if (flag_realloc_lhs == -1) { if (gfc_option.allow_std & GFC_STD_F2003) - gfc_option.flag_realloc_lhs = 1; + flag_realloc_lhs = 1; else - gfc_option.flag_realloc_lhs = 0; + flag_realloc_lhs = 0; } /* -fbounds-check is equivalent to -fcheck=bounds */ @@ -337,55 +318,63 @@ gfc_post_options (const char **pfilename) /* If the user didn't explicitly specify -f(no)-second-underscore we use it if we're trying to be compatible with f2c, and not otherwise. */ - if (gfc_option.flag_second_underscore == -1) - gfc_option.flag_second_underscore = flag_f2c; + if (flag_second_underscore == -1) + flag_second_underscore = flag_f2c; - if (!flag_automatic && gfc_option.flag_max_stack_var_size != -2 - && gfc_option.flag_max_stack_var_size != 0) + if (!flag_automatic && flag_max_stack_var_size != -2 + && flag_max_stack_var_size != 0) gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>", - gfc_option.flag_max_stack_var_size); + flag_max_stack_var_size); else if (!flag_automatic && flag_recursive) gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-frecursive%>"); else if (!flag_automatic && flag_openmp) gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by " "%<-fopenmp%>"); - else if (gfc_option.flag_max_stack_var_size != -2 && flag_recursive) + else if (flag_max_stack_var_size != -2 && flag_recursive) gfc_warning_now ("Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>", - gfc_option.flag_max_stack_var_size); - else if (gfc_option.flag_max_stack_var_size != -2 && flag_openmp) + flag_max_stack_var_size); + else if (flag_max_stack_var_size != -2 && flag_openmp) gfc_warning_now ("Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> " - "implied by %<-fopenmp%>", - gfc_option.flag_max_stack_var_size); + "implied by %<-fopenmp%>", flag_max_stack_var_size); /* Implement -frecursive as -fmax-stack-var-size=-1. */ if (flag_recursive) - gfc_option.flag_max_stack_var_size = -1; + flag_max_stack_var_size = -1; /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */ - if (gfc_option.flag_max_stack_var_size == -2 && flag_openmp - && flag_automatic) + if (flag_max_stack_var_size == -2 && flag_openmp && flag_automatic) { flag_recursive = 1; - gfc_option.flag_max_stack_var_size = -1; + flag_max_stack_var_size = -1; } /* Set default. */ - if (gfc_option.flag_max_stack_var_size == -2) - gfc_option.flag_max_stack_var_size = 32768; + if (flag_max_stack_var_size == -2) + flag_max_stack_var_size = 32768; /* Implement -fno-automatic as -fmax-stack-var-size=0. */ if (!flag_automatic) - gfc_option.flag_max_stack_var_size = 0; + flag_max_stack_var_size = 0; /* Optimization implies front end optimization, unless the user specified it directly. */ - if (gfc_option.flag_frontend_optimize == -1) - gfc_option.flag_frontend_optimize = optimize; + if (flag_frontend_optimize == -1) + flag_frontend_optimize = optimize; - if (flag_max_array_constructor > 65535) + if (flag_max_array_constructor < 65535) flag_max_array_constructor = 65535; + if (flag_fixed_line_length != 0 && flag_fixed_line_length < 7) + gfc_fatal_error ("Fixed line length must be at least seven"); + + if (flag_free_line_length != 0 && flag_free_line_length < 4) + gfc_fatal_error ("Free line length must be at least three"); + + if (flag_max_subrecord_length > MAX_SUBRECORD_LENGTH) + gfc_fatal_error ("Maximum subrecord length cannot exceed %d", + MAX_SUBRECORD_LENGTH); + gfc_cpp_post_options (); return gfc_cpp_preprocess_only (); @@ -554,34 +543,10 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.source_form = FORM_FIXED; break; - case OPT_ffixed_line_length_none: - gfc_option.fixed_line_length = 0; - break; - - case OPT_ffixed_line_length_: - if (value != 0 && value < 7) - gfc_fatal_error ("Fixed line length must be at least seven"); - gfc_option.fixed_line_length = value; - break; - case OPT_ffree_form: gfc_option.source_form = FORM_FREE; break; - case OPT_ffree_line_length_none: - gfc_option.free_line_length = 0; - break; - - case OPT_ffree_line_length_: - if (value != 0 && value < 4) - gfc_fatal_error ("Free line length must be at least three"); - gfc_option.free_line_length = value; - break; - - case OPT_fsecond_underscore: - gfc_option.flag_second_underscore = value; - break; - case OPT_static_libgfortran: #ifndef HAVE_LD_STATIC_DYNAMIC gfc_fatal_error ("%<-static-libgfortran%> is not supported in this " @@ -601,14 +566,6 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_add_intrinsic_modules_path (arg); break; - case OPT_fmax_stack_var_size_: - gfc_option.flag_max_stack_var_size = value; - break; - - case OPT_fstack_arrays: - gfc_option.flag_stack_arrays = value; - break; - case OPT_fpreprocessed: gfc_option.flag_preprocessed = value; break; @@ -620,49 +577,10 @@ gfc_handle_option (size_t scode, const char *arg, int value, gfc_option.max_identifier_length = value; break; - case OPT_fdefault_integer_8: - gfc_option.flag_default_integer = value; - break; - - case OPT_fdefault_real_8: - gfc_option.flag_default_real = value; - break; - - case OPT_fdefault_double_8: - gfc_option.flag_default_double = value; - break; - - case OPT_finteger_4_integer_8: - gfc_option.flag_integer4_kind = 8; - break; - - case OPT_freal_4_real_8: - gfc_option.flag_real4_kind = 8; - break; - - case OPT_freal_4_real_10: - gfc_option.flag_real4_kind = 10; - break; - - case OPT_freal_4_real_16: - gfc_option.flag_real4_kind = 16; - break; - - case OPT_freal_8_real_4: - gfc_option.flag_real8_kind = 4; - break; - - case OPT_freal_8_real_10: - gfc_option.flag_real8_kind = 10; - break; - - case OPT_freal_8_real_16: - gfc_option.flag_real8_kind = 16; - break; - case OPT_finit_local_zero: gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; gfc_option.flag_init_integer_value = 0; + flag_init_real = GFC_INIT_REAL_ZERO; gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE; gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON; gfc_option.flag_init_character_value = (char)0; @@ -762,34 +680,6 @@ gfc_handle_option (size_t scode, const char *arg, int value, /* Handled in language-independent code. */ break; - case OPT_frecord_marker_4: - gfc_option.record_marker = 4; - break; - - case OPT_frecord_marker_8: - gfc_option.record_marker = 8; - break; - - case OPT_fmax_subrecord_length_: - if (value > MAX_SUBRECORD_LENGTH) - gfc_fatal_error ("Maximum subrecord length cannot exceed %d", - MAX_SUBRECORD_LENGTH); - - gfc_option.max_subrecord_length = value; - break; - - case OPT_ffrontend_optimize: - gfc_option.flag_frontend_optimize = value; - break; - - case OPT_fprotect_parens: - gfc_option.flag_protect_parens = value; - break; - - case OPT_frealloc_lhs: - gfc_option.flag_realloc_lhs = value; - break; - case OPT_fcheck_: gfc_handle_runtime_check_option (arg); break; diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 71f0b7d..77522e5 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -224,7 +224,7 @@ match_integer_constant (gfc_expr **result, int signflag) if (kind == -1) return MATCH_ERROR; - if (kind == 4 && gfc_option.flag_integer4_kind == 8) + if (kind == 4 && flag_integer4_kind == 8) kind = 8; if (gfc_validate_kind (BT_INTEGER, kind, true) < 0) @@ -639,21 +639,21 @@ done: if (kind == 4) { - if (gfc_option.flag_real4_kind == 8) + if (flag_real4_kind == 8) kind = 8; - if (gfc_option.flag_real4_kind == 10) + if (flag_real4_kind == 10) kind = 10; - if (gfc_option.flag_real4_kind == 16) + if (flag_real4_kind == 16) kind = 16; } if (kind == 8) { - if (gfc_option.flag_real8_kind == 4) + if (flag_real8_kind == 4) kind = 4; - if (gfc_option.flag_real8_kind == 10) + if (flag_real8_kind == 10) kind = 10; - if (gfc_option.flag_real8_kind == 16) + if (flag_real8_kind == 16) kind = 16; } break; @@ -688,21 +688,21 @@ done: if (kind == 4) { - if (gfc_option.flag_real4_kind == 8) + if (flag_real4_kind == 8) kind = 8; - if (gfc_option.flag_real4_kind == 10) + if (flag_real4_kind == 10) kind = 10; - if (gfc_option.flag_real4_kind == 16) + if (flag_real4_kind == 16) kind = 16; } if (kind == 8) { - if (gfc_option.flag_real8_kind == 4) + if (flag_real8_kind == 4) kind = 4; - if (gfc_option.flag_real8_kind == 10) + if (flag_real8_kind == 10) kind = 10; - if (gfc_option.flag_real8_kind == 16) + if (flag_real8_kind == 16) kind = 16; } diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index c4ce247..b180e18 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9352,7 +9352,7 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns) if (!gfc_notify_std (GFC_STD_F2008, "Assignment to an allocatable " "polymorphic variable at %L", &lhs->where)) return false; - if (!gfc_option.flag_realloc_lhs) + if (!flag_realloc_lhs) { gfc_error ("Assignment to an allocatable polymorphic variable at %L " "requires %<-frealloc-lhs%>", &lhs->where); @@ -10777,7 +10777,7 @@ build_default_init_expr (gfc_symbol *sym) init_expr = NULL; } if (!init_expr && gfc_option.flag_init_character == GFC_INIT_CHARACTER_ON - && sym->ts.u.cl->length && gfc_option.flag_max_stack_var_size != 0) + && sym->ts.u.cl->length && flag_max_stack_var_size != 0) { gfc_actual_arglist *arg; init_expr = gfc_get_expr (); @@ -10827,7 +10827,7 @@ apply_default_init_local (gfc_symbol *sym) are stack allocated even with -fno-automatic; we have also to exclude result variable, which are also nonstatic. */ if (sym->attr.save || sym->ns->save_all - || (gfc_option.flag_max_stack_var_size == 0 && !sym->attr.result + || (flag_max_stack_var_size == 0 && !sym->attr.result && !sym->ns->proc_name->attr.recursive && (!sym->attr.dimension || !is_non_constant_shape_array (sym)))) { diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index deeb594..d6b9bbf 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -1050,7 +1050,7 @@ restart: if (warn_line_truncation && gfc_current_locus.lb != NULL && gfc_current_locus.lb->truncated) { - int maxlen = gfc_option.free_line_length; + int maxlen = flag_free_line_length; gfc_char_t *current_nextc = gfc_current_locus.nextc; gfc_current_locus.lb->truncated = 0; @@ -1433,9 +1433,9 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char) /* Determine the maximum allowed line length. */ if (gfc_current_form == FORM_FREE) - maxlen = gfc_option.free_line_length; + maxlen = flag_free_line_length; else if (gfc_current_form == FORM_FIXED) - maxlen = gfc_option.fixed_line_length; + maxlen = flag_fixed_line_length; else maxlen = 72; @@ -1609,7 +1609,7 @@ next_char: /* Pad lines to the selected line length in fixed form. */ if (gfc_current_form == FORM_FIXED - && gfc_option.fixed_line_length != 0 + && flag_fixed_line_length != 0 && !preprocessor_flag && c != EOF) { diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 22309a0..e061dcf 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -830,7 +830,7 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, { /* Allocate the temporary. */ onstack = !dynamic && initial == NULL_TREE - && (gfc_option.flag_stack_arrays + && (flag_stack_arrays || gfc_can_put_var_on_stack (size)); if (onstack) @@ -3950,7 +3950,7 @@ done: continue; /* Catch allocatable lhs in f2003. */ - if (gfc_option.flag_realloc_lhs && ss->is_alloc_lhs) + if (flag_realloc_lhs && ss->is_alloc_lhs) continue; expr = ss_info->expr; @@ -4349,7 +4349,7 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest, if (ss->info->type != GFC_SS_SECTION) { - if (gfc_option.flag_realloc_lhs + if (flag_realloc_lhs && dest_expr != ss_expr && gfc_is_reallocatable_lhs (dest_expr) && ss_expr->rank) @@ -5700,7 +5700,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, return; } - if (gfc_option.flag_stack_arrays) + if (flag_stack_arrays) { gcc_assert (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE); space = build_decl (sym->declared_at.lb->location, diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index fe16f5c..a7ae714 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -257,7 +257,7 @@ gfc_sym_mangled_common_id (gfc_common_head *com) if (flag_underscoring) { has_underscore = strchr (name, '_') != 0; - if (gfc_option.flag_second_underscore && has_underscore) + if (flag_second_underscore && has_underscore) snprintf (mangled_name, sizeof mangled_name, "%s__", name); else snprintf (mangled_name, sizeof mangled_name, "%s_", name); diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index a92b253..494d8aa 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -396,7 +396,7 @@ gfc_sym_mangled_function_id (gfc_symbol * sym) if (flag_underscoring) { has_underscore = strchr (sym->name, '_') != 0; - if (gfc_option.flag_second_underscore && has_underscore) + if (flag_second_underscore && has_underscore) snprintf (name, sizeof name, "%s__", sym->name); else snprintf (name, sizeof name, "%s_", sym->name); @@ -431,14 +431,14 @@ gfc_can_put_var_on_stack (tree size) if (!INTEGER_CST_P (size)) return 0; - if (gfc_option.flag_max_stack_var_size < 0) + if (flag_max_stack_var_size < 0) return 1; if (!tree_fits_uhwi_p (size)) return 0; low = TREE_INT_CST_LOW (size); - if (low > (unsigned HOST_WIDE_INT) gfc_option.flag_max_stack_var_size) + if (low > (unsigned HOST_WIDE_INT) flag_max_stack_var_size) return 0; /* TODO: Set a per-function stack size limit. */ @@ -1148,7 +1148,7 @@ gfc_create_string_length (gfc_symbol * sym) it is an automatic variable. */ bool static_length = sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE - || (gfc_option.flag_max_stack_var_size == 0 + || (flag_max_stack_var_size == 0 && sym->ts.deferred && !sym->attr.dummy && !sym->attr.result && !sym->attr.function); @@ -1546,7 +1546,7 @@ gfc_get_symbol_decl (gfc_symbol * sym) if (TREE_STATIC (decl) && !(sym->attr.use_assoc && !intrinsic_array_parameter) && (sym->attr.save || sym->ns->proc_name->attr.is_main_program - || gfc_option.flag_max_stack_var_size == 0 + || flag_max_stack_var_size == 0 || sym->attr.data || sym->ns->proc_name->attr.flavor == FL_MODULE) && (flag_coarray != GFC_FCOARRAY_LIB || !sym->attr.codimension || sym->attr.allocatable)) @@ -3873,7 +3873,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) } if (sym->ts.type == BT_CLASS - && (sym->attr.save || gfc_option.flag_max_stack_var_size == 0) + && (sym->attr.save || flag_max_stack_var_size == 0) && CLASS_DATA (sym)->attr.allocatable) { tree vptr; @@ -4002,7 +4002,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->attr.allocatable))) { - if (!sym->attr.save && gfc_option.flag_max_stack_var_size != 0) + if (!sym->attr.save && flag_max_stack_var_size != 0) { tree descriptor = NULL_TREE; @@ -5487,21 +5487,21 @@ create_main_function (tree fndecl) /* If this is the main program and an -frecord-marker option was provided, add a call to set_record_marker. */ - if (gfc_option.record_marker != 0) + if (flag_record_marker != 0) { tmp = build_call_expr_loc (input_location, gfor_fndecl_set_record_marker, 1, build_int_cst (integer_type_node, - gfc_option.record_marker)); + flag_record_marker)); gfc_add_expr_to_block (&body, tmp); } - if (gfc_option.max_subrecord_length != 0) + if (flag_max_subrecord_length != 0) { tmp = build_call_expr_loc (input_location, gfor_fndecl_set_max_subrecord_length, 1, build_int_cst (integer_type_node, - gfc_option.max_subrecord_length)); + flag_max_subrecord_length)); gfc_add_expr_to_block (&body, tmp); } diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 44a2b07..7772dca 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -2653,9 +2653,8 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr) switch (expr->value.op.op) { case INTRINSIC_PARENTHESES: - if ((expr->ts.type == BT_REAL - || expr->ts.type == BT_COMPLEX) - && gfc_option.flag_protect_parens) + if ((expr->ts.type == BT_REAL || expr->ts.type == BT_COMPLEX) + && flag_protect_parens) { gfc_conv_unary_op (PAREN_EXPR, se, expr); gcc_assert (FLOAT_TYPE_P (TREE_TYPE (se->expr))); @@ -5176,7 +5175,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, /* If the lhs of an assignment x = f(..) is allocatable and f2003 is allowed, we must do the automatic reallocation. TODO - deal with intrinsics, without using a temporary. */ - if (gfc_option.flag_realloc_lhs + if (flag_realloc_lhs && se->ss && se->ss->loop_chain && se->ss->loop_chain->is_alloc_lhs && !expr->value.function.isym @@ -5214,8 +5213,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, f2003 is allowed, we must not generate the function call here but should just send back the results of the mapping. This is signalled by the function ss being flagged. */ - if (gfc_option.flag_realloc_lhs - && se->ss && se->ss->is_alloc_lhs) + if (flag_realloc_lhs && se->ss && se->ss->is_alloc_lhs) { gfc_free_interface_mapping (&mapping); return has_alternate_specifier; @@ -5250,8 +5248,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, f2003 is allowed, we must not generate the function call here but should just send back the results of the mapping. This is signalled by the function ss being flagged. */ - if (gfc_option.flag_realloc_lhs - && se->ss && se->ss->is_alloc_lhs) + if (flag_realloc_lhs && se->ss && se->ss->is_alloc_lhs) { gfc_free_interface_mapping (&mapping); return has_alternate_specifier; @@ -7409,9 +7406,7 @@ arrayfunc_assign_needs_temporary (gfc_expr * expr1, gfc_expr * expr2) need a temporary except in the particular case that reallocation on assignment is active and the lhs is allocatable and a target. */ if (expr2->value.function.isym) - return (gfc_option.flag_realloc_lhs - && sym->attr.allocatable - && sym->attr.target); + return (flag_realloc_lhs && sym->attr.allocatable && sym->attr.target); /* If the LHS is a dummy, we need a temporary if it is not INTENT(OUT). */ @@ -7652,7 +7647,7 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2) calls, the array data is freed and the library takes care of allocation. TODO: Add logic of trans-array.c: gfc_alloc_allocatable_for_assignment to the library. */ - if (gfc_option.flag_realloc_lhs + if (flag_realloc_lhs && gfc_is_reallocatable_lhs (expr1) && !gfc_expr_attr (expr1).codimension && !gfc_is_coindexed (expr1) @@ -8312,8 +8307,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, otherwise the character length of the result is not known. NOTE: This relies on having the exact dependence of the length type parameter available to the caller; gfortran saves it in the .mod files. */ - if (gfc_option.flag_realloc_lhs && expr2->ts.type == BT_CHARACTER - && expr1->ts.deferred) + if (flag_realloc_lhs && expr2->ts.type == BT_CHARACTER && expr1->ts.deferred) gfc_add_block_to_block (&block, &rse.pre); tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, @@ -8325,8 +8319,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, if (lss == gfc_ss_terminator) { /* F2003: Add the code for reallocation on assignment. */ - if (gfc_option.flag_realloc_lhs - && is_scalar_reallocatable_lhs (expr1)) + if (flag_realloc_lhs && is_scalar_reallocatable_lhs (expr1)) alloc_scalar_allocatable_for_assignment (&block, rse.string_length, expr1, expr2); @@ -8366,7 +8359,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, } /* F2003: Allocate or reallocate lhs of allocatable array. */ - if (gfc_option.flag_realloc_lhs + if (flag_realloc_lhs && gfc_is_reallocatable_lhs (expr1) && !gfc_expr_attr (expr1).codimension && !gfc_is_coindexed (expr1) diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 985fc0b..47edd32 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5328,11 +5328,11 @@ gfc_trans_allocate (gfc_code * code) { /* Switch off automatic reallocation since we have just done the ALLOCATE. */ - int realloc_lhs = gfc_option.flag_realloc_lhs; - gfc_option.flag_realloc_lhs = 0; + int realloc_lhs = flag_realloc_lhs; + flag_realloc_lhs = 0; tmp = gfc_trans_assignment (gfc_expr_to_initialize (expr), rhs, false, false); - gfc_option.flag_realloc_lhs = realloc_lhs; + flag_realloc_lhs = realloc_lhs; } gfc_free_expr (rhs); gfc_add_expr_to_block (&block, tmp); diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index b14edb1..9bf08038 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -493,7 +493,7 @@ gfc_init_kinds (void) gfc_numeric_storage_size = 4 * 8; - if (gfc_option.flag_default_integer) + if (flag_default_integer) { if (!saw_i8) gfc_fatal_error ("INTEGER(KIND=8) is not available for " @@ -502,7 +502,7 @@ gfc_init_kinds (void) gfc_default_integer_kind = 8; } - else if (gfc_option.flag_integer4_kind == 8) + else if (flag_integer4_kind == 8) { if (!saw_i8) gfc_fatal_error ("INTEGER(KIND=8) is not available for " @@ -521,7 +521,7 @@ gfc_init_kinds (void) } /* Choose the default real kind. Again, we choose 4 when possible. */ - if (gfc_option.flag_default_real) + if (flag_default_real) { if (!saw_r8) gfc_fatal_error ("REAL(KIND=8) is not available for " @@ -529,7 +529,7 @@ gfc_init_kinds (void) gfc_default_real_kind = 8; } - else if (gfc_option.flag_real4_kind == 8) + else if (flag_real4_kind == 8) { if (!saw_r8) gfc_fatal_error ("REAL(KIND=8) is not available for %<-freal-4-real-8%> " @@ -537,7 +537,7 @@ gfc_init_kinds (void) gfc_default_real_kind = 8; } - else if (gfc_option.flag_real4_kind == 10) + else if (flag_real4_kind == 10) { if (!saw_r10) gfc_fatal_error ("REAL(KIND=10) is not available for " @@ -545,7 +545,7 @@ gfc_init_kinds (void) gfc_default_real_kind = 10; } - else if (gfc_option.flag_real4_kind == 16) + else if (flag_real4_kind == 16) { if (!saw_r16) gfc_fatal_error ("REAL(KIND=16) is not available for " @@ -562,15 +562,15 @@ gfc_init_kinds (void) are specified, we use kind=8, if it's available. If -fdefault-real is specified without -fdefault-double, we use kind=16, if it's available. Otherwise we do not change anything. */ - if (gfc_option.flag_default_double && !gfc_option.flag_default_real) + if (flag_default_double && !flag_default_real) gfc_fatal_error ("Use of %<-fdefault-double-8%> requires " "%<-fdefault-real-8%>"); - if (gfc_option.flag_default_real && gfc_option.flag_default_double && saw_r8) + if (flag_default_real && flag_default_double && saw_r8) gfc_default_double_kind = 8; - else if (gfc_option.flag_default_real && saw_r16) + else if (flag_default_real && saw_r16) gfc_default_double_kind = 16; - else if (gfc_option.flag_real8_kind == 4) + else if (flag_real8_kind == 4) { if (!saw_r4) gfc_fatal_error ("REAL(KIND=4) is not available for " @@ -578,7 +578,7 @@ gfc_init_kinds (void) gfc_default_double_kind = 4; } - else if (gfc_option.flag_real8_kind == 10 ) + else if (flag_real8_kind == 10 ) { if (!saw_r10) gfc_fatal_error ("REAL(KIND=10) is not available for " @@ -586,7 +586,7 @@ gfc_init_kinds (void) gfc_default_double_kind = 10; } - else if (gfc_option.flag_real8_kind == 16 ) + else if (flag_real8_kind == 16 ) { if (!saw_r16) gfc_fatal_error ("REAL(KIND=10) is not available for "