aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
2025-08-11Fix comment typosJakub Jelinek1-1/+1
This patch fixes some comment typos, singe -> single and unsinged -> unsigned. 2025-08-11 Jakub Jelinek <jakub@redhat.com> gcc/ * tree-cfg.cc (find_case_label_for_value): Fix comment typo, singe-valued -> single-valued. * config/arc/arc.md: Fix comment typos, unsinged -> unsigned. gcc/fortran/ * gfortran.h (gfc_case): Fix comment typo, singe -> single. gcc/testsuite/ * g++.dg/warn/template-1.C: Fix comment typo, unsinged -> unsigned. * gcc.target/powerpc/builtins-2-p9-runnable.c (main): Likewise. * gcc.dg/graphite/id-30.c: Likewise.
2025-08-10Daily bump.GCC Administrator1-0/+15
2025-08-09Fortran: Correct wrong PR numbersPaul Thomas1-1/+1
2025-08-09Fortran: F2018 GENERIC statement is missing [PR121182]Paul Thomas2-2/+317
2025-08-09 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/121182 * decl.cc (match_generic_stmt): New function based on original gfc_match_generic but feeding namespace rather than typebound generics. (match_typebound_generic): Renamed original gfc_match_generic. (gfc_match_generic): New function that selects between type bound generic and other generic statements and calls one of the above two functions as appropriate. * parse.cc (decode_specification_statement): Allow generic statements. (parse_spec): Accept a generic statement in a specification block. gcc/testsuite/ PR fortran/121182 * gfortran.dg/generic_stmt_1.f90: New test. * gfortran.dg/generic_stmt_2.f90: New test. * gfortran.dg/generic_stmt_3.f90: New test. * gfortran.dg/generic_stmt_4.f90: New test.
2025-08-06Daily bump.GCC Administrator1-0/+65
2025-08-05fortran: Remove overwrite of polymorphic associate variable offsetMikael Morin1-18/+0
The array descriptor returned by gfc_conv_expr_descriptor should be usable as is. No need to overwrite the offset. gcc/fortran/ChangeLog: * trans-stmt.cc (trans_associate_var): Remove overwrite of the polymorphic associate variable's array descriptor offset.
2025-08-05fortran: Remove array bound update after constructor expansionMikael Morin1-1/+0
The array constructor expansion extends the size of the array dynamically, and sets the upper bound appropriately every time it does. There is no need to do it again at the end of expansion. gcc/fortran/ChangeLog: * trans-array.cc (trans_array_constructor): Remove the update of the array descriptor upper bound after array constructor expansion.
2025-08-05fortran: Remove premature initialization of a function result's spanMikael Morin1-8/+0
Setting just the span in an otherwise uninitialized array descriptor to pass to a function that will use the descriptor for its result (thus do the initialization) doesn't seem to be useful. gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_expr_descriptor): Remove isolated initialization of the span field before passing to the function that will do the initialization.
2025-08-05fortran: Remove default initialization of local pointers's spanMikael Morin1-14/+0
A pointer has no default initialization; it is invalid to use it before it is associated to a target. We can just as well leave its span field uninitialized, and wait for the first pointer association to define a span value. The value of zero was an invalid span value anyway. gcc/fortran/ChangeLog: * trans-decl.cc (gfc_trans_deferred_vars): Don't default initialize the span of local pointer arrays.
2025-08-05fortran: Remove redundant initialisation of associate variable spanMikael Morin1-10/+0
In the initialization of associate variable array descriptors, remove an overwrite of the span field. The descriptor that is returned by gfc_conv_expr_descriptor should already be usable without it. The range of cases where the code was in effect is not completely clear. The span overwrite looks redundant, and the conditional guarding it seems to make it dead. However, the conditions governing gfc_conv_expr_descriptor, gfc_get_array_span and trans_associate_var make it difficult to track what is possible and what isn't. Trying to investigate the case where the target is an array subreference wrapped in parenthesis, I encountered a wrong-code issue, PR121384. Let's remove all this and see what happens. gcc/fortran/ChangeLog: * trans-stmt.cc (trans_associate_var): Remove overwrite of the span field of the associate variable's array descriptor.
2025-08-05fortran: Remove span overwrite with pointer assignmentsMikael Morin1-5/+0
Remove an overwrite of the array descriptor span field when pointer- assigning from a polymorphic function result to a non-polymorphic pointer. That overwrite doesn't make sense because the span is determined by the memory layout of the array; we can't change it without also changing the data pointer. gcc/fortran/ChangeLog: * trans-expr.cc (gfc_trans_pointer_assignment): Remove overwrite of the span after assignment of the array descriptor in the polymorphic function result to non-polymorphic pointer case. gcc/testsuite/ChangeLog: * gfortran.dg/pointer_assign_16.f90: New test.
2025-08-05fortran: Remove unused field use_offsetMikael Morin3-7/+0
The gfc_se::use_offset field is set in a few places, but is nowhere used. Remove it. gcc/fortran/ChangeLog: * trans.h (gfc_se): Remove field use_offset. * trans-expr.cc (gfc_conv_intrinsic_to_class): Remove use_offset initialization. (gfc_conv_procedure_call): Likewise. * trans-stmt.cc (trans_associate_var): Likewise.
2025-08-05fortran: Use array descriptor offset setter when possibleMikael Morin2-6/+5
Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- In some places, a write to an array descriptor offset field was generated simply by adding a modification of a reference to it that was already available. This change uses the existing setter function instead in those places, to generate the same code. It makes it more explicit that in those areas a write to the field is generated. gcc/fortran/ChangeLog: * trans-array.cc (gfc_alloc_allocatable_for_assignment): Use the offset setter instead of generating a write to the offset. (gfc_conv_array_parameter): Use the offset setter instead of generating a write to the value returned by the offset getter. * trans-expr.cc (gfc_trans_alloc_subarray_assign): Likewise.
2025-08-05fortran: Remove array descriptor data address accessor functionMikael Morin3-13/+1
Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- The function gfc_conv_descriptor_data_addr generates an address to the data field of an array descriptor. It is only used once, and in the single place where it is used, the address is immediately dereferenced. This change replaces the single usage with a plain access to the data field, and removes the function. As the previous patch removed the usage of the data field to write to it, the data getter can be used. gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_descriptor_data_addr): Remove. * trans-array.h (gfc_conv_descriptor_data_addr): Remove. * trans-decl.cc (gfc_trans_deferred_vars): Use gfc_conv_descriptor_data_get.
2025-08-05fortran: Use array descriptor data setter when possibleMikael Morin3-9/+24
Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- In some places, a write to an array descriptor data field was generated simply by adding a modification of a reference to it that was already available. This change uses the existing setter function instead in those places, to generate the same code. It makes it more explicit that in those areas a write to the field is generated. We have to be careful because in some of the places, the pointer that is to be modified is an array descriptor field only under some conditions. Add a conditional in those places to separate the cases, and keep generating the reference modification as before if the conditions are not met. gcc/fortran/ChangeLog: * trans.cc (gfc_finalize_tree_expr): Use the data setter instead of writing to the value returned by the data getter. * trans-decl.cc (gfc_trans_deferred_vars): Likewise. * trans-stmt.cc (trans_associate_var): Use the data setter instead of writing to the value dereferenced from the data address.
2025-08-02Daily bump.GCC Administrator1-0/+5
2025-08-01fortran: Fix closing brace in commentMikael Morin1-1/+1
In a comment, fix the closing brace of the tree layout definition of the openmp allocate clause. It was confusing vim's matching brace support. gcc/fortran/ChangeLog: * trans-decl.cc (gfc_trans_deferred_vars): Fix closing brace in a comment.
2025-08-01Daily bump.GCC Administrator1-0/+20
2025-07-31fortran: Evaluate class function bounds in the scalarizer [PR121342]Mikael Morin2-54/+97
There is code in gfc_conv_procedure_call that, for polymorphic functions, initializes the scalarization array descriptor information and forcedfully sets loop bounds. This code is changing the decisions made by the scalarizer behind his back, and the test shows an example where the consequences are (badly) visible. In the test, for one of the actual arguments to an elemental subroutine, an offset to the loop variable is missing to access the array, as it was the one originally chosen to set the loop bounds from. This could theoretically be fixed by just clearing the array of choice for the loop bounds. This change takes instead the harder path of adding the missing information to the scalarizer's knowledge so that its decision doesn't need to be forced to something else after the fact. The array descriptor information initialisation for polymorphic functions is moved to gfc_add_loop_ss_code (after the function call generation), and the loop bounds initialization to a new function called after that. As the array chosen to set the loop bounds from is no longer forced to be the polymorphic function result, we have to let the scalarizer set a delta for polymorphic function results. For regular non-polymorphic function result arrays, they are zero-based and the temporary creation makes the loop zero-based as well, so we can continue to skip the delta calculation. In the cases where a temporary is created to store the result of the array function, the creation of the temporary shifts the loop bounds to be zero-based. As there was no delta for polymorphic result arrays, the function result descriptor offset was set to zero in that case for a zero-based array reference to be correct. Now that the scalarizer sets a delta, those forced offset updates have to go because they can make the descriptor invalid and cause erroneous array references. PR fortran/121342 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_subref_array_arg): Remove offset update. (gfc_conv_procedure_call): For polymorphic functions, move the scalarizer descriptor information... * trans-array.cc (gfc_add_loop_ss_code): ... here, and evaluate the bounds to fresh variables. (get_class_info_from_ss): Remove offset update. (gfc_conv_ss_startstride): Don't set a zero value for function result upper bounds. (late_set_loop_bounds): New. (gfc_conv_loop_setup): If the bounds of a function result have been set, and no other array provided loop bounds for a dimension, use the function result bounds as loop bounds for that dimension. (gfc_set_delta): Don't skip delta setting for polymorphic function results. gcc/testsuite/ChangeLog: * gfortran.dg/class_elemental_1.f90: New test.
2025-07-31Daily bump.GCC Administrator1-0/+25
2025-07-30fortran: Remove useless elements count variableMikael Morin3-15/+9
The function gfc_array_init_size evaluates the number of array elements to a variable from a caller, but the single caller providing the variable actually doesn't use it. This change removes the variable and the function arguments passing its address down the call chain. gcc/fortran/ChangeLog: * trans-array.cc (gfc_array_init_size): Remove the nelems argument. (gfc_array_allocate): Update caller. Remove the nelems argument. * trans-stmt.cc (gfc_trans_allocate): Update caller. Remove the nelems variable. * trans-array.h (gfc_array_allocate): Update prototype.
2025-07-30fortran: implement split for fortran 2023Yuao Ma9-0/+198
This patch includes the implementation, documentation, and test case for SPLIT. gcc/fortran/ChangeLog: * check.cc (gfc_check_split): Argument check for SPLIT. * gfortran.h (enum gfc_isym_id): Define GFC_ISYM_SPLIT. * intrinsic.cc (add_subroutines): Register SPLIT intrinsic. * intrinsic.h (gfc_check_split): New decl. (gfc_resolve_split): Ditto. * intrinsic.texi: SPLIT documentation. * iresolve.cc (gfc_resolve_split): Add resolved_sym for SPLIT. * trans-decl.cc (gfc_build_intrinsic_function_decls): Add decl for SPLIT in libgfortran. * trans-intrinsic.cc (conv_intrinsic_split): SPLIT codegen. (gfc_conv_intrinsic_subroutine): Handle SPLIT case. * trans.h (GTY): Declare gfor_fndecl_string_split{, _char4}. libgfortran/ChangeLog: * gfortran.map: Add split symbol. * intrinsics/string_intrinsics_inc.c (string_split): Runtime support for SPLIT. gcc/testsuite/ChangeLog: * gfortran.dg/split_1.f90: New test. * gfortran.dg/split_2.f90: New test. * gfortran.dg/split_3.f90: New test. * gfortran.dg/split_4.f90: New test. Signed-off-by: Yuao Ma <c8ef@outlook.com>
2025-07-28Daily bump.GCC Administrator1-0/+23
2025-07-27fortran: Consistently use the same assignment reallocation condition [PR121185]Mikael Morin1-6/+8
This is a follow-up to: r16-2248-gac8e536526393580bc9a4339bab2f8603eff8a47 fortran: Delay evaluation of array bounds after reallocation That revision delayed the evaluation of array bounds, with changes in two places: in the scalarizer where we save expressions without evaluating their values to variables, and in the reallocation code where we evaluate to variables the expressions previously saved. The effect should not have been visible in scalarized code, as the saving to a variable was only delayed after reallocation. Unfortunately, it's actually not the case, and there are cases where expressions that were saved to variables before the change, are no longer after it. The reason for that is differing conditions guarding the omission of the evaluation to variables in the scalarizer on one hand, and the emission of reallocation code with the saving to variables on the other hand. There is an additional check that avoids the emission of reallocation code if we can prove at compile time that both sides of the assignment are conformable. This change moves up the reallocation code condition definition, so that it can be used as well to flag the left hand side array as reallocatable, and omit the evaluation of expressions in the exact same conditions where the reallocation code would catch those unevaluated expressions. An explicit call to gfc_fix_class_refs is added before the evaluation of the reallocation code condition. It was implicit before, by the call to gfc_walk_expr. This is not a correctness issue, but PR #121185, that made the problem apparent, exhibited wrong code examples where the lack of an intermediary variable was making visible a class container at the beginning of an array reference, causing the non-polymorphic array reference to be evaluated in a polymorphic way. The preceding commits have already fixed the PR #121185 test, so I haven't found any addition to the testsuite that would reliably test this change. PR fortran/121185 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_trans_assignment_1): Use the same condition to set the is_alloc_lhs flag and to decide to generate reallocation code. Add explicit call to gfc_fix_class_refs before evaluating the condition.
2025-07-27fortran: Trigger reference saving on pointer dereference [PR121185]Mikael Morin1-18/+36
This is a follow-up to revision: r16-2371-g8f41c87654fd819e48c9f6f1ac3d87e35794d310 fortran: Factor array descriptor references That revision introduced new variables to limit repeated subexpressions in array descriptor references. The change added a walk along the reference from child to parent, that selected subreferences worth saving and applied the saving if the reference proved non-trivial enough. Trivialness was defined in a comment as: only made of a DECL and NOPs and COMPONENTs. But the case of a pointer derefence didn't trigger the saving, so the code was also considering a dereference as if it was trivial. This change triggers the reference saving on pointer dereferences, making the trivialness as defined by the code aligned with the comment. This change is not strictly speaking a bug fix, but PR #121185 exhibited wrong code examples where the lack of a variable hiding the polymorphic leading part of a non-polymorphic array reference was causing the latter to be evaluated in a polymorphic way. PR fortran/121185 gcc/fortran/ChangeLog: * trans-array.cc (set_factored_descriptor_value): Also trigger the saving of the previously selected reference on encountering an INDIRECT_REF. Extract the saving code... (save_ref): ... here as a new function. gcc/testsuite/ChangeLog: * gfortran.dg/assign_14.f90: New test.
2025-07-27fortran: Bound class container lookup after array descriptor [PR121185]Mikael Morin1-0/+21
Don't look for a class container too far after an array descriptor. This avoids generating a polymorphic array reference, using the virtual table of a parent object, to access a non-polymorphic child having a type unrelated to that of the parent. PR fortran/121185 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_get_class_from_expr): Give up class container lookup on the second COMPONENT_REF after an array descriptor. gcc/testsuite/ChangeLog: * gfortran.dg/assign_13.f90: New test.
2025-07-26Daily bump.GCC Administrator1-0/+43
2025-07-25diagnostics: make context::m_source_printing privateDavid Malcolm1-5/+7
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Make diagnostics::context::m_source_printing private. gcc/analyzer/ChangeLog: * program-point.cc: Make diagnostics::context::m_source_printing private. gcc/c-family/ChangeLog: * c-common.cc: Make diagnostics::context::m_source_printing private. * c-format.cc: Likewise. * c-opts.cc: Likewise. gcc/ChangeLog: * diagnostic.h (diagnostic_set_caret_max_width): Drop forward decl. (diagnostic_same_line): Make diagnostics::context::m_source_printing private. * diagnostics/context.cc (diagnostic_set_caret_max_width): Convert to... (diagnostics::context::set_caret_max_width): ...this. * diagnostics/context.h (diagnostics::context::get_source_printing_options): New accessors. (diagnostics::context::m_source_printing): Make private. * diagnostics/html-sink.cc: Make diagnostics::context::m_source_printing private. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/selftest-context.cc: Likewise. * diagnostics/selftest-context.h (diagnostics::selftest::test_context::colorize_source): New. (diagnostics::selftest::test_context::show_labels): New. (diagnostics::selftest::test_context::show_line_numbers): New. (diagnostics::selftest::test_context::show_ruler): New. (diagnostics::selftest::test_context::show_event_links): New. (diagnostics::selftest::test_context::set_caret_char): New. * diagnostics/source-printing.cc: Make diagnostics::context::m_source_printing private. * diagnostics/text-sink.h: Likewise. * libgdiagnostics.cc: Likewise. * opts.cc: Likewise. * toplev.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Make diagnostics::context::m_source_printing private. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_show_trees.cc: Make diagnostics::context::m_source_printing private. * gcc.dg/plugin/diagnostic_plugin_test_inlining.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_string_literals.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: eliminate ::diagnostic_info typedefDavid Malcolm2-14/+14
No functional change intended. gcc/c-family/ChangeLog: * c-common.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * c-opts.cc: Likewise. gcc/c/ChangeLog: * c-errors.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". gcc/cp/ChangeLog: * constexpr.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * cp-tree.h: Likewise. * error.cc: Likewise. * module.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc: Likewise. gcc/ChangeLog: * diagnostic.h: Eliminate "diagnostic_info" typedef. * diagnostics/context.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * langhooks.cc: Likewise. * libgdiagnostics.cc: Likewise. * rtl-error.cc: Likewise. * substring-locations.cc: Likewise. * toplev.cc: Likewise. * tree-diagnostic.cc: Likewise. * tree-diagnostic.h: Likewise. gcc/fortran/ChangeLog: * cpp.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * error.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". gcc/m2/ChangeLog: * gm2-gcc/m2linemap.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * gm2-gcc/rtegraph.cc: Likewise. gcc/rust/ChangeLog: * resolve/rust-ice-finalizer.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * resolve/rust-ice-finalizer.h: Likewise. gcc/testsuite/ChangeLog: * g++.dg/plugin/show_template_tree_color_plugin.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. libcc1/ChangeLog: * context.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: convert diagnostic_t to enum class diagnostics::kindDavid Malcolm3-22/+29
No functional change intended. gcc/ChangeLog: * Makefile.in: Replace diagnostic.def with diagnostics/kinds.def. * config/aarch64/aarch64.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * config/i386/i386-options.cc: Likewise. * config/s390/s390.cc: Likewise. * diagnostic-core.h: Replace typedef diagnostic_t with enum class diagnostics::kind in diagnostics/kinds.h and include it. * diagnostic-global-context.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostics/buffering.cc: Likewise. * diagnostics/buffering.h: Likewise. * diagnostics/context.h: Likewise. * diagnostics/diagnostic-info.h: Likewise. * diagnostics/html-sink.cc: Likewise. * diagnostic.def: Move to... * diagnostics/kinds.def: ...here and update for diagnostic_t becoming enum class diagnostics::kind. * diagnostics/kinds.h: New file, based on material in diagnostic-core.h. * diagnostics/lazy-paths.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * diagnostics/option-classifier.cc: Likewise. * diagnostics/option-classifier.h: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/selftest-context.cc: Likewise. * diagnostics/selftest-context.h: Likewise. * diagnostics/sink.h: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * diagnostics/text-sink.h: Likewise. * gcc.cc: Likewise. * libgdiagnostics.cc: Likewise. * lto-wrapper.cc: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * rtl-error.cc: Likewise. * substring-locations.cc: Likewise. * toplev.cc: Likewise. gcc/ada/ChangeLog: * gcc-interface/trans.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/analyzer/ChangeLog: * pending-diagnostic.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * program-point.cc: Likewise. gcc/c-family/ChangeLog: * c-common.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * c-format.cc: Likewise. * c-lex.cc: Likewise. * c-opts.cc: Likewise. * c-pragma.cc: Likewise. * c-warn.cc: Likewise. gcc/c/ChangeLog: * c-errors.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * c-parser.cc: Likewise. * c-typeck.cc: Likewise. gcc/cobol/ChangeLog: * util.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/cp/ChangeLog: * call.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * constexpr.cc: Likewise. * cp-tree.h: Likewise. * decl.cc: Likewise. * error.cc: Likewise. * init.cc: Likewise. * method.cc: Likewise. * module.cc: Likewise. * parser.cc: Likewise. * pt.cc: Likewise. * semantics.cc: Likewise. * typeck.cc: Likewise. * typeck2.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/fortran/ChangeLog: * cpp.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * error.cc: Likewise. * options.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/m2/ChangeLog: * gm2-gcc/m2linemap.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * gm2-gcc/rtegraph.cc: Likewise. gcc/rust/ChangeLog: * backend/rust-tree.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * backend/rust-tree.h: Likewise. * resolve/rust-ast-resolve-expr.cc: Likewise. * resolve/rust-ice-finalizer.cc: Likewise. * resolve/rust-ice-finalizer.h: Likewise. * resolve/rust-late-name-resolver-2.0.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. * lib/gcc-dg.exp: Likewise. libcpp/ChangeLog: * internal.h: Update comment for diagnostic_t becoming enum class diagnostics::kind. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: rename diagnostic_option_id to diagnostics::option_id and move ↵David Malcolm1-1/+1
to its own header No functional change intended. gcc/c-family/ChangeLog: * c-common.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * c-common.h: Likewise. * c-cppbuiltin.cc: Likewise. * known-headers.cc: Likewise. * known-headers.h: Likewise. gcc/c/ChangeLog: * c-decl.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * c-errors.cc: Likewise. * c-tree.h: Likewise. gcc/cobol/ChangeLog: * util.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. gcc/cp/ChangeLog: * cp-tree.h: Update for renaming of diagnostic_option_id to diagnostics::option_id. * decl.cc: Likewise. * error.cc: Likewise. * name-lookup.cc: Likewise. gcc/ChangeLog: * diagnostic-core.h: Include "diagnostics/option-id.h". (struct diagnostic_option_id): Move there, renaming to diagnostics::option_id. * diagnostic-global-context.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostics/context.h: Likewise. * diagnostics/diagnostic-info.h: Likewise. * diagnostics/lazy-paths.cc: Likewise. * diagnostics/option-classifier.cc: Likewise. * diagnostics/option-classifier.h: Likewise. * diagnostics/option-id.h: New file, taken from material in diagnostic-core.h. * diagnostics/selftest-context.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * diagnostics/selftest-context.h: Likewise. * ipa-pure-const.cc: Likewise. * lto-wrapper.cc: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * substring-locations.cc: Likewise. * substring-locations.h: Likewise. gcc/fortran/ChangeLog: * cpp.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move gcc/diagnostic-color.{h,cc} to gcc/diagnostics/color.{h,cc}David Malcolm1-1/+1
No functional change intended. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Replace diagnostic-color.o with diagnostics/color.o. (PLUGIN_HEADERS): Remove diagnostic-color.h in favor of glob. * common.opt: Update for move of diagnostic-color.h to diagnostics/color.h. * diagnostic.cc: Likewise. * diagnostic-color.cc: Move to... * diagnostics/color.cc: ...here. * diagnostic-color.h: Move to... * diagnostics/color.h: ...here. * diagnostics/edit-context.cc: Update for move of diagnostic-color.h to diagnostics/color.h. * diagnostics/output-spec.cc: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * libgdiagnostics.cc: Likewise. * opts.cc: Likewise. * pretty-print-markup.h: Likewise. * pretty-print.cc: Likewise. * selftest-run-tests.cc: Likewise. * selftest.h: Likewise. * text-art/style.cc: Likewise. gcc/cp/ChangeLog: * error.cc: Update for move of diagnostic-color.h to diagnostics/color.h. gcc/fortran/ChangeLog: * error.cc: Update for move of diagnostic-color.h to diagnostics/color.h. gcc/m2/ChangeLog: * gm2-gcc/m2color.cc: Update for move of diagnostic-color.h to diagnostics/color.h. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_cpython_plugin.cc: Update for move of diagnostic-color.h to diagnostics/color.h. * gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise. * gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move diagnostic_context to diagnostics::context in its own headerDavid Malcolm1-13/+13
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Update for diagnostic_context becoming diagnostics::context. gcc/analyzer/ChangeLog: * program-point.cc: : Update for diagnostic_context becoming diagnostics::context, and for diagnostic_source_print_policy becoming diagnostics::source_print_policy. gcc/c-family/ChangeLog: * c-common.h: Update for diagnostic_context becoming diagnostics::context. * c-opts.cc: Likewise. gcc/c/ChangeLog: * c-objc-common.cc: Update for diagnostic_context becoming diagnostics::context. * c-tree.h: Likewise. gcc/ChangeLog: * coretypes.h: Update for diagnostic_context becoming diagnostics::context. * diagnostic-global-context.cc: Likewise. * diagnostic.cc: Likewise. Also for diagnostic_option_classifier becoming diagnostics::option_classifier. * diagnostic.h (diagnostic_text_starter_fn): Rename to... (diagnostics::text_starter_fn): ...this, and move to diagnostics/context.h. (get_printer): Rename to... (diagnostics::get_printer): ...this, and move to diagnostics/context.h. (class diagnostic_option_manager): Rename to... (class diagnostics::option_manager): ...this, and move to diagnostics/context.h. (class diagnostic_option_classifier): Rename to... (class diagnostics::option_classifier): ...this, and move to diagnostics/context.h. (struct diagnostic_source_printing_options): Rename to... (struct diagnostics::source_printing_options): ...this, and move to diagnostics/context.h. (class diagnostic_column_policy): Rename to... (class diagnostics::column_policy): ...this, and move to diagnostics/context.h. (class diagnostic_location_print_policy): Rename to... (class diagnostics::location_print_policy): ...this, and move to diagnostics/context.h. (class html_label_writer): Rename to... (class diagnostics::html_label_writer): ...this, and move to diagnostics/context.h. (class diagnostic_source_print_policy): Rename to... (class diagnostics::source_print_policy): ...this, and move to diagnostics/context.h. (struct diagnostic_counters): Rename to... (struct diagnostics::counters): ...this, and move to diagnostics/context.h. (class diagnostic_context): Rename to... (class diagnostics::context): ...this, and move to diagnostics/context.h. (diagnostic_text_starter): Rename to... (diagnostics::text_starter): ...this, and move to diagnostics/context.h. (diagnostic_start_span): Rename to... (diagnostics::start_span): ...this, and move to diagnostics/context.h. (diagnostic_text_finalizer): Rename to... (diagnostics::text_finalizer): ...this, and move to diagnostics/context.h. Include "diagnostics/context.h". * diagnostics/buffering.h: Update for diagnostic_context becoming diagnostics::context; similarly for diagnostic_counters. * diagnostics/client-data-hooks.h: Likewise. * diagnostics/context.h: New file, taken from material in diagnostic.h. * diagnostics/html-sink.cc: : Update for diagnostic_context becoming diagnostics::context. * diagnostics/html-sink.h: Likewise. * diagnostics/lazy-paths.cc: Likewise for diagnostic_option_manager. * diagnostics/output-file.h: Likewise for diagnostic_context. * diagnostics/output-spec.cc: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/sarif-sink.h: Likewise. * diagnostics/sink.h: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * diagnostics/text-sink.h: Likewise. * gcc-rich-location.h: Likewise. * gcc.cc: Likewise. * gdbinit.in: Likewise. * langhooks-def.h: Likewise. * langhooks.cc: Likewise. * langhooks.h: Likewise. * libgdiagnostics.cc: Likewise. * optc-gen.awk: Likewise. * opth-gen.awk: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.cc: Likewise. * opts-diagnostic.h: Likewise. * opts-global.cc: Likewise. * opts.cc: Likewise. * opts.h: Likewise. * selftest-diagnostic.cc: Likewise. * selftest-diagnostic.h: Likewise. * toplev.cc: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. * tree-diagnostic.cc: Likewise. * tree-diagnostic.h: Likewise. gcc/cp/ChangeLog: * cp-tree.h: Update for diagnostic_context becoming diagnostics::context. * error.cc: Likewise. * module.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update for diagnostic_context becoming diagnostics::context. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for diagnostic_context becoming diagnostics::context. * jit-playback.h: Likewise. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc: Update for diagnostic_text_finalizer becoming diagnostics::text_finalizer. * resolve/rust-late-name-resolver-2.0.cc: Likewise. gcc/testsuite/ChangeLog: * g++.dg/plugin/show_template_tree_color_plugin.cc: Update for moves to namespace diagnostics. * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: add m_ prefix to fields of diagnostic_infoDavid Malcolm1-11/+11
No functional change intended. gcc/c-family/ChangeLog: * c-opts.cc (c_diagnostic_text_finalizer): Add "m_" prefix to fields of diagnostic_info. gcc/c/ChangeLog: * c-errors.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. gcc/cp/ChangeLog: * constexpr.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. * error.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc (d_diagnostic_report_diagnostic): Update to add "m_" prefix to fields of diagnostic_info throughout. gcc/ChangeLog: * diagnostic.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. * diagnostic.h: Likewise. * diagnostics/html-sink.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * libgdiagnostics.cc: Likewise. * substring-locations.cc: Likewise. * tree-diagnostic.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move/rename output formats to diagnostics as "sinks"David Malcolm2-12/+12
Within gcc/ move diagnostic-buffer.h to diagnostics/buffering.h move diagnostic-format-html.cc to diagnostics/html-sink.cc move diagnostic-format-html.h to diagnostics/html-sink.h move diagnostic-format-sarif.cc to diagnostics/sarif-sink.cc move diagnostic-format-sarif.h to diagnostics/sarif-sink.h move diagnostic-format.h to diagnostics/sink.h move diagnostic-format-text.cc to diagnostics/text-sink.cc move diagnostic-format-text.h to diagnostics/text-sink.h renaming various types including: Old name: New name: diagnostic_output_format diagnostics::sink diagnostic_buffer diagnostics::buffer diagnostic_per_format_buffer diagnostics::per_sink_buffer diagnostic_text_output_format diagnostics::text_sink sarif_output_format diagnostics::sarif_sink diagnostic_sarif_format_buffer diagnostics::sarif_sink_buffer html_output_format diagnostics::html_sink diagnostic_html_format_buffer diagnostics::html_sink_buffer No functional change intended. gcc/ChangeLog: * Makefile.in (OBJS): Replace diagnostic-format-html.o with diagnostics/html-sink.o, diagnostic-format-sarif.o with diagnostics/sarif-sink.o, and diagnostic-format-text.o with diagnostics/text-sink.o. * coretypes.h (class diagnostic_text_output_format): Replace with... (class diagnostics::text_sink): ...this. * diagnostic-global-context.cc: Update for move of diagnostics output formats into namespace "diagnostics", as "sinks". * diagnostic-macro-unwinding.cc: Likewise. * diagnostic-macro-unwinding.h: Likewise. * diagnostic-show-locus.cc: Likewise. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostic-buffer.h: Rename to... * diagnostics/buffering.h: ...this, updating for above changes. * diagnostics/client-data-hooks.h: Likewise. * diagnostics/digraphs.cc: Likewise. * diagnostic-format-html.cc: Rename to... * diagnostics/html-sink.cc: ...this, updating for above changes. * diagnostic-format-html.h: Rename to... * diagnostics/html-sink.h: ...this, updating for above changes. * diagnostics/lazy-paths.cc: Likewise. * diagnostics/metadata.h: Likewise. * diagnostics/output-spec.cc: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/paths.h: Likewise. * diagnostic-format-sarif.cc: Rename to... * diagnostics/sarif-sink.cc: ...this, updating for above changes. * diagnostic-format-sarif.h: Rename to... * diagnostics/sarif-sink.h: ...this, updating for above changes. * diagnostic-format.h: Rename to... * diagnostics/sink.h: ...this, updating for above changes. * diagnostics/state-graphs-to-dot.cc: Likewise. * diagnostic-format-text.cc: Rename to... * diagnostics/text-sink.cc: ...this, updating for above changes. * diagnostic-format-text.h: Rename to... * diagnostics/text-sink.h: ...this, updating for above changes. * gcc.cc: Likewise. * langhooks-def.h: Likewise. * langhooks.cc: Likewise. * langhooks.h: Likewise. * libgdiagnostics.cc: Likewise. * opts-diagnostic.cc: Likewise. * opts.cc: Likewise. * selftest-diagnostic.cc: Likewise. * selftest-run-tests.cc: Likewise. * selftest.h: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. * tree-diagnostic.cc: Likewise. gcc/analyzer/ChangeLog: * ana-state-to-diagnostic-state.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * bounds-checking.cc: Likewise. * call-details.cc: Likewise. * checker-event.cc: Likewise. * checker-event.h: Likewise. * diagnostic-manager.cc: Likewise. * diagnostic-manager.h: Likewise. * infinite-loop.cc: Likewise. * infinite-recursion.cc: Likewise. * pending-diagnostic.h: Likewise. * region-model.cc: Likewise. * sm-taint.cc: Likewise. gcc/c-family/ChangeLog: * c-opts.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". gcc/cp/ChangeLog: * cp-tree.h: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * error.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * gfortran.h: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". gcc/rust/ChangeLog: * resolve/rust-ice-finalizer.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * resolve/rust-ice-finalizer.h: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_group_plugin.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. libcc1/ChangeLog: * context.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-24Daily bump.GCC Administrator1-0/+7
2025-07-23Fortran: fix passing of character length of function to procedure [PR121203]Harald Anlauf1-13/+13
PR fortran/121203 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): Obtain the character length of an assumed character length procedure from the typespec of the actual argument even if there is no explicit interface. gcc/testsuite/ChangeLog: * gfortran.dg/function_charlen_4.f90: New test.
2025-07-22Daily bump.GCC Administrator1-0/+22
2025-07-21fortran: Fix indentationMikael Morin1-8/+8
gcc/fortran/ChangeLog: * trans-decl.cc (gfc_trans_deferred_vars): Fix indentation.
2025-07-21Fortran: Allow for iterator substitution in array constructors [PR119106]Andre Vehreschild1-2/+3
PR fortran/119106 gcc/fortran/ChangeLog: * expr.cc (simplify_constructor): Do not simplify constants. (gfc_simplify_expr): Continue to simplify expression when an iterator is present. gcc/testsuite/ChangeLog: * gfortran.dg/array_constructor_58.f90: New test.
2025-07-21fortran: Factor array descriptor referencesMikael Morin1-1/+143
Save subexpressions of array descriptor references to variables, so that all the expressions using the descriptor as base object benefit from a simplified reference using the variables. This limits the size of the expressions generated in the original tree dump, easing analysis of the code involving those expressions. This is especially helpful with chains of array references where each array in the chain uses a descriptor. After optimizations, the effect of the change shouldn't be visible in the vast majority of cases. In rare cases it seems to permit a couple more jump threadings. gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_ss_descriptor): Move the descriptor expression initialisation... (set_factored_descriptor_value): ... to this new function. Before initialisation, walk the reference expression passed as argument and save some of its subexpressions to a variable. (substitute_t): New struct. (maybe_substitute_expr): New function. (substitute_subexpr_in_expr): New function.
2025-07-19Daily bump.GCC Administrator1-0/+6
2025-07-18Fortran: fix bogus runtime error with optional procedure argument [PR121145]Harald Anlauf1-1/+2
PR fortran/121145 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): Do not create pointer check for proc-pointer actual passed to optional dummy. gcc/testsuite/ChangeLog: * gfortran.dg/pointer_check_15.f90: New test.
2025-07-17Daily bump.GCC Administrator1-0/+11
2025-07-16Fortran: Fix ICE in ASSOCIATE with user defined operator [PR121060]Paul Thomas1-0/+7
2025-07-16 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/121060 * interface.cc (matching_typebound_op): Defer determination of specific procedure until resolution by returning NULL. gcc/testsuite/ PR fortran/121060 * gfortran.dg/associate_75.f90: New test.
2025-07-16Fortran: Fix ICE in F2018 IMPORT statements.Paul Thomas1-3/+6
2025-07-16 Steve Kargl <sgk@troutmask.apl.washington.edu> gcc/fortran * decl.cc (gfc_match_import): Correct minor whitespace snafu and fix NULL pointer dereferences in two places. gcc/testsuite/ * gfortran.dg/import13.f90: New test.
2025-07-16Daily bump.GCC Administrator1-0/+49
2025-07-15openmp, fortran: Fix ICE when the procedure name cannot be found in declare ↵Kwok Cheung Yeung1-2/+3
variant directives [PR104428] The result of searching for the procedure name symbol should be checked in case the symbol cannot be found to avoid a null dereference. gcc/fortran/ PR fortran/104428 * trans-openmp.cc (gfc_trans_omp_declare_variant): Check that proc_st is non-NULL before dereferencing. Add line number to error message. gcc/testsuite/ PR fortran/104428 * gfortran.dg/gomp/pr104428.f90: New.
2025-07-15fortran: Amend descriptor bounds init if unallocatedMikael Morin2-47/+49
Always generate the conditional initialization of unallocated variables regardless of the basic variable allocation tracking done in the frontend and with an additional always false condition. The scalarizer used to always evaluate array bounds, including in the case of unallocated arrays on the left hand side of an assignment. This was (correctly) causing uninitialized warnings, even if the uninitialized values were in the end discarded. Since the fix for PR fortran/108889, an initialization of the descriptor bounds is added to silent the uninitialized warnings, conditional on the array being unallocated. This initialization is not useful in the execution of the program, and it is removed if the compiler can prove that the variable is unallocated (in the case of a local variable for example). Unfortunately, the compiler is not always able to prove it and the useless initialization may remain in the final code. Moreover, the generated code that was causing the evaluation of uninitialized variables has ben changed to avoid them, so we can try to remove or revisit that unallocated variable bounds initialization tweak. Unfortunately, just removing the extra initialization restores the warnings at -O0, as there is no dead code removal at that optimization level. Instead, this change keeps the initialization and modifies its guarding condition with an extra always false variable, so that if optimizations are enabled the whole initialization block is removed, and if they are disabled it remains and is sufficient to prevent the warning. The new variable requires the code generation to be done earlier in the function so that the variable declaration and usage are in the same scope. As the modified condition guarantees the removal of the block with optimizations, we can emit it more broadly and remove the basic allocation tracking that was done in the frontend to limit its emission. gcc/fortran/ChangeLog: * gfortran.h (gfc_symbol): Remove field allocated_in_scope. * trans-array.cc (gfc_array_allocate): Don't set it. (gfc_alloc_allocatable_for_assignment): Likewise. Generate the unallocated descriptor bounds initialisation before the opening of the reallocation code block. Create a variable and use it as additional condition to the unallocated descriptor bounds initialisation.
2025-07-15fortran: Delay evaluation of array bounds after reallocationMikael Morin2-47/+104
Delay the evaluation of bounds, offset, etc after the reallocation, for the scalarization of allocatable arrays on the left hand side of assignments. Before this change, the code preceding the scalarization loop is like: D.4757 = ref2.offset; D.4759 = ref2.dim[0].ubound; D.4762 = ref2.dim[0].lbound; { if (ref2.data == 0B) goto realloc; if (ref2.dim[0].lbound + 4 != ref2.dim[0].ubound) goto realloc; goto L.10; realloc: ... change offset and bounds ... D.4757 = ref2.offset; D.4762 = NON_LVALUE_EXPR <ref2.dim[0].lbound>; ... reallocation ... L.10:; } while (1) { ... scalarized code ... so the bounds etc are evaluated first to variables, and the reallocation code takes care to update the variables during the reallocation. This is problematic because the variables' initialization references the array bounds, which for unallocated arrays are uninitialized at the evaluation point. This used to (correctly) cause uninitialized warnings (see PR fortran/108889), and a workaround for variables was found, that initializes the bounds of arrays variables to some value beforehand if they are unallocated. For allocatable components, there is no warning but the problem remains, some uninitialized values are used, even if discarded later. After this change the code becomes: { if (ref2.data == 0B) goto realloc; if (ref2.dim[0].lbound + 4 != ref2.dim[0].ubound) goto realloc; goto L.10; realloc:; ... change offset and bounds ... ... reallocation ... L.10:; } D.4762 = ref2.offset; D.4763 = ref2.dim[0].lbound; D.4764 = ref2.dim[0].ubound; while (1) { ... scalarized code so the scalarizer avoids storing the values to variables at the time it evaluates them, if the array is reallocatable on assignment. Instead, it keeps expressions with references to the array descriptor fields, expressions that remain valid through reallocation. After the reallocation code has been generated, the expressions stored by the scalarizer are evaluated in place to variables. The decision to delay evaluation is based on the existing field is_alloc_lhs, which requires a few tweaks to be alway correct wrt to what its name suggests. Namely it should be set even if the assignment right hand side is an intrinsic function, and it should not be set if the right hand side is a scalar and neither if the -fno-realloc-lhs flag is passed to the compiler. gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_ss_descriptor): Don't evaluate offset and data to a variable if is_alloc_lhs is set. Move the existing evaluation decision condition for data... (save_descriptor_data): ... here as a new predicate. (evaluate_bound): Add argument save_value. Omit the evaluation of the value to a variable if that argument isn't set. (gfc_conv_expr_descriptor): Update caller. (gfc_conv_section_startstride): Update caller. Set save_value if is_alloc_lhs is not set. Omit the evaluation of stride to a variable if save_value isn't set. (gfc_set_delta): Omit the evaluation of delta to a variable if is_alloc_lhs is set. (gfc_is_reallocatable_lhs): Return false if flag_realloc_lhs isn't set. (gfc_alloc_allocatable_for_assignment): Don't update the variables that may be stored in saved_offset, delta, and data. Call instead... (update_reallocated_descriptor): ... this new procedure. * trans-expr.cc (gfc_trans_assignment_1): Don't omit setting the is_alloc_lhs flag if the right hand side is an intrinsic function. Clear the flag if the right hand side is scalar.