aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
2025-07-15fortran: Generate array reallocation out of loopsMikael Morin1-9/+12
Generate the array reallocation on assignment code before entering the scalarization loops. This doesn't move the generated code itself, which was already put before the outermost loop, but only changes the current scope at the time the code is generated. This is a prerequisite for a followup patch that makes the reallocation code create new variables. Without this change the new variables would be declared in the innermost loop body and couldn't be used outside of it. gcc/fortran/ChangeLog: * trans-expr.cc (gfc_trans_assignment_1): Generate array reallocation code before entering the scalarisation loops.
2025-07-15fortran: Fix indentationFilip Kastl1-10/+10
Move a block of code two spaces to the left. Commiting as obvious. gcc/fortran/ChangeLog: * resolve.cc (resolve_select_type): Fix indentation. Signed-off-by: Filip Kastl <fkastl@suse.cz>
2025-07-13Daily bump.GCC Administrator1-0/+9
2025-07-12Fortran/OpenACC: Permit PARAMETER as 'var' in clauses (+ ignore)Tobias Burnus3-9/+38
It turned out that other compilers permit (require?) named constants to appear in clauses - and programs actually use this. OpenACC 3.4 added therefore the following: In this spec, a _var_ (in italics) is one of the following: ... * a named constant in Fortran. plus If during an optimization phase _var_ is removed by the compiler, appearances of var in data clauses are ignored. Thus, all errors related to PARAMETER are now downgraded, most to a -Wsurprising warning, but for 'acc declare device_resident' (which kind of makes sense), no warning is printed. In trans-openmp.cc, those are ignored, unless I missed some code path. (If so, I hope the middle end removes them; but before removing them for the covered cases, the program just compiled & linked fine.) Note that 'ignore PARAMETER inside clauses' in trans-openmp.cc would in principle also apply to expressions ('if (var)') but those should be evaluated during 'resolve.cc' + 'openmp.cc' to their (numeric, logical, string) value such that there should be no issue. gcc/fortran/ChangeLog: * invoke.texi (-Wsurprising): Note about OpenACC warning related to PARAMATER. * openmp.cc (resolve_omp_clauses, gfc_resolve_oacc_declare): Accept PARAMETER for OpenACC but add surprising warning. * trans-openmp.cc (gfc_trans_omp_variable_list, gfc_trans_omp_clauses): Ignore PARAMETER inside clauses. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/parameter.f95: Add -Wsurprising flag and update expected diagnostic. * gfortran.dg/goacc/parameter-3.f90: New test. * gfortran.dg/goacc/parameter-4.f90: New test.
2025-07-12Daily bump.GCC Administrator1-0/+27
2025-07-11Fortran: Implement F2018 IMPORT statements [PR106135]Paul Thomas4-16/+369
2025-09-09 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/106135 * decl.cc (build_sym): Emit an error if a symbol associated by an IMPORT, ONLY or IMPORT, all statement is being redeclared. (gfc_match_import): Parse and check the F2018 versions of the IMPORT statement. For scopes other than and interface body, if the symbol cannot be found in the host scope, generate it and set it up such that gfc_fixup_sibling_symbols can transfer its 'imported attribute' if it turnes out to be a not yet parsed procedure. Test for violations of C897-8100. * gfortran.h : Add 'import_only' to the gfc_symtree structure. Add the enum, 'importstate', which is used for values the new field 'import_state' in gfc_namespace. * parse.cc (gfc_fixup_sibling_symbols): Transfer the attribute 'imported' to the new symbol. * resolve.cc (check_sym_import_status, check_import_status): New functions to test symbols and expressions for violations of F2018:C8102. (resolve_call): Test the 'resolved_sym' against C8102 by a call to 'check_sym_import_status'. (gfc_resolve_expr): If the expression is OK and an IMPORT statement has been registered in the current scope, test C102 by calling 'check_import_status'. (resolve_select_type): Test the declared derived type in TYPE IS and CLASS IS statements. gcc/testsuite/ PR fortran/106135 * gfortran.dg/import3.f90: Use -std=f2008 and comment on change in error message texts with f2018. * gfortran.dg/import12.f90: New test.
2025-07-09Daily bump.GCC Administrator1-0/+6
2025-07-08Fortran: Ensure finalizers are created correctly [PR120637]Andre Vehreschild1-10/+14
Finalize_component freeed an expression that it used to remember which components in which context it had finalized already. While it makes sense to free the copy of the expression, if it is unused, it causes issues, when comparing to a non existent expression. This is now detected by returning true, when the expression has been used. PR fortran/120637 gcc/fortran/ChangeLog: * class.cc (finalize_component): Return true, when a finalizable component was detect and do not free it. gcc/testsuite/ChangeLog: * gfortran.dg/asan/finalize_1.f90: New test.
2025-07-08Daily bump.GCC Administrator1-0/+5
2025-07-07fortran: Add the preliminary code of MOVE_ALLOC argumentsMikael Morin1-0/+5
Add the preliminary code produced for the evaluation of the FROM and TO arguments of the MOVE_ALLOC intrinsic before using their values. Before this change, the preliminary code was ignored and dropped, limiting the validity of the implementation of MOVE_ALLOC to simple cases without preliminary code. This change also adds the cleanup code of the same arguments. It doesn't make any difference on the testcase though. Because of the limited set of arguments that are allowed (variables or components without subreference), it is possible that the cleanup code is actually guaranteed to be empty. At least adding the cleanup code makes the array case consistent with the scalar case. gcc/fortran/ChangeLog: * trans-intrinsic.cc (conv_intrinsic_move_alloc): Add pre and post code for the FROM and TO arguments. gcc/testsuite/ChangeLog: * gfortran.dg/move_alloc_20.f03: New test.
2025-07-05Daily bump.GCC Administrator1-0/+5
2025-07-04Fortran: Silence a clang warning (suggesting a brace) in io.ccMartin Jambor1-1/+1
When GCC is built with clang, it suggests that we add a brace to the initialization of format_asterisk: gcc/fortran/io.cc:32:16: warning: suggest braces around initialization of subobject [-Wmissing-braces] So this patch does that to silence it. gcc/fortran/ChangeLog: 2025-06-24 Martin Jambor <mjambor@suse.cz> * io.cc (format_asterisk): Add a brace around static initialization location part of the field locus.
2025-07-04Daily bump.GCC Administrator1-0/+6
2025-07-03Fortran: Remove corank conformability checks [PR120843]Andre Vehreschild1-29/+0
Remove the checks on coranks conformability in expressions, because there is nothing in the standard about it. When a coarray has no coindexes it it treated like a non-coarray, when it has a full-corank coindex its result is a regular array. So nothing to check for corank conformability. PR fortran/120843 gcc/fortran/ChangeLog: * resolve.cc (resolve_operator): Remove conformability check, because it is not in the standard. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_6.f90: Enhance test to have coarray components covered.
2025-07-02Daily bump.GCC Administrator1-0/+22
2025-07-01Fortran: fix minor issues with coarraysHarald Anlauf2-3/+6
gcc/fortran/ChangeLog: * coarray.cc (check_add_new_component): Treat pure and elemental intrinsic functions the same as non-intrinsic ones. (create_caf_add_data_parameter_type): Fix front-end memleaks. * trans-intrinsic.cc (conv_caf_func_index): Likewise.
2025-07-01Fortran: Ensure arguments in coarray call get unique components in add_data ↵Andre Vehreschild1-2/+2
[PR120847] PR fortran/120847 gcc/fortran/ChangeLog: * coarray.cc (check_add_new_comp_handle_array): Make the count of components static to be able to create more than one. Create an array component only for array expressions. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_7.f90: New test.
2025-07-01Fortran: Fix non-conformable corank on this_image ref [PR120843]Andre Vehreschild1-3/+4
PR fortran/120843 gcc/fortran/ChangeLog: * resolve.cc (resolve_operator): Report inconsistent coranks only when not referencing this_image. (gfc_op_rank_conformable): Treat coranks as inconformable only when a coindex other then implicit this_image is used. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_6.f90: New test.
2025-06-28Daily bump.GCC Administrator1-0/+27
2025-06-27Fortran: follow-up fix to checking of renamed-on-use interface name [PR120784]Harald Anlauf1-1/+3
Commit r16-1633 introduced a regression for imported interfaces that were not renamed-on-use, since the related logic did not take into account that the absence of renaming could be represented by an empty string. PR fortran/120784 gcc/fortran/ChangeLog: * interface.cc (gfc_match_end_interface): Detect empty local_name. gcc/testsuite/ChangeLog: * gfortran.dg/interface_63.f90: Extend testcase.
2025-06-26fortran: Avoid freeing uninitialized valueMartin Jambor1-1/+1
When compiling fortran/match.cc, clang emits a warning fortran/match.cc:5301:7: warning: variable 'p' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] which looks accurate, so this patch adds an initialization of p to avoid the use. gcc/fortran/ChangeLog: 2025-06-23 Martin Jambor <mjambor@suse.cz> * match.cc (gfc_match_nullify): Initialize p to NULL;
2025-06-26Fortran: Prevent creation of unused tree.Andre Vehreschild1-4/+7
gcc/fortran/ChangeLog: * trans.cc (gfc_allocate_using_malloc): Prevent possible memory leak when allocation was already done.
2025-06-26Fortran: Fix wasting memory in coarray single mode.Andre Vehreschild2-3/+3
gcc/fortran/ChangeLog: * resolve.cc (resolve_fl_derived0): Do not create the token component when not in coarray lib mode. * trans-types.cc: Do not access the token when not in coarray lib mode.
2025-06-26Fortran: Fix out of bounds access in structure constructor's clean up [PR120711]Andre Vehreschild1-4/+6
A structure constructor's generated clean up code was using an offset variable, which was manipulated before the clean up was run leading to an out of bounds access. PR fortran/120711 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_array_ctor_element): Store the value of the offset for reuse. gcc/testsuite/ChangeLog: * gfortran.dg/asan/array_constructor_1.f90: New test.
2025-06-25Daily bump.GCC Administrator1-0/+28
2025-06-24Fortran/OpenACC: Add Fortran support for acc_attach/acc_detachTobias Burnus1-2/+72
While C/++ support the routines acc_attach{,_async} and acc_detach{,_finalize}{,_async} routines since a long time, the Fortran API routines where only added in OpenACC 3.3. Unfortunately, they cannot directly be implemented in the library as GCC will introduce a temporary array descriptor in some cases, which causes the attempted attachment to the this temporary variable instead of to the original one. Therefore, those API routines are handled in a special way in the compiler. gcc/fortran/ChangeLog: * trans-stmt.cc (gfc_trans_call_acc_attach_detach): New. (gfc_trans_call): Call it. libgomp/ChangeLog: * libgomp.texi (acc_attach, acc_detach): Update for Fortran version. * openacc.f90 (acc_attach{,_async}, acc_detach{,_finalize}{,_async}): Add. * openacc_lib.h: Likewise. * testsuite/libgomp.oacc-fortran/acc-attach-detach-1.f90: New test. * testsuite/libgomp.oacc-fortran/acc-attach-detach-2.f90: New test.
2025-06-24Fortran: fix ICE in verify_gimple_in_seq with substrings [PR120743]Harald Anlauf1-2/+3
PR fortran/120743 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_substring): Substring indices are of type gfc_charlen_type_node. Convert to size_type_node for pointer arithmetic only after offset adjustments have been made. gcc/testsuite/ChangeLog: * gfortran.dg/pr120743.f90: New test. Co-authored-by: Jerry DeLisle <jvdelisle@gcc.gnu.org> Co-authored-by: Mikael Morin <mikael@gcc.gnu.org>
2025-06-24fortran: Mention user variable in SELECT TYPE temporary variable namesMikael Morin4-17/+51
The temporary variables that are generated to implement SELECT TYPE and TYPE IS statements have (before this change) a name depending only on the type. This can produce confusing dumps with code having multiple SELECT TYPE statements, as it isn't obvious which SELECT TYPE construct the variable relates to. This is especially the case with nested SELECT TYPE statements and with SELECT TYPE variables having identical types (and thus identical names). This change adds one additional user-provided discriminating string in the variable names, using the value from the SELECT TYPE variable name or last component reference name. The additional string may be truncated to fit in the temporary buffer. This requires all buffers to have matching sizes to get the same resulting name everywhere. gcc/fortran/ChangeLog: * misc.cc (gfc_var_name_for_select_type_temp): New function. * gfortran.h (gfc_var_name_for_select_type_temp): Declare it. * resolve.cc (resolve_select_type): Pick a discriminating name from the SELECT TYPE variable reference and use it in the name of the temporary variable that is generated. Truncate name to the buffer size. * match.cc (select_type_set_tmp): Likewise. Pass the discriminating name... (select_intrinsic_set_tmp): ... to this function. Use the discriminating name likewise. Augment the buffer size to match that of select_type_set_tmp and resolve_select_type. gcc/testsuite/ChangeLog: * gfortran.dg/select_type_51.f90: New test.
2025-06-24Daily bump.GCC Administrator1-0/+11
2025-06-23OpenACC: Add 'if' clause to 'acc wait' directiveTobias Burnus2-1/+5
OpenACC 3.0 added the 'if' clause to four directives; this patch only adds it to 'acc wait'. gcc/c-family/ChangeLog: * c-omp.cc (c_finish_oacc_wait): Handle if clause. gcc/c/ChangeLog: * c-parser.cc (OACC_WAIT_CLAUSE_MASK): Add if clause. gcc/cp/ChangeLog: * parser.cc (OACC_WAIT_CLAUSE_MASK): Ass if clause. gcc/fortran/ChangeLog: * openmp.cc (OACC_WAIT_CLAUSES): Add if clause. * trans-openmp.cc (gfc_trans_oacc_wait_directive): Handle it. gcc/testsuite/ChangeLog: * c-c++-common/goacc/acc-wait-1.c: New test. * gfortran.dg/goacc/acc-wait-1.f90: New test.
2025-06-23Fortran: fix checking of renamed-on-use interface name [PR120784]Harald Anlauf1-3/+10
PR fortran/120784 gcc/fortran/ChangeLog: * interface.cc (gfc_match_end_interface): If a use-associated symbol is renamed, use the local_name for checking. gcc/testsuite/ChangeLog: * gfortran.dg/interface_63.f90: New test.
2025-06-20Daily bump.GCC Administrator1-0/+6
2025-06-19fortran: Statically initialize length of SAVEd character arraysMikael Morin1-2/+10
PR fortran/120713 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_deferred_array): Statically initialize deferred length variable for SAVEd character arrays. gcc/testsuite/ChangeLog: * gfortran.dg/save_alloc_character_1.f90: New test.
2025-06-19Daily bump.GCC Administrator1-0/+9
2025-06-18Fortran: various fixes for STAT/LSTAT/FSTAT intrinsics [PR82480]Harald Anlauf2-39/+46
The GNU intrinsics STAT/LSTAT/FSTAT were inherited from g77, but changed the names of some keywords: FILE became NAME, and SARRAY became VALUES, which are the keywords documented in the gfortran manual. Adjust code and libgfortran error messages to reflect this change. Furthermore, add compile-time checking that INTENT(OUT) arguments are definable, and that array VALUES has at least size 13. Document that integer arguments are of default kind, and that overflows in conversion to integer return -1 in VALUES. PR fortran/82480 gcc/fortran/ChangeLog: * check.cc (gfc_check_fstat): Extend checks to INTENT(OUT) arguments. (gfc_check_fstat_sub): Likewise. (gfc_check_stat): Likewise. (gfc_check_stat_sub): Likewise. * intrinsic.texi: Adjust documentation. libgfortran/ChangeLog: * intrinsics/stat.c (stat_i4_sub_0): Fix argument names. Rename SARRAY to VALUES also in error message. When array VALUES is KIND=4, get only stat components that do not overflow INT32_MAX, otherwise set the corresponding VALUES elements to -1. (stat_i4_sub): Fix argument names. (lstat_i4_sub): Likewise. (stat_i8_sub_0): Likewise. (stat_i8_sub): Likewise. (lstat_i8_sub): Likewise. (stat_i4): Likewise. (stat_i8): Likewise. (lstat_i4): Likewise. (lstat_i8): Likewise. (fstat_i4_sub): Likewise. (fstat_i8_sub): Likewise. (fstat_i4): Likewise. (fstat_i8): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/stat_3.f90: New test.
2025-06-17Daily bump.GCC Administrator1-0/+6
2025-06-16Fortran: fix checking of MOLD= in ALLOCATE statements [PR51961]Harald Anlauf1-0/+17
In ALLOCATE statements where the MOLD= argument is present and is not scalar, and the allocate-object has an explicit-shape-spec, the standard does not require the ranks to agree. In that case we skip the rank check, but emit a warning if -Wsurprising is given. PR fortran/51961 gcc/fortran/ChangeLog: * resolve.cc (conformable_arrays): Use modified rank check when MOLD= expression is given. gcc/testsuite/ChangeLog: * gfortran.dg/allocate_with_mold_5.f90: New test.
2025-06-12Daily bump.GCC Administrator1-0/+7
2025-06-12fortran: add intrinsic doc for trig functions with half revolutionsYuao Ma1-68/+458
This patch is a follow-up to commit r16-938-ge8fdd55ec90749. In this patch, we add intrinsic documentation for the newly added trig functions with half revolutions. We also reorder the documentation for `atand` to place it in correct alphabetical order. PR fortran/113152 gcc/fortran/ChangeLog: * intrinsic.texi: Document new half-revolution trigonometric functions. Reorder doc for atand. Signed-off-by: Yuao Ma <c8ef@outlook.com> Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2025-06-07Daily bump.GCC Administrator1-0/+10
2025-06-06OpenMP: Add omp_get_initial_device/omp_get_num_devices builtinsTobias Burnus4-3/+20
By adding omp_get_initial_device and omp_get_num_devices builtins for C, C++, and Fortran, the following can be achieved: * By making them pure, multiple calls can be avoiding in some cases. * Some comparisons can be optimized at compile time. omp_get_initial_device will be converted to omp_get_num_devices for consistency; note that OpenMP 6 also permits omp_initial_device (== -1) as value. If GCC has not been configure for offloading, either intrinsic will leads to 0 - and on the offload side, -1 (= omp_initial_device) is returned for omp_initial_device. gcc/fortran/ChangeLog: * f95-lang.cc (ATTR_PURE_NOTHROW_LIST): Define. * trans-expr.cc (get_builtin_fn): Handle omp_get_num_devices and omp_get_intrinsic_device. * gfortran.h (gfc_option_t): Add disable_omp_... for them. * options.cc (gfc_handle_option): Handle them with -fno-builtin-. gcc/ChangeLog: * gimple-fold.cc (gimple_fold_builtin_omp_get_initial_device, gimple_fold_builtin_omp_get_num_devices): New. (gimple_fold_builtin): Call them. * omp-builtins.def (BUILT_IN_OMP_GET_INITIAL_DEVICE): Add (BUILT_IN_OMP_GET_NUM_DEVICES): Make uservisible + pure. libgomp/ChangeLog: * libgomp.texi (omp_get_num_devices, omp_get_intrinsic_device): Document builtin handling. gcc/testsuite/ChangeLog: * c-c++-common/gomp/omp_get_num_devices_initial_device-2.c: New test. * c-c++-common/gomp/omp_get_num_devices_initial_device.c: New test. * gfortran.dg/gomp/omp_get_num_devices_initial_device-2.f90: New test. * gfortran.dg/gomp/omp_get_num_devices_initial_device.f90: New test. Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com>
2025-06-05Daily bump.GCC Administrator1-0/+6
2025-06-04Fortran: Fix missing substring ref for allocatable saved vars [PR120483]Andre Vehreschild1-3/+13
Compute a substring ref on an allocatable static character array using pointer arithmetic. Using an array type corrupts type layouting and crashes omp generation. PR fortran/120483 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_substring): Use pointer arithmetic on static allocatable char arrays. gcc/testsuite/ChangeLog: * gfortran.dg/save_8.f90: New test.
2025-06-04Daily bump.GCC Administrator1-0/+6
2025-06-03Fortran: ICE due to missing locus with data statement for coarray [PR99838]Harald Anlauf1-1/+7
PR fortran/99838 gcc/fortran/ChangeLog: * data.cc (gfc_assign_data_value): For a new initializer use the location from the constructor as fallback. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_data_2.f90: New test.
2025-05-31Daily bump.GCC Administrator1-0/+27
2025-05-30Fortran: parameter inquiries of constant complex arrays [PR102599,PR114022]Harald Anlauf2-4/+83
PR fortran/102599 PR fortran/114022 gcc/fortran/ChangeLog: * expr.cc (simplify_complex_array_inquiry_ref): Helper function for simplification of inquiry references (%re/%im) of constant complex arrays. (find_inquiry_ref): Use it for handling %re/%im inquiry references of complex arrays. (scalarize_intrinsic_call): Fix frontend memleak. * primary.cc (gfc_match_varspec): When the reference is NULL, the previous simplification has succeeded in evaluating inquiry references also of arrays. gcc/testsuite/ChangeLog: * gfortran.dg/inquiry_type_ref_8.f90: New test.
2025-05-30Type mismatch for passed external functionThomas Koenig1-1/+8
This obvious and simple patch fixes a 15/16 regression where the typespec of a global function was in the RESULT clause and not in the symbol itself. gcc/fortran/ChangeLog: PR fortran/120355 * interface.cc (compare_parameter): If the global function has a result clause, take typespec from there for the comparison against the dummy argument. gcc/testsuite/ChangeLog: PR fortran/120355 * gfortran.dg/interface_62.f90: New test.
2025-05-30OpenMP: C++ "declare mapper" supportJulian Brown1-0/+3
This patch adds support for OpenMP 5.0 "declare mapper" functionality for C++. I've merged it to og13 based on the last version posted upstream, with some minor changes due to the newly-added 'present' map modifier support. There's also a fix to splay-tree traversal in gimplify.cc:omp_instantiate_implicit_mappers, and this patch omits the rearrangement of gimplify.cc:gimplify_{scan,adjust}_omp_clauses that I separated out into its own patch and applied (to og13) already. gcc/c-family/ * c-common.h (c_omp_region_type): Add C_ORT_DECLARE_MAPPER and C_ORT_OMP_DECLARE_MAPPER codes. (omp_mapper_list): Add forward declaration. (c_omp_find_nested_mappers, c_omp_instantiate_mappers): Add prototypes. * c-omp.cc (c_omp_find_nested_mappers): New function. (remap_mapper_decl_info): New struct. (remap_mapper_decl_1, omp_instantiate_mapper, c_omp_instantiate_mappers): New functions. gcc/cp/ * constexpr.cc (reduced_constant_expression_p): Add OMP_DECLARE_MAPPER case. (cxx_eval_constant_expression, potential_constant_expression_1): Likewise. * cp-gimplify.cc (cxx_omp_finish_mapper_clauses): New function. * cp-objcp-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks. * cp-tree.h (lang_decl_base): Add omp_declare_mapper_p field. Recount spare bits comment. (DECL_OMP_DECLARE_MAPPER_P): New macro. (omp_mapper_id): Add prototype. (cp_check_omp_declare_mapper): Add prototype. (omp_instantiate_mappers): Add prototype. (cxx_omp_finish_mapper_clauses): Add prototype. (cxx_omp_mapper_lookup): Add prototype. (cxx_omp_extract_mapper_directive): Add prototype. (cxx_omp_map_array_section): Add prototype. * decl.cc (check_initializer): Add OpenMP declare mapper support. (cp_finish_decl): Set DECL_INITIAL for OpenMP declare mapper var decls as appropriate. * decl2.cc (mark_used): Instantiate OpenMP "declare mapper" magic var decls. * error.cc (dump_omp_declare_mapper): New function. (dump_simple_decl): Use above. * parser.cc (cp_parser_omp_clause_map): Add KIND parameter. Support "mapper" modifier. (cp_parser_omp_all_clauses): Add KIND argument to cp_parser_omp_clause_map call. (cp_parser_omp_target): Call omp_instantiate_mappers before finish_omp_clauses. (cp_parser_omp_declare_mapper): New function. (cp_parser_omp_declare): Add "declare mapper" support. * pt.cc (tsubst_decl): Adjust name of "declare mapper" magic var decls once we know their type. (tsubst_omp_clauses): Call omp_instantiate_mappers before finish_omp_clauses, for target regions. (tsubst_expr): Support OMP_DECLARE_MAPPER nodes. (instantiate_decl): Instantiate initialiser (i.e definition) for OpenMP declare mappers. * semantics.cc (gimplify.h): Include. (omp_mapper_id, omp_mapper_lookup, omp_extract_mapper_directive, cxx_omp_map_array_section, cp_check_omp_declare_mapper): New functions. (finish_omp_clauses): Delete GOMP_MAP_PUSH_MAPPER_NAME and GOMP_MAP_POP_MAPPER_NAME artificial clauses. (omp_target_walk_data): Add MAPPERS field. (finish_omp_target_clauses_r): Scan for uses of struct/union/class type variables. (finish_omp_target_clauses): Create artificial mapper binding clauses for used structs/unions/classes in offload region. gcc/fortran/ * parse.cc (tree.h, fold-const.h, tree-hash-traits.h): Add includes (for additions to omp-general.h). gcc/ * gimplify.cc (gimplify_omp_ctx): Add IMPLICIT_MAPPERS field. (new_omp_context): Initialise IMPLICIT_MAPPERS hash map. (delete_omp_context): Delete IMPLICIT_MAPPERS hash map. (instantiate_mapper_info): New structs. (remap_mapper_decl_1, omp_mapper_copy_decl, omp_instantiate_mapper, omp_instantiate_implicit_mappers): New functions. (gimplify_scan_omp_clauses): Handle MAPPER_BINDING clauses. (gimplify_adjust_omp_clauses): Instantiate implicit declared mappers. (gimplify_omp_declare_mapper): New function. (gimplify_expr): Call above function. * langhooks-def.h (lhd_omp_mapper_lookup, lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): Add prototypes. (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define macros. (LANG_HOOK_DECLS): Add above macros. * langhooks.cc (lhd_omp_mapper_lookup, lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): New dummy functions. * langhooks.h (lang_hooks_for_decls): Add OMP_FINISH_MAPPER_CLAUSES, OMP_MAPPER_LOOKUP, OMP_EXTRACT_MAPPER_DIRECTIVE, OMP_MAP_ARRAY_SECTION hooks. * omp-general.h (omp_name_type<T>): Add templatized struct, hash type traits (for omp_name_type<tree> specialization). (omp_mapper_list<T>): Add struct. * tree-core.h (omp_clause_code): Add OMP_CLAUSE__MAPPER_BINDING_. * tree-pretty-print.cc (dump_omp_clause): Support GOMP_MAP_UNSET, GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping clauses. Support OMP_CLAUSE__MAPPER_BINDING_ and OMP_DECLARE_MAPPER. * tree.cc (omp_clause_num_ops, omp_clause_code_name): Add OMP_CLAUSE__MAPPER_BINDING_. * tree.def (OMP_DECLARE_MAPPER): New tree code. * tree.h (OMP_DECLARE_MAPPER_ID, OMP_DECLARE_MAPPER_DECL, OMP_DECLARE_MAPPER_CLAUSES): New defines. (OMP_CLAUSE__MAPPER_BINDING__ID, OMP_CLAUSE__MAPPER_BINDING__DECL, OMP_CLAUSE__MAPPER_BINDING__MAPPER): New defines. include/ * gomp-constants.h (gomp_map_kind): Add GOMP_MAP_UNSET, GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping clause types. gcc/testsuite/ * c-c++-common/gomp/map-6.c: Update error scan output. * c-c++-common/gomp/declare-mapper-3.c: New test (only enabled for C++ for now). * c-c++-common/gomp/declare-mapper-4.c: Likewise. * c-c++-common/gomp/declare-mapper-5.c: Likewise. * c-c++-common/gomp/declare-mapper-6.c: Likewise. * c-c++-common/gomp/declare-mapper-7.c: Likewise. * c-c++-common/gomp/declare-mapper-8.c: Likewise. * c-c++-common/gomp/declare-mapper-9.c: Likewise. * c-c++-common/gomp/declare-mapper-10.c: Likewise. * c-c++-common/gomp/declare-mapper-12.c: Likewise. * g++.dg/gomp/declare-mapper-1.C: New test. * g++.dg/gomp/declare-mapper-2.C: New test. * g++.dg/gomp/declare-mapper-3.C: New test. libgomp/ * testsuite/libgomp.c++/declare-mapper-1.C: New test. * testsuite/libgomp.c++/declare-mapper-2.C: New test. * testsuite/libgomp.c++/declare-mapper-3.C: New test. * testsuite/libgomp.c++/declare-mapper-4.C: New test. * testsuite/libgomp.c++/declare-mapper-5.C: New test. * testsuite/libgomp.c++/declare-mapper-6.C: New test. * testsuite/libgomp.c++/declare-mapper-7.C: New test. * testsuite/libgomp.c++/declare-mapper-8.C: New test. * testsuite/libgomp.c-c++-common/declare-mapper-9.c: New test (only enabled for C++ for now). * testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise. Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-05-30Daily bump.GCC Administrator1-0/+6