aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
2025-05-29Fortran: Make minor adjustment to error message.Jerry DeLisle1-2/+2
PR fortran/120049 gcc/fortran/ChangeLog: * check.cc(check_c_ptr_2): Rephrase error message for clarity. gcc/testsuite/ChangeLog: * gfortran.dg/c_f_pointer_tests_6.f90: Adjust dg-error directive.
2025-05-28Fortran: Fix ChangeLog.Jerry DeLisle1-1/+1
PR fortran/119856 gcc/fortran/ChangeLog: * ChangeLog: Fix PR number in log.
2025-05-29Daily bump.GCC Administrator1-0/+32
2025-05-28Fortran: gfc_simplify_{cospi,sinpi} - fix for MPFR < 4.2.0Tobias Burnus1-8/+10
gcc/fortran/ChangeLog: PR fortran/113152 * simplify.cc (gfc_simplify_cospi, gfc_simplify_sinpi): Avoid using mpfr_fmod_ui in the MPFR < 4.2.0 version.
2025-05-28Fortran: Adjust handling of optional comma in FORMAT.Jerry DeLisle1-2/+4
This change adjusts the error messages for optional commas in format strings to give a warning at compile time unless -std=legacy is used. This is more consistant with the runtime library. A missing comma separator should not be encouraged as it is non-standard fortran. PR fortran/119586 gcc/fortran/ChangeLog: * io.cc: Set missing comma error checks to STD_STD_LEGACY. gcc/testsuite/ChangeLog: * gfortran.dg/comma_format_extension_1.f: Update dg-options to "-std=legacy". * gfortran.dg/comma_format_extension_3.f: Likewise. * gfortran.dg/continuation_13.f90: Likewise.
2025-05-28fortran: add constant input support for trig functions with half-revolutionsYuao Ma6-64/+381
This patch introduces constant input support for trigonometric functions, including those involving half-revolutions. Both valid and invalid inputs have been thoroughly tested, as have mpfr versions greater than or equal to 4.2 and less than 4.2. Inspired by Steve's previous work, this patch also fixes subtle bugs revealed by newly added test cases. If this patch is merged, I plan to work on middle-end optimization support for previously added GCC built-ins and libgfortran intrinsics. PR fortran/113152 gcc/fortran/ChangeLog: * gfortran.h (enum gfc_isym_id): Add new enum. * intrinsic.cc (add_functions): Register new intrinsics. Changing the call from gfc_resolve_trigd{,2} to gfc_resolve_trig{,2}. * intrinsic.h (gfc_simplify_acospi, gfc_simplify_asinpi, gfc_simplify_asinpi, gfc_simplify_atanpi, gfc_simplify_atan2pi, gfc_simplify_cospi, gfc_simplify_sinpi, gfc_simplify_tanpi): New. (gfc_resolve_trig): Rename from gfc_resolve_trigd. (gfc_resolve_trig2): Rename from gfc_resolve_trigd2. * iresolve.cc (gfc_resolve_trig): Rename from gfc_resolve_trigd. (gfc_resolve_trig2): Rename from gfc_resolve_trigd2. * mathbuiltins.def: Add 7 new math builtins and re-align. * simplify.cc (gfc_simplify_acos, gfc_simplify_asin, gfc_simplify_acosd, gfc_simplify_asind): Revise error message. (gfc_simplify_acospi, gfc_simplify_asinpi, gfc_simplify_asinpi, gfc_simplify_atanpi, gfc_simplify_atan2pi, gfc_simplify_cospi, gfc_simplify_sinpi, gfc_simplify_tanpi): New. gcc/testsuite/ChangeLog: * gfortran.dg/dec_math_3.f90: Test invalid input. * gfortran.dg/dec_math_5.f90: Test valid output. * gfortran.dg/dec_math_6.f90: New test. Signed-off-by: Yuao Ma <c8ef@outlook.com> Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2025-05-28Daily bump.GCC Administrator1-0/+37
2025-05-27Fortran: fix regression introduced by commit r16-914-g787a8dec1acedfHarald Anlauf1-4/+5
A last-minute cleanup before patch submission reordered a change that should not have happened. This fixes it. PR fortran/101735 gcc/fortran/ChangeLog: * primary.cc (gfc_match_varspec): Correct order of logic.
2025-05-27Fortran: Fix c_associated argument checks.Jerry DeLisle2-32/+96
PR fortran/120049 gcc/fortran/ChangeLog: * check.cc (gfc_check_c_associated): Use new helper functions. Only call check_c_ptr_1 if optional c_ptr_2 tests succeed. (check_c_ptr_1): Handle only c_ptr_1 checks. (check_c_ptr_2): Expand checks for c_ptr_2 and handle cases where there is no derived pointer in the gfc_expr and check the inmod_sym_id only if it exists. * misc.cc (gfc_typename): Handle the case for BT_VOID rather than throw an internal error. gcc/testsuite/ChangeLog: * gfortran.dg/pr120049_a.f90: Update test directives. * gfortran.dg/pr120049_b.f90: Update test directives * gfortran.dg/pr120049_2.f90: New test. Co-Authored-By: Steve Kargl <kargl@gcc.gnu.org>
2025-05-27Fortran: fix parsing of type parameter inquiries of substrings [PR101735]Harald Anlauf2-6/+80
Handling of type parameter inquiries of substrings failed to due either parsing issues or not following or handling reference chains properly. PR fortran/101735 gcc/fortran/ChangeLog: * expr.cc (find_inquiry_ref): If an inquiry reference applies to a substring, use that, and calculate substring length if needed. * primary.cc (extend_ref): Also handle attaching to end of reference chain for appending. (gfc_match_varspec): Discrimate between arrays of character and substrings of them. If a substring is taken from a character component of a derived type, get the proper typespec so that inquiry references work correctly. (gfc_match_rvalue): Handle corner case where we hit a seemingly dangling '%' and missed an inquiry reference. Try another match. gcc/testsuite/ChangeLog: * gfortran.dg/inquiry_type_ref_7.f90: New test.
2025-05-27diagnostics: rework experimental-html output [PR116792]David Malcolm1-1/+2
This patch reworks the HTML output from the the option -fdiagnostics-add-output=experimental-html so that for source quoting and path printing, rather than simply adding the textual output inside <pre> elements, it breaks up the output into HTML tags reflecting the structure of the output, using CSS, SVG and a little javascript to help the user navigate the diagnostics and the events within any paths. This uses ideas from the patch I posted in: https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558603.html but reworks the above patch so that: * rather than printing source to a pretty_printer, the HTML is created by building a DOM tree in memory, using a new xml::printer class. This should be less error-prone than the pretty_printer approach, since it ought to solve escaping issues. Instead of a text vs html boolean, the code is generalized via templates with to_text vs to_html sinks. This templatization applies both to path-printing and diagnostic-show-locus.cc. * the HTML output can have multiple diagnostics and multiple paths rather than just a single path. The javascript keyboard controls now cycle through all diagnostics and all events within them An example of the output can be seen at: https://dmalcolm.fedorapeople.org/gcc/2025-05-27/malloc-1.c.html where the keys "j" and "k" cycle through diagnostics and events within them. gcc/ChangeLog: PR other/116792 * diagnostic-format-html.cc: Define INCLUDE_STRING. Include "xml.h", "xml-printer.h", and "json.h". (html_generation_options::html_generation_options): New. (namespace xml): Move decls to xml.h and convert from using label_text to std::string. (xml::text::write_as_xml): Reimplement indentation so it is done by this node, rather than the parent. (xml::node_with_children::add_text): Convert from label_text to std::string. Consolidate runs of text into a single node. (xml::document::write_as_xml): Reimplement indentation. (xml::element::write_as_xml): Reimplement indentation so it is done by this node, rather than the parent. Convert from label_text to std::string. Update attribute-printing to new representation to preserve insertion order. (xml::element::set_attr): Convert from label_text to std::string. Record insertion order. (xml::raw::write_as_xml): New. (xml::printer::printer): New. (xml::printer::push_tag): New. (xml::printer::push_tag_with_class): New. (xml::printer::pop_tag): New. (xml::printer::set_attr): New. (xml::printer::add_text): New. (xml::printer::add_raw): New. (xml::printer::push_element): New. (xml::printer::append): New. (xml::printer::get_insertion_point): New. (html_builder::add_focus_id): New. (html_builder::m_html_gen_opts): New field. (html_builder::m_head_element): New field. (html_builder::m_next_diag_id): New field. (html_builder::m_ui_focus_ids): New field. (make_div): Convert from label_text to std::string. (make_span): Likewise. (HTML_STYLE): New. (HTML_SCRIPT): New. (html_builder::html_builder): Fix indentation. Add "html_gen_opts" param. Initialize new fields. Reimplement using xml::printer. Optionally add style and script tags. (class html_path_label_writer): New. (html_builder::make_element_for_diagnostic): Convert from label_text to std::string. Set "id" on "gcc-diagnostic" and "gcc-message" <div> elements; add the latter to the focus ids. Use diagnostic_context::maybe_show_locus_as_html rather than html_builder::make_element_for_source. Use print_path_as_html rather than html_builder::make_element_for_path. (html_builder::make_element_for_source): Drop. (html_builder::make_element_for_path): Drop. (html_builder::make_element_for_patch): Convert from label_text to std::string. (html_builder::make_metadata_element): Likewise. Use xml::printer. (html_builder::make_element_for_metadata): Convert from label_text to std::string. (html_builder::emit_diagram): Expand comment. (html_builder::flush_to_file): Write out initializer for "focus_ids" into javascript. (html_output_format::html_output_format): Add param "html_gen_opts" and use it to initialize m_builder. (html_file_output_format::html_file_output_format): Likewise, to initialize base class. (make_html_sink): Likewise, to pass to ctor. (selftest::test_html_diagnostic_context::test_html_diagnostic_context): Set up html_generation_options. (selftest::html_buffered_output_format::html_buffered_output_format): Add html_gen_opts param. (selftest::test_simple_log): Add id attributes to expected text for "gcc-diagnostic" and "gcc-message" elements. Update whitespace for indentation fixes. (selftest::test_metadata): Update whitespace for indentation fixes. (selftest::test_printer): New selftest. (selftest::test_attribute_ordering): New selftest. (selftest::diagnostic_format_html_cc_tests): Call the new selftests. * diagnostic-format-html.h (struct html_generation_options): New. (make_html_sink): Add "html_gen_opts" param. (print_path_as_html): New decl. * diagnostic-path-output.cc: Define INCLUDE_MAP. Add includes of "diagnostic-format-html.h", "xml.h", and "xml-printer.h". (path_print_policy::path_print_policy): Add ctor. (path_print_policy::get_diagram_theme): Fix whitespace. (struct stack_frame): New. (begin_html_stack_frame): New function. (end_html_stack_frame): New function. (emit_svg_arrow): New function. (event_range::print): Rename to... (event_range::print_as_text): ...this. Update call to diagnostic_start_span. (event_range::print_as_html): New, based on the above, but ported from pretty_printer to xml::printer. (thread_event_printer::print_swimlane_for_event_range): Rename to... (thread_event_printer::print_swimlane_for_event_range_as_text): ...this. Update for renaming of event_range::print to event_range::print_as_text. (thread_event_printer::print_swimlane_for_event_range_as_html): New. (print_path_summary_as_text): Update for "_as_text" renaming. (print_path_summary_as_html): New. (print_path_as_html): New. * diagnostic-show-locus.cc: Add defines of INCLUDE_MAP and INCLUDE_STRING. Add includes of "xml.h" and "xml-printer.h". (struct char_display_policy): Replace "m_print_cb" with "m_print_text_cb" and "m_print_html_cb". (struct to_text): New. (struct to_html): New. (get_printer): New. (default_diagnostic_start_span_fn<to_text>): New. (default_diagnostic_start_span_fn<to_html>): New. (class layout): Update "friend class layout_printer;" for template. (enum class margin_kind): New. (class layout_printer): Convert into a template. (layout_printer::m_pp): Replace field with... (layout_printer::m_sink): ...this. (layout_printer::m_colorizer): Drop field in favor of a pointer in the "to_text" sink. (default_print_decoded_ch): Convert into a template. (escape_as_bytes_print): Likewise. (escape_as_unicode_print): Likewise. (make_char_policy): Update to use both text and html callbacks. (layout_printer::print_gap_in_line_numbering): Replace with... (layout_printer<to_text>::print_gap_in_line_numbering): ...this (layout_printer<to_html>::print_gap_in_line_numbering): ...and this. (layout_printer::print_source_line): Convert to template, using m_sink. (layout_printer::print_leftmost_column): Likewise. (layout_printer::start_annotation_line): Likewise. (layout_printer<to_text>::end_line): New. (layout_printer<to_html>::end_line): New. (layout_printer::print_annotation_line): Convert to template, using m_sink. (class line_label): Add field m_original_range_idx. (layout_printer<to_text>::begin_label): New. (layout_printer<to_html>::begin_label): New. (layout_printer<to_text>::end_label): New. (layout_printer<to_html>::end_label): New. (layout_printer::print_any_labels): Convert to template, using m_sink. (layout_printer::print_leading_fixits): Likewise. (layout_printer::print_trailing_fixits): Likewise. (layout_printer::print_newline): Drop. (layout_printer::move_to_column): Convert to template, using m_sink. (layout_printer::show_ruler): Likewise. (layout_printer::print_line): Likewise. (layout_printer::print_any_right_to_left_edge_lines): Likewise. (layout_printer::layout_printer): Likewise. (diagnostic_context::maybe_show_locus_as_html): New. (diagnostic_source_print_policy::diagnostic_source_print_policy): Update for split of start_span_cb into text vs html variants. (diagnostic_source_print_policy::print): Update for use of templates; use to_text. (diagnostic_source_print_policy::print_as_html): New. (layout_printer::print): Convert to template, using m_sink. (selftest::make_element_for_locus): New. (selftest::make_raw_html_for_locus): New. (selftest::test_layout_x_offset_display_utf8): Update for use of templates. (selftest::test_layout_x_offset_display_tab): Likewise. (selftest::test_one_liner_caret_and_range): Add test coverage of HTML output. (selftest::test_one_liner_labels): Likewise. * diagnostic.cc (diagnostic_context::initialize): Update for split of start_span_cb into text vs html variants. (default_diagnostic_start_span_fn): Move to diagnostic-show-locus.cc, converting to template. * diagnostic.h (class xml::printer): New forward decl. (diagnostic_start_span_fn): Replace typedef with "using", converting to a template. (struct to_text): New forward decl. (struct to_html): New forward decl. (get_printer): New decl. (diagnostic_location_print_policy::print_text_span_start): New decl. (diagnostic_location_print_policy::print_html_span_start): New decl. (class html_label_writer): New. (diagnostic_source_print_policy::print_as_html): New decl. (diagnostic_source_print_policy::get_start_span_fn): Replace with... (diagnostic_source_print_policy::get_text_start_span_fn): ...this (diagnostic_source_print_policy::get_html_start_span_fn): ...and this (diagnostic_source_print_policy::m_start_span_cb): Replace with... (diagnostic_source_print_policy::m_text_start_span_cb): ...this (diagnostic_source_print_policy::m_html_start_span_cb): ...and this. (diagnostic_context::maybe_show_locus_as_html): New decl. (diagnostic_context::m_text_callbacks::m_start_span): Replace with... (diagnostic_context::m_text_callbacks::m_text_start_span): ...this (diagnostic_context::m_text_callbacks::m_html_start_span): ...and this. (diagnostic_start_span): Update for template change. (diagnostic_show_locus_as_html): New inline function. (default_diagnostic_start_span_fn): Convert to template. * doc/invoke.texi (experimental-html): Add "css" and "javascript" keys. * opts-diagnostic.cc (html_scheme_handler::make_sink): Likewise. * selftest-diagnostic.cc (selftest::test_diagnostic_context::start_span_cb): Update for template changes. * selftest-diagnostic.h (selftest::test_diagnostic_context::start_span_cb): Likewise. * xml-printer.h: New file. * xml.h: New file, based on material in diagnostic-format-html.cc, but using std::string rather than label_text. (xml::element::m_key_insertion_order): New field. (struct xml::raw): New. gcc/fortran/ChangeLog PR other/116792 * error.cc (gfc_diagnostic_start_span): Update for diagnostic.h changes. gcc/testsuite/ChangeLog: PR other/116792 * gcc.dg/html-output/missing-semicolon.c: Add ":javascript=no" to html output. * gcc.dg/html-output/missing-semicolon.py: Move repeated definitions into lib/htmltest.py. * gcc.dg/plugin/diagnostic_group_plugin.cc: Update for template changes. * gcc.dg/plugin/diagnostic-test-metadata-html.c: Add ":javascript=no" to html output. Add "-fdiagnostics-show-line-numbers". * gcc.dg/plugin/diagnostic-test-metadata-html.py: Move repeated definitions into lib/htmltest.py. Add checks of annotated source. * gcc.dg/plugin/diagnostic-test-paths-2.c: Add ":javascript=no" to html output. * gcc.dg/plugin/diagnostic-test-paths-2.py: Move repeated definitions into lib/htmltest.py. Add checks of execution path. * gcc.dg/plugin/diagnostic-test-paths-4.c: Add -fdiagnostics-add-output=experimental-html:javascript=no. Add invocation ot diagnostic-test-paths-4.py. * gcc.dg/plugin/diagnostic-test-paths-4.py: New test script. * gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c: Add -fdiagnostics-add-output=experimental-html:javascript=no. Add invocation of diagnostic-test-show-locus.py. * gcc.dg/plugin/diagnostic-test-show-locus.py: New test script. * lib/htmltest.py: New test support script. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-05-20Daily bump.GCC Administrator1-0/+7
2025-05-19Fortran: fix FAIL of gfortran.dg/specifics_1.f90 after r16-372 [PR120099]Harald Anlauf1-2/+3
After commit r16-372, testcase gfortran.dg/specifics_1.f90 started to FAIL at -O2 and higher, as DCE lead to elimination of evaluations of Fortran specific intrinsics returning complex results and with -ff2c. As the Fortran runtime library is compiled with -fno-f2c, the frontend generates calls to wrapper subroutines _gfortran_f2c_specific_* that return their result by reference via their first argument when this is needed. This is e.g. the case when specific names of the intrinsics are used for passing as actual argument to procedures. These wrappers are not pure in the GCC IR sense, even if the Fortran intrinsics are. Therefore gfc_return_by_reference must return true for these. PR fortran/120099 gcc/fortran/ChangeLog: * trans-types.cc (gfc_return_by_reference): Intrinsic functions returning complex numbers may return their result by reference with -ff2c.
2025-05-16Daily bump.GCC Administrator1-0/+11
2025-05-15Fortran: default-initialization and functions returning derived type [PR85750]Harald Anlauf1-4/+4
Functions with non-pointer, non-allocatable result and of derived type did not always get initialized although the type had default-initialization, and a derived type component had the allocatable or pointer attribute. Rearrange the logic when to apply default-initialization. PR fortran/85750 gcc/fortran/ChangeLog: * resolve.cc (resolve_symbol): Reorder conditions when to apply default-initializers. gcc/testsuite/ChangeLog: * gfortran.dg/alloc_comp_auto_array_3.f90: Adjust scan counts. * gfortran.dg/alloc_comp_class_3.f03: Remove bogus warnings. * gfortran.dg/alloc_comp_class_4.f03: Likewise. * gfortran.dg/allocate_with_source_14.f03: Adjust scan count. * gfortran.dg/derived_constructor_comps_6.f90: Likewise. * gfortran.dg/derived_result_5.f90: New test.
2025-05-15OpenMP/Fortran: Fix allocatable-component mapping of derived-type array compsTobias Burnus1-0/+20
The check whether the location expression in map clause has allocatable components was failing for some derived-type array expressions such as map(var%tiles(1)) as the compiler produced _4 = var.tiles; MEMREF(_4, _5); This commit now also handles this case. gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_omp_deep_mapping_do): Handle SSA_NAME if a def_stmt is available. libgomp/ChangeLog: * testsuite/libgomp.fortran/alloc-comp-4.f90: New test.
2025-05-15Daily bump.GCC Administrator1-0/+27
2025-05-14Fix explicit arrays with non-constant size for -fc-prototypes.Thomas Koenig1-0/+2
gcc/fortran/ChangeLog: PR fortran/120139 * dump-parse-tree.cc (get_c_type_name): If no constant size of an array exists, output an asterisk.
2025-05-14Do not dump non-interoperable types with -fc-prototypes.Thomas Koenig1-2/+3
gcc/fortran/ChangeLog: PR fortran/120107 * dump-parse-tree.cc (write_type): Do not dump non-interoperable types.
2025-05-14Fortran: Fix mpfr_tanu use in gfc_simplify_cotand with mpfr 4.2.0+ [PR120225]Tobias Burnus1-1/+1
Fix commit r16-607-gc91c226762b422. gcc/fortran/ChangeLog: PR fortran/120225 * simplify.cc (gfc_simplify_cotand): Fix used argument in mpfr_tanu call.
2025-05-14Fortran: Use mpfr_sinu etc. with mpfr 4.2.0+ for degree trigonometric ↵Tobias Burnus1-1/+40
functions [PR120225] As MPFR 4.2.0 added, support for degree trigonometric functions by via the mpfr_...u functions (for u = 360), it makes sense to use them if available. If MPFR is older, the current implementation is used as fallback. PR fortran/120225 gcc/fortran/ChangeLog: * simplify.cc: Include "trigd_fe.inc" only with MPFR < 4.2.0. (rad2deg, rad2deg): Only define if MPFR < 4.2.0. (gfc_simplify_acosd, gfc_simplify_asind, gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd, gfc_simplify_tand, gfc_simplify_cotand): Use mpfr_...u functions with MPFR >= 4.2.0.
2025-05-14Daily bump.GCC Administrator1-0/+20
2025-05-14fortran: map atand(y, x) to atan2d(y, x) [PR113413]Yuao Ma2-11/+21
According to the Fortran standard, atand(y, x) is equivalent to atan2d(y, x). However, the current atand(y, x) function produces an error. This patch includes the necessary intrinsic mapping, related test, and intrinsic documentation. The minor comment change in intrinsic.cc is cherry-picked from Steve's previous work. PR fortran/113413 - ATAND(Y,X) is unsupported PR fortran/113413 gcc/fortran/ChangeLog: * intrinsic.cc (do_check): Minor doc polish. (add_functions): Add atand(y, x) mapping. * intrinsic.texi: Update atand example. gcc/testsuite/ChangeLog: * gfortran.dg/dec_math.f90: Add atand(y, x) testcase. Signed-off-by: Yuao Ma <c8ef@outlook.com> Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2025-05-13fortran: Fix up minloc/maxloc lowering [PR120191]Jakub Jelinek1-36/+15
We need to drop the kind argument from what is passed to the library, but need to do it not only when one uses the argument name for it (so kind=4 etc.) but also when one passes all the arguments to the intrinsics. The following patch uses what gfc_conv_intrinsic_findloc uses, which looks more efficient and cleaner, we already set automatic vars to point to the kind and back actual arguments, so we can just free/clear expr on the former and set name to "%VAL" on the latter. And similarly clears dim argument for the BT_CHARACTER case when using maxloc2/minloc2, again regardless of whether it was named or not. 2025-05-13 Jakub Jelinek <jakub@redhat.com> Daniil Kochergin <daniil2472s@gmail.com> Tobias Burnus <tburnus@baylibre.com> PR fortran/120191 * trans-intrinsic.cc (strip_kind_from_actual): Remove. (gfc_conv_intrinsic_minmaxloc): Don't call strip_kind_from_actual. Free and clear kind_arg->expr if non-NULL. Set back_arg->name to "%VAL" instead of a loop looking for last argument. Remove actual variable, use array_arg instead. Free and clear dim_arg->expr if non-NULL for BT_CHARACTER cases instead of using a loop. * gfortran.dg/pr120191_1.f90: New test.
2025-05-12Daily bump.GCC Administrator1-0/+9
2025-05-11Do not generate formal arglist from actual if we have already resolved it.Thomas Koenig2-3/+7
This bug was another case of generating a formal arglist from an actual one where we should not have done so. The fix is straightforward: If we have resolved the formal arglist, we should not generare a new one. OK for trunk and backport? gcc/fortran/ChangeLog: PR fortran/120163 * gfortran.h: Add formal_resolved to gfc_symbol. * resolve.cc (gfc_resolve_formal_arglist): Set it. (resolve_function): Do not call gfc_get_formal_from_actual_arglist if we already resolved a formal arglist. (resolve_call): Likewise. gcc/testsuite/ChangeLog: PR fortran/120163 * gfortran.dg/interface_61.f90: New test.
2025-05-11Daily bump.GCC Administrator1-0/+16
2025-05-10Fortran: fix passing of inquiry ref of complex array to TRANSFER [PR102891]Harald Anlauf1-1/+5
PR fortran/102891 gcc/fortran/ChangeLog: * dependency.cc (gfc_ref_needs_temporary_p): Within an array reference, inquiry references of complex variables generally need a temporary. gcc/testsuite/ChangeLog: * gfortran.dg/transfer_array_subref.f90: New test.
2025-05-10fortran: Fix debug info for unsigned(kind=1) and unsigned(kind=4) [PR120193]Jakub Jelinek1-14/+17
As the following testcase shows, debug info for unsigned(kind=1) and unsigned(kind=4) vars is wrong while unsigned(kind=2), unsigned(kind=8) and unsigned(kind=16) look right. Instead of objects having unsigned(kind=1) type they have character(kind=1) and instead of unsigned(kind=4) they have character(kind=4). This means in gdb e.g. unsigned(kind=1) :: a(2) variable initialized to 97 will print as 'aa' rather than (97, 97) etc. While there can be just one unsigned_char_type_node and one unsigned_type_node type, each can have arbitrary number of variants (e.g. consider C typedef unsigned char uc; where uc is a variant type to unsigned char) or even distinct types with different TYPE_MAIN_VARIANT. The following patch uses a variant of the character(kind=4) type for unsigned(kind=4) and a distinct type based on character(kind=1) type for unsigned(kind=1). The reason for the latter is that unsigned_char_type_node has TYPE_STRING_FLAG set on it, so it has DW_AT_encoding DW_ATE_unsigned_char rather than DW_ATE_unsigned and so the debugger then likes to print it as characters rather than numbers. That is IMHO in Fortran desirable for character(kind=1) but not for unsigned(kind=1). I've made sure TYPE_CANONICAL of the unsigned(kind=1) type is still character(kind=1), so they are considered compatible by the middle-end also e.g. for aliasing etc. 2025-05-10 Jakub Jelinek <jakub@redhat.com> PR fortran/120193 * trans-types.cc (gfc_init_types): For flag_unsigned use build_distinct_type_copy or build_variant_type_copy from gfc_character_types[index_char] if index_char > -1 instead of gfc_character_types[index_char] or gfc_build_unsigned_type (&gfc_unsigned_kinds[index]). * gfortran.dg/guality/pr120193.f90: New test.
2025-05-09Daily bump.GCC Administrator1-0/+6
2025-05-08Fortran: parsing issue with DO CONCURRENT;ENDDO on same line [PR120179]Harald Anlauf1-1/+2
PR fortran/120179 gcc/fortran/ChangeLog: * match.cc (gfc_match_do): Do not attempt to match end-of-statement twice. gcc/testsuite/ChangeLog: * gfortran.dg/do_concurrent_basic.f90: Extend testcase.
2025-05-08Daily bump.GCC Administrator1-0/+8
2025-05-07Fortran: Source allocation of pure module function rejected [PR119948]Paul Thomas1-1/+1
2025-05-07 Paul Thomas <pault@gcc.gnu.org> and Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran PR fortran/119948 * primary.cc (match_variable): Module procedures with sym the same as result can be treated as variables, although marked external. gcc/testsuite/ PR fortran/119948 * gfortran.dg/pr119948.f90: Update to incorporate failing test, where module procedure is the result. Test submodule cases.
2025-05-07Daily bump.GCC Administrator1-0/+17
2025-05-06Fortran: Fix ICE with use of c_associated.Jerry DeLisle1-16/+26
PR fortran/120049 gcc/fortran/ChangeLog: * check.cc (gfc_check_c_associated): Modify checks to avoid ICE and allow use, intrinsic :: iso_c_binding from a separate module file. gcc/testsuite/ChangeLog: * gfortran.dg/pr120049_a.f90: New test. * gfortran.dg/pr120049_b.f90: New test.
2025-05-06Fix PR 119928, formal arguments used to wrongly inferred for CLASS.Thomas Koenig1-62/+73
The problem was indeed that generating a formal from an actual arglist is a bad idea when classes are involved. Fixed in the attached patch. I think it still makes sense to remove the checks when the other attributes are present (or PR96073 may come back in different guise, even if I have to test case at present). I have also converted the test to a run-time check. gcc/fortran/ChangeLog: PR fortran/119928 * interface.cc (gfc_check_dummy_characteristics): Do not issue error if one dummy symbol has been generated from an actual argument and the other one has OPTIONAL, INTENT, ALLOCATABLE, POINTER, TARGET, VALUE, ASYNCHRONOUS or CONTIGUOUS. (gfc_get_formal_from_actual_arglist): Do nothing if symbol is a class. gcc/testsuite/ChangeLog: PR fortran/119928 * gfortran.dg/interface_60.f90: New test.
2025-05-05Daily bump.GCC Administrator1-0/+10
2025-05-04Fortran: array subreferences and components of derived types [PR119986]Harald Anlauf2-4/+10
PR fortran/119986 gcc/fortran/ChangeLog: * expr.cc (is_subref_array): When searching for array references, do not terminate early so that inquiry references to complex components work. * primary.cc (gfc_variable_attr): A substring reference can refer to either a scalar or array character variable. Adjust search accordingly. gcc/testsuite/ChangeLog: * gfortran.dg/actual_array_subref.f90: New test.
2025-05-02Daily bump.GCC Administrator1-0/+7
2025-05-01Fortran: Source allocation of pure function result rejected [PR119948]Paul Thomas1-0/+10
2025-05-01 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/119948 * resolve.cc (gfc_impure_variable): The result of a module procedure with an interface declaration is not impure even if the current namespace is not the same as the symbol's. gcc/testsuite/ PR fortran/119948 * gfortran.dg/pr119948.f90: New test.
2025-04-26Daily bump.GCC Administrator1-0/+13
2025-04-25Fortran: fix procedure pointer handling with -fcheck=pointer [PR102900]Harald Anlauf2-7/+9
PR fortran/102900 gcc/fortran/ChangeLog: * trans-decl.cc (gfc_generate_function_code): Use sym->result when generating fake result decl for functions returning allocatable or pointer results. * trans-expr.cc (gfc_conv_procedure_call): When checking the pointer status of an actual argument passed to a non-allocatable, non-pointer dummy which is of type CLASS, do not check the class container of the actual if it is just a procedure pointer. (gfc_trans_pointer_assignment): Fix treatment of assignment to NULL of a procedure pointer. gcc/testsuite/ChangeLog: * gfortran.dg/proc_ptr_52.f90: Add -fcheck=pointer to options. * gfortran.dg/proc_ptr_57.f90: New test.
2025-04-25Daily bump.GCC Administrator1-0/+10
2025-04-23Fortran: Use correct location in check of coarray functions [PR119200]Andre Vehreschild1-6/+12
Use gfc_current_intrinsic_where during check(), because gfc_current_locus is not set to correct location or at all. PR fortran/119200 gcc/fortran/ChangeLog: * check.cc (gfc_check_lcobound): Use locus from intrinsic_where. (gfc_check_image_index): Same. (gfc_check_num_images): Same. (gfc_check_team_number): Same. (gfc_check_this_image): Same. (gfc_check_ucobound): Same.
2025-04-23Daily bump.GCC Administrator1-0/+207
2025-04-22Fortran: Various fixes on F2018 teams.Andre Vehreschild4-7/+35
gcc/fortran/ChangeLog: * match.cc (match_exit_cycle): Allow to exit team block. (gfc_match_end_team): Create end_team node also without parameter list. * trans-intrinsic.cc (conv_stat_and_team): Team and team_number only need to be a single pointer. * trans-stmt.cc (trans_associate_var): Create a mapping coarray token for coarray associations or it is not addressed correctly. * trans.h (enum gfc_coarray_regtype): Add mapping mode to coarray register. libgfortran/ChangeLog: * caf/libcaf.h: Add mapping mode to coarray's register. * caf/single.c (_gfortran_caf_register): Create a token sharing another token's memory. (check_team): Check team parameters to coindexed expressions are valid. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_3.f08: Add minimal test for get_team(). * gfortran.dg/team_change_2.f90: Add test for change team with label and exiting out of it. * gfortran.dg/team_end_2.f90: Check parsing to labeled team blocks is correct now. * gfortran.dg/team_end_3.f90: Check that end_team call is generated for labeled end_teams, too. * gfortran.dg/coarray/coindexed_5.f90: New test.
2025-04-22Fortran: Add teams support in image_index and num_images for F2018Andre Vehreschild9-139/+144
This more or less completes the set of functions that are affected by teams. gcc/fortran/ChangeLog: * check.cc (gfc_check_image_index): Check for team or team_number correctnes. (gfc_check_num_images): Same. * gfortran.texi: Update documentation on num_images' API function. * intrinsic.cc (add_functions): Update signature of image_index and num_images. Both can take either a team handle or number. * intrinsic.h (gfc_check_num_images): Update signature to take either team or team_number. (gfc_check_image_index): Can take coarray, subscripts and team or team number now. (gfc_simplify_image_index): Same. (gfc_simplify_num_images): Same. (gfc_resolve_image_index): Same. * intrinsic.texi: Update documentation of num_images() Fortran function. * iresolve.cc (gfc_resolve_image_index): Update signature. * simplify.cc (gfc_simplify_num_images): Update signature and remove undocumented failed argument. (gfc_simplify_image_index): Add team or team number argument. * trans-intrinsic.cc (conv_stat_and_team): Because being optional teams need to be a pointer to the opaque pointer. (conv_caf_sendget): Correct call; was two arguments short. (trans_image_index): Support team or team_number. (trans_num_images): Same. (conv_intrinsic_cobound): Adapt to changed signature of num_images in call. * trans-stmt.cc (gfc_trans_sync): Same. libgfortran/ChangeLog: * caf/libcaf.h (_gfortran_caf_num_images): Correct prototype. * caf/single.c (_gfortran_caf_num_images): Default implementation. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_49.f90: Adapt to changed error message. * gfortran.dg/coarray_collectives_12.f90: Adapt to changed function signature of num_images. * gfortran.dg/coarray_collectives_16.f90: Same. * gfortran.dg/coarray_lib_this_image_1.f90: Same. * gfortran.dg/coarray_lib_this_image_2.f90: Same. * gfortran.dg/coarray_this_image_1.f90: Adapt tests for num_images. * gfortran.dg/coarray_this_image_2.f90: Same. * gfortran.dg/coarray_this_image_3.f90: Same. * gfortran.dg/num_images_1.f90: Check that deprecated syntax is no longer supported.
2025-04-22Fortran: Add team-support to this_image [PR87326]Andre Vehreschild10-106/+157
This_image() no longer has a distance formal argument, but a team one. The source of the distance argument could not be identified, i.e. whether it came from a TS or standard draft. To implement only the standard it is removed. Besides being defined, it was not used anyway. PR fortran/87326 gcc/fortran/ChangeLog: * check.cc (gfc_check_this_image): Check the three different parameter lists possible for this_image and sort them correctly. * gfortran.texi: Update documentation on this_image's API. * intrinsic.cc (add_functions): Update this_image's signature. (check_specific): Add specific check for this_image. * intrinsic.h (gfc_check_this_image): Change to flexible argument list. * intrinsic.texi: Update documentation on this_image(). * iresolve.cc (gfc_resolve_this_image): Resolve the different arguments. * simplify.cc (gfc_simplify_this_image): Simplify the simplify routine. * trans-decl.cc (gfc_build_builtin_function_decls): Update signature of this_image. * trans-expr.cc (gfc_caf_get_image_index): Use correct signature of this_image. * trans-intrinsic.cc (trans_this_image): Adapt to correct signature. libgfortran/ChangeLog: * caf/libcaf.h (_gfortran_caf_this_image): Correct prototype. * caf/single.c (struct caf_single_team): Add new_index of image. (_gfortran_caf_this_image): Return the image index in the given team. (_gfortran_caf_form_team): Set new_index in team structure. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_10.f90: Update error messages. * gfortran.dg/coarray_lib_this_image_1.f90: Same. * gfortran.dg/coarray_lib_this_image_2.f90: Same. * gfortran.dg/coarray_this_image_1.f90: Add more tests and remove incorrect ones. * gfortran.dg/coarray_this_image_2.f90: Test more features. * gfortran.dg/coarray_this_image_3.f90: New test.
2025-04-22Fortran: Update get_team, team_number and image_status to F2018 [PR88154, ↵Andre Vehreschild12-72/+268
PR88960, PR97210, PR103001] Add functions get_team() and team_number() to comply with F2018 standard. Update image_status() to comply with F2018 standard. PR fortran/88154 PR fortran/88960 PR fortran/97210 PR fortran/103001 gcc/fortran/ChangeLog: * check.cc (team_type_check): Check a type for being team_type from the iso_fortran_env module. (gfc_check_image_status): Use team_type check. (gfc_check_get_team): Check for level argument. (gfc_check_team_number): Use team_type check. * expr.cc (gfc_check_assign): Add treatment for returning team_type in caf-single mode. * gfortran.texi: Add/Update documentation for get_team and team_number API functions. * intrinsic.cc (add_functions): Update get_team signature. * intrinsic.h (gfc_resolve_get_team): Add prototype. * intrinsic.texi: Add/Update documentation for get_team and team_number Fortran functions. * iresolve.cc (gfc_resolve_get_team): Resolve return type to be of type team_type. * iso-fortran-env.def: Update STAT_LOCK constants. They have nothing to do with files. Add level constants for get_team. * libgfortran.h: Add level and unlock_stat constants. * simplify.cc (gfc_simplify_get_team): Simply to correct return type team_type. * trans-decl.cc (gfc_build_builtin_function_decls): Update get_team and image_status API prototypes to correct signatures. * trans-intrinsic.cc (conv_intrinsic_image_status): Translate second parameter correctly. (conv_intrinsic_team_number): Translate optional single team argument correctly. (gfc_conv_intrinsic_function): Add translation of get_team. libgfortran/ChangeLog: * caf/libcaf.h: Add constants for get_team's level argument and update stat values for failed images. (_gfortran_caf_team_number): Add prototype. (_gfortran_caf_get_team): Same. * caf/single.c (_gfortran_caf_team_number): Get the given team's team number. (_gfortran_caf_get_team): Get the current team or the team given by level when the argument is present. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/image_status_1.f08: Correct check for team_type. * gfortran.dg/pr102458.f90: Adapt to multiple errors. * gfortran.dg/coarray/get_team_1.f90: New test. * gfortran.dg/team_get_1.f90: New test. * gfortran.dg/team_number_1.f90: Correct Fortran syntax.
2025-04-22Fortran: Improve F2018 TEAM handling [PR87326, PR87556, PR88254, PR103896]Andre Vehreschild15-190/+667
Improve the implementation of F2018 TEAM handling routines. Add runtime-functions to caf_single to allow testing. PR fortran/87326 PR fortran/87556 PR fortran/88254 PR fortran/103796 gcc/fortran/ChangeLog: * coarray.cc (split_expr_at_caf_ref): Treat polymorphic types correctly. Ensure resolve of expression after coindex. (create_allocated_callback): Fix parameter of allocated function for coarrays. (coindexed_expr_callback): Improve detection of coarrays in allocated function. * decl.cc (gfc_match_end): Add team block matching. * dump-parse-tree.cc (show_code_node): Dump change team block as such. * frontend-passes.cc (gfc_code_walker): Recognice team block. * gfortran.texi: Add documentation for team api functions. * intrinsic.texi: Add documentation about team_type in iso_fortran_env module. * iso-fortran-env.def (team_type): Use helper to get pointer kind. * match.cc (gfc_match_associate): Factor out matching of association list, because it is used in change team as well. (check_coarray_assoc): Ensure, that the association is to a coarray. (match_association_list): Match a list of association either in associate or in change team. (gfc_match_form_team): Match form team correctly include new_index. (gfc_match_change_team): Match change team with association list. (gfc_match_end_team): Match end team including stat and errmsg. (gfc_match_return): Prevent return from team block. * parse.cc (decode_statement): Sort team block. (next_statement): Same. (check_statement_label): Same. (accept_statement): Same. (verify_st_order): Same. (parse_associate): Renamed to move_associates_to_block... (move_associates_to_block): ... to enable reuse for change team. (parse_change_team): Parse it as block. (parse_executable): Same. * parse.h (enum gfc_compile_state): Add team block as compiler state. * resolve.cc (resolve_scalar_argument): New function to resolve an argument to a statement as a scalar. (resolve_form_team): Resolve its members. (resolve_change_team): Same. (resolve_branch): Prevent branch from jumping out of team block. (check_team): Removed. * trans-decl.cc (gfc_build_builtin_function_decls): Add stat and errmsg to team API functions and update their arguments. * trans-expr.cc (gfc_trans_subcomponent_assign): Also null the token when moving memory or an allocated() will not detect a free. * trans-intrinsic.cc (gfc_conv_intrinsic_caf_is_present_remote): Adapt to signature change no longer a pointer-pointer. * trans-stmt.cc (gfc_trans_form_team): Translate a form team including new_index. (gfc_trans_change_team): Translate a change team as a block. libgfortran/ChangeLog: * caf/libcaf.h: Remove commented block. (_gfortran_caf_form_team): Allow for all relevant arguments. (_gfortran_caf_change_team): Same. (_gfortran_caf_end_team): Same. (_gfortran_caf_sync_team): Same. * caf/single.c (struct caf_single_team): Team handling structures. (_gfortran_caf_init): Initialize initial team. (free_team_list): Free all teams and the memory they hold. (_gfortran_caf_finalize): Free initial and sibling teams. (_gfortran_caf_register): Add memory registered to current team. (_gfortran_caf_deregister): Unregister memory from current team. (_gfortran_caf_is_present_on_remote): Check token's memptr for llocation. May have been deallocated by an end team. (_gfortran_caf_form_team): Push a new team stub to the list. (_gfortran_caf_change_team): Push a formed team on top of the ctive teams stack. (_gfortran_caf_end_team): End the active team, free all memory allocated during its livespan. (_gfortran_caf_sync_team): Take stat and errmsg into account. gcc/testsuite/ChangeLog: * gfortran.dg/team_change_2.f90: New test. * gfortran.dg/team_change_3.f90: New test. * gfortran.dg/team_end_2.f90: New test. * gfortran.dg/team_end_3.f90: New test. * gfortran.dg/team_form_2.f90: New test. * gfortran.dg/team_form_3.f90: New test. * gfortran.dg/team_sync_2.f90: New test.