From 0d01a2722671bef37b931fd1f121e44b27e68268 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 17 Jan 2022 22:52:08 +0100 Subject: Fortran: handle expansion of zero-sized array constructors gcc/fortran/ChangeLog: PR fortran/103692 * array.cc (gfc_expand_constructor): Handle zero-sized array constructors. gcc/testsuite/ChangeLog: PR fortran/103692 * gfortran.dg/pr102520.f90: Adjust error messages. * gfortran.dg/pr103692.f90: New test. --- gcc/fortran/array.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index 4723043..f1d92e0 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -1883,6 +1883,9 @@ gfc_expand_constructor (gfc_expr *e, bool fatal) gfc_expr *f; bool rc; + if (gfc_is_size_zero_array (e)) + return true; + /* If we can successfully get an array element at the max array size then the array is too big to expand, so we just return. */ f = gfc_get_array_element (e, flag_max_array_constructor); -- cgit v1.1 From 7a761ae658967dab59dca691373e3ea10707217a Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 19 Jan 2022 00:16:32 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0e8d6d8..e044230 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-01-18 Harald Anlauf + + PR fortran/103692 + * array.cc (gfc_expand_constructor): Handle zero-sized array + constructors. + 2022-01-17 Martin Liska * check.cc (gfc_check_all_any): Rename .c names to .cc. -- cgit v1.1 From d2ad748eeef0dd260f3993b8dcbffbded3240a0a Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Thu, 20 Jan 2022 13:29:48 -0800 Subject: Fortran: Fix scope for OMP AFFINITY clause iterator variables [PR103695] gfc_finish_var_decl was confused by the undocumented overloading of the proc_name field in struct gfc_namespace to contain iterator variables for the OpenMP AFFINITY clause, causing it to insert the decls in the wrong scope. This patch adds a new distinct field to hold these variables. 2022-01-20 Sandra Loosemore PR fortran/103695 PR fortran/102621 gcc/fortran * gfortran.h (struct gfc_namespace) Add omp_affinity_iterator field. * dump-parse-tree.cc (show_iterator): Use it. * openmp.cc (gfc_match_iterator): Likewise. (resolve_omp_clauses): Likewise. * trans-decl.cc (gfc_finish_var_decl): Likewise. * trans-openmp.cc (handle_iterator): Likewise. gcc/testsuite/ * gfortran.dg/gomp/affinity-clause-3.f90: Adjust pattern. * gfortran.dg/gomp/pr102621.f90: New. * gfortran.dg/gomp/pr103695.f90: New. --- gcc/fortran/dump-parse-tree.cc | 4 ++-- gcc/fortran/gfortran.h | 3 +++ gcc/fortran/openmp.cc | 6 +++--- gcc/fortran/trans-decl.cc | 3 +++ gcc/fortran/trans-openmp.cc | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index a618ae2..3112cae 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1302,10 +1302,10 @@ show_code (int level, gfc_code *c) static void show_iterator (gfc_namespace *ns) { - for (gfc_symbol *sym = ns->proc_name; sym; sym = sym->tlink) + for (gfc_symbol *sym = ns->omp_affinity_iterators; sym; sym = sym->tlink) { gfc_constructor *c; - if (sym != ns->proc_name) + if (sym != ns->omp_affinity_iterators) fputc (',', dumpfile); fputs (sym->name, dumpfile); fputc ('=', dumpfile); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 00a558a..993879f 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2107,6 +2107,9 @@ typedef struct gfc_namespace /* !$ACC ROUTINE clauses. */ gfc_omp_clauses *oacc_routine_clauses; + /* !$ACC TASK AFFINITY iterator symbols. */ + gfc_symbol *omp_affinity_iterators; + /* !$ACC ROUTINE names. */ gfc_oacc_routine_name *oacc_routine_names; diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 9b73b9f..073e5a1 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -1123,7 +1123,7 @@ gfc_match_iterator (gfc_namespace **ns, bool permit_var) if (last) last->tlink = sym; else - (*ns)->proc_name = sym; + (*ns)->omp_affinity_iterators = sym; last = sym; sym->declared_at = prev_loc; sym->ts = ts; @@ -6832,8 +6832,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, && n->u2.ns && !n->u2.ns->resolved) { n->u2.ns->resolved = 1; - for (gfc_symbol *sym = n->u2.ns->proc_name; sym; - sym = sym->tlink) + for (gfc_symbol *sym = n->u2.ns->omp_affinity_iterators; + sym; sym = sym->tlink) { gfc_constructor *c; c = gfc_constructor_first (sym->value->value.constructor); diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 1112ca9..6493cc2 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -647,6 +647,9 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) && sym->ns->proc_name->attr.flavor == FL_LABEL) /* This is a BLOCK construct. */ add_decl_as_local (decl); + else if (sym->ns->omp_affinity_iterators) + /* This is a block-local iterator. */ + add_decl_as_local (decl); else gfc_add_decl_to_parent_function (decl); } diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 9eabf68..d5a6b2d 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -2483,7 +2483,7 @@ static tree handle_iterator (gfc_namespace *ns, stmtblock_t *iter_block, tree block) { tree list = NULL_TREE; - for (gfc_symbol *sym = ns->proc_name; sym; sym = sym->tlink) + for (gfc_symbol *sym = ns->omp_affinity_iterators; sym; sym = sym->tlink) { gfc_constructor *c; gfc_se se; -- cgit v1.1 From 5fa55d55abd29c4db73965d5ac5a8619d7af6c58 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 21 Jan 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e044230..cd8bc4e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,15 @@ +2022-01-20 Sandra Loosemore + + PR fortran/103695 + PR fortran/102621 + * gfortran.h (struct gfc_namespace) Add omp_affinity_iterator + field. + * dump-parse-tree.cc (show_iterator): Use it. + * openmp.cc (gfc_match_iterator): Likewise. + (resolve_omp_clauses): Likewise. + * trans-decl.cc (gfc_finish_var_decl): Likewise. + * trans-openmp.cc (handle_iterator): Likewise. + 2022-01-18 Harald Anlauf PR fortran/103692 -- cgit v1.1 From 6c1a93102b41a558f3ad49a7c66015257535c747 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 20 Jan 2022 22:36:50 +0100 Subject: Fortran: fix simplification of TRANSFER for zero-sized character array result gcc/fortran/ChangeLog: PR fortran/104127 * simplify.cc (gfc_simplify_transfer): Ensure that the result typespec is set up for TRANSFER with MOLD of type CHARACTER including character length even if the result is a zero-sized array. gcc/testsuite/ChangeLog: PR fortran/104127 * gfortran.dg/transfer_simplify_11.f90: Fix logic. * gfortran.dg/transfer_simplify_13.f90: New test. --- gcc/fortran/simplify.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 3881370..8604162 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -8162,7 +8162,18 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size) set even for array expressions, in order to pass this information into gfc_target_interpret_expr. */ if (result->ts.type == BT_CHARACTER && gfc_is_constant_expr (mold_element)) - result->value.character.length = mold_element->value.character.length; + { + result->value.character.length = mold_element->value.character.length; + + /* Let the typespec of the result inherit the string length. + This is crucial if a resulting array has size zero. */ + if (mold_element->ts.u.cl->length) + result->ts.u.cl->length = gfc_copy_expr (mold_element->ts.u.cl->length); + else + result->ts.u.cl->length = + gfc_get_int_expr (gfc_charlen_int_kind, NULL, + mold_element->value.character.length); + } /* Set the number of elements in the result, and determine its size. */ -- cgit v1.1 From d43be9dcc1bef95d70fb411d98b4de0d83c6b85d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 23 Jan 2022 00:16:24 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index cd8bc4e..ea90c19 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-01-22 Harald Anlauf + + PR fortran/104127 + * simplify.cc (gfc_simplify_transfer): Ensure that the result + typespec is set up for TRANSFER with MOLD of type CHARACTER + including character length even if the result is a zero-sized + array. + 2022-01-20 Sandra Loosemore PR fortran/103695 -- cgit v1.1 From 9acd5a01175a3a0998eaaf306305890081d8550f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 24 Jan 2022 11:52:30 +0100 Subject: fortran: Extend -fconvert= option for ppc64le r16_ieee and r16_ibm This patch on top of the previously posted option handling changes patch allows specifying -fconvert=swap,r16_ieee etc. (but will error on it when not on powerpc64le because in the library such swapping is only implemented for HAVE_REAL_17). 2022-01-24 Jakub Jelinek * lang.opt (fconvert=): Add EnumSet property and mention also r16_ieee and r16_ibm arguments. (big-endian, little-endian, native, swap): Add Set(1) property. (r16_ieee, r16_ibm): New EnumValue entries with Set(2) property. * trans-types.cc (gfc_init_kinds): Emit gfc_fatal_error for -fconvert=r16_ieee or -fconvert=r16_ibm when R16_IEEE <=> R16_IBM conversions aren't supported. --- gcc/fortran/lang.opt | 18 ++++++++++++------ gcc/fortran/trans-types.cc | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index ab92e0e..cf39712 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -421,23 +421,29 @@ Fortran Produce a warning at runtime if a array temporary has been created for a procedure argument. fconvert= -Fortran RejectNegative Joined Enum(gfc_convert) Var(flag_convert) Init(GFC_FLAG_CONVERT_NATIVE) --fconvert= The endianness used for unformatted files. +Fortran RejectNegative Joined Enum(gfc_convert) EnumSet Var(flag_convert) Init(GFC_FLAG_CONVERT_NATIVE) +-fconvert= The endianness used for unformatted files. Enum Name(gfc_convert) Type(enum gfc_convert) UnknownError(Unrecognized option to endianness value: %qs) EnumValue -Enum(gfc_convert) String(big-endian) Value(GFC_FLAG_CONVERT_BIG) +Enum(gfc_convert) String(big-endian) Value(GFC_FLAG_CONVERT_BIG) Set(1) EnumValue -Enum(gfc_convert) String(little-endian) Value(GFC_FLAG_CONVERT_LITTLE) +Enum(gfc_convert) String(little-endian) Value(GFC_FLAG_CONVERT_LITTLE) Set(1) EnumValue -Enum(gfc_convert) String(native) Value(GFC_FLAG_CONVERT_NATIVE) +Enum(gfc_convert) String(native) Value(GFC_FLAG_CONVERT_NATIVE) Set(1) EnumValue -Enum(gfc_convert) String(swap) Value(GFC_FLAG_CONVERT_SWAP) +Enum(gfc_convert) String(swap) Value(GFC_FLAG_CONVERT_SWAP) Set(1) + +EnumValue +Enum(gfc_convert) String(r16_ieee) Value(GFC_FLAG_CONVERT_R16_IEEE) Set(2) + +EnumValue +Enum(gfc_convert) String(r16_ibm) Value(GFC_FLAG_CONVERT_R16_IBM) Set(2) fcray-pointer Fortran Var(flag_cray_pointer) diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index a56337b..3cdc529 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -527,6 +527,9 @@ gfc_init_kinds (void) } } } + else if ((flag_convert & (GFC_CONVERT_R16_IEEE | GFC_CONVERT_R16_IBM)) != 0) + gfc_fatal_error ("%<-fconvert=r16_ieee%> or %<-fconvert=r16_ibm%> not " + "supported on this architecture"); /* Choose the default integer kind. We choose 4 unless the user directs us otherwise. Even if the user specified that the default integer kind is 8, -- cgit v1.1 From bb99171b9b0f01a46bfca2d3cbd52fc6faf6cbaa Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 25 Jan 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ea90c19..0875317 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-01-24 Jakub Jelinek + + * lang.opt (fconvert=): Add EnumSet property and mention also + r16_ieee and r16_ibm arguments. + (big-endian, little-endian, native, swap): Add Set(1) property. + (r16_ieee, r16_ibm): New EnumValue entries with Set(2) property. + * trans-types.cc (gfc_init_kinds): Emit gfc_fatal_error for + -fconvert=r16_ieee or -fconvert=r16_ibm when R16_IEEE <=> R16_IBM + conversions aren't supported. + 2022-01-22 Harald Anlauf PR fortran/104127 -- cgit v1.1 From 34e8dafb76240f69c729c11cfc8c8fc4f717bc17 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 24 Jan 2022 21:40:41 +0100 Subject: Fortran: optional argument DIM for intrinsics NORM2, PARITY must be scalar gcc/fortran/ChangeLog: PR fortran/104212 * check.cc (gfc_check_norm2): Check that optional argument DIM is scalar. (gfc_check_parity): Likewise. gcc/testsuite/ChangeLog: PR fortran/104212 * gfortran.dg/argument_checking_26.f90: New test. --- gcc/fortran/check.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 5fe8d45..4fa05ee 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -4338,6 +4338,9 @@ gfc_check_norm2 (gfc_expr *array, gfc_expr *dim) if (!array_check (array, 0)) return false; + if (!dim_check (dim, 1, false)) + return false; + if (!dim_rank_check (dim, array, false)) return false; @@ -4476,6 +4479,9 @@ gfc_check_parity (gfc_expr *mask, gfc_expr *dim) if (!array_check (mask, 0)) return false; + if (!dim_check (dim, 1, false)) + return false; + if (!dim_rank_check (dim, mask, false)) return false; -- cgit v1.1 From ec543c9833c2d9283c035cd8430849eb4ec04406 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 25 Jan 2022 21:56:39 +0100 Subject: Fortran: MOLD argument to TRANSFER intrinsic having storage size zero gcc/fortran/ChangeLog: PR fortran/104227 * check.cc (gfc_calculate_transfer_sizes): Fix checking of arrays passed as MOLD argument to the TRANSFER intrinsic for having storage size zero. gcc/testsuite/ChangeLog: PR fortran/104227 * gfortran.dg/transfer_check_6.f90: New test. --- gcc/fortran/check.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 4fa05ee..d6c6767 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -6151,7 +6151,7 @@ gfc_calculate_transfer_sizes (gfc_expr *source, gfc_expr *mold, gfc_expr *size, * If SIZE is present, the result is an array of rank one and size SIZE. */ if (result_elt_size == 0 && *source_size > 0 && !size - && mold->expr_type == EXPR_ARRAY) + && (mold->expr_type == EXPR_ARRAY || mold->rank)) { gfc_error ("% argument of % intrinsic at %L is an " "array and shall not have storage size 0 when % " -- cgit v1.1 From e0b8716f53ed6455e9f18931940141692793068d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 26 Jan 2022 00:16:38 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0875317..a55e851 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,17 @@ +2022-01-25 Harald Anlauf + + PR fortran/104227 + * check.cc (gfc_calculate_transfer_sizes): Fix checking of arrays + passed as MOLD argument to the TRANSFER intrinsic for having + storage size zero. + +2022-01-25 Harald Anlauf + + PR fortran/104212 + * check.cc (gfc_check_norm2): Check that optional argument DIM is + scalar. + (gfc_check_parity): Likewise. + 2022-01-24 Jakub Jelinek * lang.opt (fconvert=): Add EnumSet property and mention also -- cgit v1.1 From 7eb61a45a171d4f8f5bf4d4f469d42e657c69a6a Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 27 Jan 2022 20:23:00 +0100 Subject: Fortran: add missing conversions for result of intrinsics to result type gcc/fortran/ChangeLog: PR fortran/84784 * trans-intrinsic.cc (conv_intrinsic_image_status): Convert result to resulting (default) integer type. (conv_intrinsic_team_number): Likewise. (gfc_conv_intrinsic_popcnt_poppar): Likewise. gcc/testsuite/ChangeLog: PR fortran/84784 * gfortran.dg/pr84784.f90: New test. --- gcc/fortran/trans-intrinsic.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index fccf0a9..da854fa 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -2620,7 +2620,7 @@ conv_intrinsic_image_status (gfc_se *se, gfc_expr *expr) else gcc_unreachable (); - se->expr = tmp; + se->expr = fold_convert (gfc_get_int_type (gfc_default_integer_kind), tmp); } static void @@ -2662,7 +2662,7 @@ conv_intrinsic_team_number (gfc_se *se, gfc_expr *expr) else gcc_unreachable (); - se->expr = tmp; + se->expr = fold_convert (gfc_get_int_type (gfc_default_integer_kind), tmp); } @@ -7255,12 +7255,13 @@ gfc_conv_intrinsic_popcnt_poppar (gfc_se * se, gfc_expr *expr, int parity) /* Combine the results. */ if (parity) - se->expr = fold_build2_loc (input_location, BIT_XOR_EXPR, result_type, - call1, call2); + se->expr = fold_build2_loc (input_location, BIT_XOR_EXPR, + integer_type_node, call1, call2); else - se->expr = fold_build2_loc (input_location, PLUS_EXPR, result_type, - call1, call2); + se->expr = fold_build2_loc (input_location, PLUS_EXPR, + integer_type_node, call1, call2); + se->expr = convert (result_type, se->expr); return; } -- cgit v1.1 From b51fb28ed294cdf19087ca9d9ad107c9c52bec42 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 23 Jan 2022 21:55:33 +0100 Subject: Fortran: fix issues with internal conversion between default and wide char gcc/fortran/ChangeLog: PR fortran/104128 * expr.cc (gfc_copy_expr): Convert internal representation of string to wide char in value only for default character kind. * target-memory.cc (interpret_array): Pass flag for conversion of wide chars. (gfc_target_interpret_expr): Likewise. gcc/testsuite/ChangeLog: PR fortran/104128 * gfortran.dg/transfer_simplify_14.f90: New test. --- gcc/fortran/expr.cc | 3 ++- gcc/fortran/target-memory.cc | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 279d9b3..ed82a94 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -312,7 +312,8 @@ gfc_copy_expr (gfc_expr *p) break; case BT_CHARACTER: - if (p->representation.string) + if (p->representation.string + && p->ts.kind == gfc_default_character_kind) q->value.character.string = gfc_char_to_widechar (q->representation.string); else diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc index 361907b..7ce7d73 100644 --- a/gcc/fortran/target-memory.cc +++ b/gcc/fortran/target-memory.cc @@ -365,7 +365,8 @@ gfc_target_encode_expr (gfc_expr *source, unsigned char *buffer, static size_t -interpret_array (unsigned char *buffer, size_t buffer_size, gfc_expr *result) +interpret_array (unsigned char *buffer, size_t buffer_size, gfc_expr *result, + bool convert_widechar) { gfc_constructor_base base = NULL; size_t array_size = 1; @@ -390,7 +391,7 @@ interpret_array (unsigned char *buffer, size_t buffer_size, gfc_expr *result) gfc_constructor_append_expr (&base, e, &result->where); ptr += gfc_target_interpret_expr (&buffer[ptr], buffer_size - ptr, e, - true); + convert_widechar); } result->value.constructor = base; @@ -580,7 +581,7 @@ gfc_target_interpret_expr (unsigned char *buffer, size_t buffer_size, gfc_expr *result, bool convert_widechar) { if (result->expr_type == EXPR_ARRAY) - return interpret_array (buffer, buffer_size, result); + return interpret_array (buffer, buffer_size, result, convert_widechar); switch (result->ts.type) { -- cgit v1.1 From 99f17e996f21d0ed64c36ed1e52977b705143522 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 28 Jan 2022 00:16:32 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a55e851..877f345 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,20 @@ +2022-01-27 Harald Anlauf + + PR fortran/104128 + * expr.cc (gfc_copy_expr): Convert internal representation of + string to wide char in value only for default character kind. + * target-memory.cc (interpret_array): Pass flag for conversion of + wide chars. + (gfc_target_interpret_expr): Likewise. + +2022-01-27 Harald Anlauf + + PR fortran/84784 + * trans-intrinsic.cc (conv_intrinsic_image_status): Convert result + to resulting (default) integer type. + (conv_intrinsic_team_number): Likewise. + (gfc_conv_intrinsic_popcnt_poppar): Likewise. + 2022-01-25 Harald Anlauf PR fortran/104227 -- cgit v1.1 From c9c48ab7bad9fe5e096076e56a60ce0a5a2b65f7 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Fri, 28 Jan 2022 09:20:23 +0100 Subject: Prevent malicious descriptor stacking for scalar components. gcc/fortran/ChangeLog: PR fortran/103790 * trans-array.cc (structure_alloc_comps): Prevent descriptor stacking for non-array data; do not broadcast caf-tokens. * trans-intrinsic.cc (conv_co_collective): Prevent generation of unused descriptor. gcc/testsuite/ChangeLog: PR fortran/103790 * gfortran.dg/coarray_collectives_18.f90: New test. --- gcc/fortran/trans-array.cc | 71 +++++++++++++++++++++++++++--------------- gcc/fortran/trans-intrinsic.cc | 40 +++++++++++++----------- 2 files changed, 68 insertions(+), 43 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 2f0c8a4..1234932 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9102,6 +9102,10 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, continue; } + /* Do not broadcast a caf_token. These are local to the image. */ + if (attr->caf_token) + continue; + add_when_allocated = NULL_TREE; if (cmp_has_alloc_comps && !c->attr.pointer && !c->attr.proc_pointer) @@ -9134,10 +9138,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, if (attr->dimension) { tmp = gfc_get_element_type (TREE_TYPE (comp)); - ubound = gfc_full_array_size (&tmpblock, comp, - c->ts.type == BT_CLASS - ? CLASS_DATA (c)->as->rank - : c->as->rank); + if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) + ubound = GFC_TYPE_ARRAY_SIZE (TREE_TYPE (comp)); + else + ubound = gfc_full_array_size (&tmpblock, comp, + c->ts.type == BT_CLASS + ? CLASS_DATA (c)->as->rank + : c->as->rank); } else { @@ -9145,26 +9152,36 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, ubound = build_int_cst (gfc_array_index_type, 1); } - cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node, - &ubound, 1, - GFC_ARRAY_ALLOCATABLE, false); + /* Treat strings like arrays. Or the other way around, do not + * generate an additional array layer for scalar components. */ + if (attr->dimension || c->ts.type == BT_CHARACTER) + { + cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node, + &ubound, 1, + GFC_ARRAY_ALLOCATABLE, false); - cdesc = gfc_create_var (cdesc, "cdesc"); - DECL_ARTIFICIAL (cdesc) = 1; + cdesc = gfc_create_var (cdesc, "cdesc"); + DECL_ARTIFICIAL (cdesc) = 1; - gfc_add_modify (&tmpblock, gfc_conv_descriptor_dtype (cdesc), - gfc_get_dtype_rank_type (1, tmp)); - gfc_conv_descriptor_lbound_set (&tmpblock, cdesc, - gfc_index_zero_node, - gfc_index_one_node); - gfc_conv_descriptor_stride_set (&tmpblock, cdesc, - gfc_index_zero_node, - gfc_index_one_node); - gfc_conv_descriptor_ubound_set (&tmpblock, cdesc, - gfc_index_zero_node, ubound); + gfc_add_modify (&tmpblock, gfc_conv_descriptor_dtype (cdesc), + gfc_get_dtype_rank_type (1, tmp)); + gfc_conv_descriptor_lbound_set (&tmpblock, cdesc, + gfc_index_zero_node, + gfc_index_one_node); + gfc_conv_descriptor_stride_set (&tmpblock, cdesc, + gfc_index_zero_node, + gfc_index_one_node); + gfc_conv_descriptor_ubound_set (&tmpblock, cdesc, + gfc_index_zero_node, ubound); + } if (attr->dimension) - comp = gfc_conv_descriptor_data_get (comp); + { + if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) + comp = gfc_conv_descriptor_data_get (comp); + else + comp = gfc_build_addr_expr (NULL_TREE, comp); + } else { gfc_se se; @@ -9172,14 +9189,18 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, gfc_init_se (&se, NULL); comp = gfc_conv_scalar_to_descriptor (&se, comp, - c->ts.type == BT_CLASS - ? CLASS_DATA (c)->attr - : c->attr); - comp = gfc_build_addr_expr (NULL_TREE, comp); + c->ts.type == BT_CLASS + ? CLASS_DATA (c)->attr + : c->attr); + if (c->ts.type == BT_CHARACTER) + comp = gfc_build_addr_expr (NULL_TREE, comp); gfc_add_block_to_block (&tmpblock, &se.pre); } - gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp); + if (attr->dimension || c->ts.type == BT_CHARACTER) + gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp); + else + cdesc = comp; tree fndecl; diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index da854fa..e680de1 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -11212,24 +11212,31 @@ conv_co_collective (gfc_code *code) return gfc_finish_block (&block); } + gfc_symbol *derived = code->ext.actual->expr->ts.type == BT_DERIVED + ? code->ext.actual->expr->ts.u.derived : NULL; + /* Handle the array. */ gfc_init_se (&argse, NULL); - if (code->ext.actual->expr->rank == 0) - { - symbol_attribute attr; - gfc_clear_attr (&attr); - gfc_init_se (&argse, NULL); - gfc_conv_expr (&argse, code->ext.actual->expr); - gfc_add_block_to_block (&block, &argse.pre); - gfc_add_block_to_block (&post_block, &argse.post); - array = gfc_conv_scalar_to_descriptor (&argse, argse.expr, attr); - array = gfc_build_addr_expr (NULL_TREE, array); - } - else + if (!derived || !derived->attr.alloc_comp + || code->resolved_isym->id != GFC_ISYM_CO_BROADCAST) { - argse.want_pointer = 1; - gfc_conv_expr_descriptor (&argse, code->ext.actual->expr); - array = argse.expr; + if (code->ext.actual->expr->rank == 0) + { + symbol_attribute attr; + gfc_clear_attr (&attr); + gfc_init_se (&argse, NULL); + gfc_conv_expr (&argse, code->ext.actual->expr); + gfc_add_block_to_block (&block, &argse.pre); + gfc_add_block_to_block (&post_block, &argse.post); + array = gfc_conv_scalar_to_descriptor (&argse, argse.expr, attr); + array = gfc_build_addr_expr (NULL_TREE, array); + } + else + { + argse.want_pointer = 1; + gfc_conv_expr_descriptor (&argse, code->ext.actual->expr); + array = argse.expr; + } } gfc_add_block_to_block (&block, &argse.pre); @@ -11290,9 +11297,6 @@ conv_co_collective (gfc_code *code) gcc_unreachable (); } - gfc_symbol *derived = code->ext.actual->expr->ts.type == BT_DERIVED - ? code->ext.actual->expr->ts.u.derived : NULL; - if (derived && derived->attr.alloc_comp && code->resolved_isym->id == GFC_ISYM_CO_BROADCAST) /* The derived type has the attribute 'alloc_comp'. */ -- cgit v1.1 From 6da86c254aa4d68aab2b1f501a88d53f8777178b Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Fri, 28 Jan 2022 10:35:07 +0100 Subject: Revert "Prevent malicious descriptor stacking for scalar components." Breaks bootstrap. This reverts commit c9c48ab7bad9fe5e096076e56a60ce0a5a2b65f7. --- gcc/fortran/trans-array.cc | 71 +++++++++++++++--------------------------- gcc/fortran/trans-intrinsic.cc | 40 +++++++++++------------- 2 files changed, 43 insertions(+), 68 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 1234932..2f0c8a4 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9102,10 +9102,6 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, continue; } - /* Do not broadcast a caf_token. These are local to the image. */ - if (attr->caf_token) - continue; - add_when_allocated = NULL_TREE; if (cmp_has_alloc_comps && !c->attr.pointer && !c->attr.proc_pointer) @@ -9138,13 +9134,10 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, if (attr->dimension) { tmp = gfc_get_element_type (TREE_TYPE (comp)); - if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) - ubound = GFC_TYPE_ARRAY_SIZE (TREE_TYPE (comp)); - else - ubound = gfc_full_array_size (&tmpblock, comp, - c->ts.type == BT_CLASS - ? CLASS_DATA (c)->as->rank - : c->as->rank); + ubound = gfc_full_array_size (&tmpblock, comp, + c->ts.type == BT_CLASS + ? CLASS_DATA (c)->as->rank + : c->as->rank); } else { @@ -9152,36 +9145,26 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, ubound = build_int_cst (gfc_array_index_type, 1); } - /* Treat strings like arrays. Or the other way around, do not - * generate an additional array layer for scalar components. */ - if (attr->dimension || c->ts.type == BT_CHARACTER) - { - cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node, - &ubound, 1, - GFC_ARRAY_ALLOCATABLE, false); + cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node, + &ubound, 1, + GFC_ARRAY_ALLOCATABLE, false); - cdesc = gfc_create_var (cdesc, "cdesc"); - DECL_ARTIFICIAL (cdesc) = 1; + cdesc = gfc_create_var (cdesc, "cdesc"); + DECL_ARTIFICIAL (cdesc) = 1; - gfc_add_modify (&tmpblock, gfc_conv_descriptor_dtype (cdesc), - gfc_get_dtype_rank_type (1, tmp)); - gfc_conv_descriptor_lbound_set (&tmpblock, cdesc, - gfc_index_zero_node, - gfc_index_one_node); - gfc_conv_descriptor_stride_set (&tmpblock, cdesc, - gfc_index_zero_node, - gfc_index_one_node); - gfc_conv_descriptor_ubound_set (&tmpblock, cdesc, - gfc_index_zero_node, ubound); - } + gfc_add_modify (&tmpblock, gfc_conv_descriptor_dtype (cdesc), + gfc_get_dtype_rank_type (1, tmp)); + gfc_conv_descriptor_lbound_set (&tmpblock, cdesc, + gfc_index_zero_node, + gfc_index_one_node); + gfc_conv_descriptor_stride_set (&tmpblock, cdesc, + gfc_index_zero_node, + gfc_index_one_node); + gfc_conv_descriptor_ubound_set (&tmpblock, cdesc, + gfc_index_zero_node, ubound); if (attr->dimension) - { - if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) - comp = gfc_conv_descriptor_data_get (comp); - else - comp = gfc_build_addr_expr (NULL_TREE, comp); - } + comp = gfc_conv_descriptor_data_get (comp); else { gfc_se se; @@ -9189,18 +9172,14 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, gfc_init_se (&se, NULL); comp = gfc_conv_scalar_to_descriptor (&se, comp, - c->ts.type == BT_CLASS - ? CLASS_DATA (c)->attr - : c->attr); - if (c->ts.type == BT_CHARACTER) - comp = gfc_build_addr_expr (NULL_TREE, comp); + c->ts.type == BT_CLASS + ? CLASS_DATA (c)->attr + : c->attr); + comp = gfc_build_addr_expr (NULL_TREE, comp); gfc_add_block_to_block (&tmpblock, &se.pre); } - if (attr->dimension || c->ts.type == BT_CHARACTER) - gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp); - else - cdesc = comp; + gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp); tree fndecl; diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index e680de1..da854fa 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -11212,31 +11212,24 @@ conv_co_collective (gfc_code *code) return gfc_finish_block (&block); } - gfc_symbol *derived = code->ext.actual->expr->ts.type == BT_DERIVED - ? code->ext.actual->expr->ts.u.derived : NULL; - /* Handle the array. */ gfc_init_se (&argse, NULL); - if (!derived || !derived->attr.alloc_comp - || code->resolved_isym->id != GFC_ISYM_CO_BROADCAST) + if (code->ext.actual->expr->rank == 0) { - if (code->ext.actual->expr->rank == 0) - { - symbol_attribute attr; - gfc_clear_attr (&attr); - gfc_init_se (&argse, NULL); - gfc_conv_expr (&argse, code->ext.actual->expr); - gfc_add_block_to_block (&block, &argse.pre); - gfc_add_block_to_block (&post_block, &argse.post); - array = gfc_conv_scalar_to_descriptor (&argse, argse.expr, attr); - array = gfc_build_addr_expr (NULL_TREE, array); - } - else - { - argse.want_pointer = 1; - gfc_conv_expr_descriptor (&argse, code->ext.actual->expr); - array = argse.expr; - } + symbol_attribute attr; + gfc_clear_attr (&attr); + gfc_init_se (&argse, NULL); + gfc_conv_expr (&argse, code->ext.actual->expr); + gfc_add_block_to_block (&block, &argse.pre); + gfc_add_block_to_block (&post_block, &argse.post); + array = gfc_conv_scalar_to_descriptor (&argse, argse.expr, attr); + array = gfc_build_addr_expr (NULL_TREE, array); + } + else + { + argse.want_pointer = 1; + gfc_conv_expr_descriptor (&argse, code->ext.actual->expr); + array = argse.expr; } gfc_add_block_to_block (&block, &argse.pre); @@ -11297,6 +11290,9 @@ conv_co_collective (gfc_code *code) gcc_unreachable (); } + gfc_symbol *derived = code->ext.actual->expr->ts.type == BT_DERIVED + ? code->ext.actual->expr->ts.u.derived : NULL; + if (derived && derived->attr.alloc_comp && code->resolved_isym->id == GFC_ISYM_CO_BROADCAST) /* The derived type has the attribute 'alloc_comp'. */ -- cgit v1.1 From 26e237fb5b83582b30ef7c5a388bc4e968a5a289 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Fri, 28 Jan 2022 12:34:17 +0100 Subject: Prevent malicious descriptor stacking for scalar components [V2]. gcc/fortran/ChangeLog: PR fortran/103790 * trans-array.cc (structure_alloc_comps): Prevent descriptor stacking for non-array data; do not broadcast caf-tokens. * trans-intrinsic.cc (conv_co_collective): Prevent generation of unused descriptor. gcc/testsuite/ChangeLog: PR fortran/103790 * gfortran.dg/coarray_collectives_18.f90: New test. --- gcc/fortran/trans-array.cc | 74 ++++++++++++++++++++++++++++-------------- gcc/fortran/trans-intrinsic.cc | 40 +++++++++++++---------- 2 files changed, 71 insertions(+), 43 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 2f0c8a4..cfb6eac 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9102,6 +9102,10 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, continue; } + /* Do not broadcast a caf_token. These are local to the image. */ + if (attr->caf_token) + continue; + add_when_allocated = NULL_TREE; if (cmp_has_alloc_comps && !c->attr.pointer && !c->attr.proc_pointer) @@ -9134,10 +9138,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, if (attr->dimension) { tmp = gfc_get_element_type (TREE_TYPE (comp)); - ubound = gfc_full_array_size (&tmpblock, comp, - c->ts.type == BT_CLASS - ? CLASS_DATA (c)->as->rank - : c->as->rank); + if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) + ubound = GFC_TYPE_ARRAY_SIZE (TREE_TYPE (comp)); + else + ubound = gfc_full_array_size (&tmpblock, comp, + c->ts.type == BT_CLASS + ? CLASS_DATA (c)->as->rank + : c->as->rank); } else { @@ -9145,26 +9152,39 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, ubound = build_int_cst (gfc_array_index_type, 1); } - cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node, - &ubound, 1, - GFC_ARRAY_ALLOCATABLE, false); + /* Treat strings like arrays. Or the other way around, do not + * generate an additional array layer for scalar components. */ + if (attr->dimension || c->ts.type == BT_CHARACTER) + { + cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node, + &ubound, 1, + GFC_ARRAY_ALLOCATABLE, false); - cdesc = gfc_create_var (cdesc, "cdesc"); - DECL_ARTIFICIAL (cdesc) = 1; + cdesc = gfc_create_var (cdesc, "cdesc"); + DECL_ARTIFICIAL (cdesc) = 1; - gfc_add_modify (&tmpblock, gfc_conv_descriptor_dtype (cdesc), - gfc_get_dtype_rank_type (1, tmp)); - gfc_conv_descriptor_lbound_set (&tmpblock, cdesc, - gfc_index_zero_node, - gfc_index_one_node); - gfc_conv_descriptor_stride_set (&tmpblock, cdesc, - gfc_index_zero_node, - gfc_index_one_node); - gfc_conv_descriptor_ubound_set (&tmpblock, cdesc, - gfc_index_zero_node, ubound); + gfc_add_modify (&tmpblock, gfc_conv_descriptor_dtype (cdesc), + gfc_get_dtype_rank_type (1, tmp)); + gfc_conv_descriptor_lbound_set (&tmpblock, cdesc, + gfc_index_zero_node, + gfc_index_one_node); + gfc_conv_descriptor_stride_set (&tmpblock, cdesc, + gfc_index_zero_node, + gfc_index_one_node); + gfc_conv_descriptor_ubound_set (&tmpblock, cdesc, + gfc_index_zero_node, ubound); + } + else + /* Prevent warning. */ + cdesc = NULL_TREE; if (attr->dimension) - comp = gfc_conv_descriptor_data_get (comp); + { + if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) + comp = gfc_conv_descriptor_data_get (comp); + else + comp = gfc_build_addr_expr (NULL_TREE, comp); + } else { gfc_se se; @@ -9172,14 +9192,18 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, gfc_init_se (&se, NULL); comp = gfc_conv_scalar_to_descriptor (&se, comp, - c->ts.type == BT_CLASS - ? CLASS_DATA (c)->attr - : c->attr); - comp = gfc_build_addr_expr (NULL_TREE, comp); + c->ts.type == BT_CLASS + ? CLASS_DATA (c)->attr + : c->attr); + if (c->ts.type == BT_CHARACTER) + comp = gfc_build_addr_expr (NULL_TREE, comp); gfc_add_block_to_block (&tmpblock, &se.pre); } - gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp); + if (attr->dimension || c->ts.type == BT_CHARACTER) + gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp); + else + cdesc = comp; tree fndecl; diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index da854fa..e680de1 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -11212,24 +11212,31 @@ conv_co_collective (gfc_code *code) return gfc_finish_block (&block); } + gfc_symbol *derived = code->ext.actual->expr->ts.type == BT_DERIVED + ? code->ext.actual->expr->ts.u.derived : NULL; + /* Handle the array. */ gfc_init_se (&argse, NULL); - if (code->ext.actual->expr->rank == 0) - { - symbol_attribute attr; - gfc_clear_attr (&attr); - gfc_init_se (&argse, NULL); - gfc_conv_expr (&argse, code->ext.actual->expr); - gfc_add_block_to_block (&block, &argse.pre); - gfc_add_block_to_block (&post_block, &argse.post); - array = gfc_conv_scalar_to_descriptor (&argse, argse.expr, attr); - array = gfc_build_addr_expr (NULL_TREE, array); - } - else + if (!derived || !derived->attr.alloc_comp + || code->resolved_isym->id != GFC_ISYM_CO_BROADCAST) { - argse.want_pointer = 1; - gfc_conv_expr_descriptor (&argse, code->ext.actual->expr); - array = argse.expr; + if (code->ext.actual->expr->rank == 0) + { + symbol_attribute attr; + gfc_clear_attr (&attr); + gfc_init_se (&argse, NULL); + gfc_conv_expr (&argse, code->ext.actual->expr); + gfc_add_block_to_block (&block, &argse.pre); + gfc_add_block_to_block (&post_block, &argse.post); + array = gfc_conv_scalar_to_descriptor (&argse, argse.expr, attr); + array = gfc_build_addr_expr (NULL_TREE, array); + } + else + { + argse.want_pointer = 1; + gfc_conv_expr_descriptor (&argse, code->ext.actual->expr); + array = argse.expr; + } } gfc_add_block_to_block (&block, &argse.pre); @@ -11290,9 +11297,6 @@ conv_co_collective (gfc_code *code) gcc_unreachable (); } - gfc_symbol *derived = code->ext.actual->expr->ts.type == BT_DERIVED - ? code->ext.actual->expr->ts.u.derived : NULL; - if (derived && derived->attr.alloc_comp && code->resolved_isym->id == GFC_ISYM_CO_BROADCAST) /* The derived type has the attribute 'alloc_comp'. */ -- cgit v1.1 From f6f2d6cfec1c2fe9570b98211be58329d8d7749b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 29 Jan 2022 00:16:22 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 877f345..a755caf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,30 @@ +2022-01-28 Andre Vehreschild + + PR fortran/103790 + * trans-array.cc (structure_alloc_comps): Prevent descriptor + stacking for non-array data; do not broadcast caf-tokens. + * trans-intrinsic.cc (conv_co_collective): Prevent generation + of unused descriptor. + +2022-01-28 Andre Vehreschild + + Revert: + 2022-01-28 Andre Vehreschild + + PR fortran/103790 + * trans-array.cc (structure_alloc_comps): Prevent descriptor + stacking for non-array data; do not broadcast caf-tokens. + * trans-intrinsic.cc (conv_co_collective): Prevent generation + of unused descriptor. + +2022-01-28 Andre Vehreschild + + PR fortran/103790 + * trans-array.cc (structure_alloc_comps): Prevent descriptor + stacking for non-array data; do not broadcast caf-tokens. + * trans-intrinsic.cc (conv_co_collective): Prevent generation + of unused descriptor. + 2022-01-27 Harald Anlauf PR fortran/104128 -- cgit v1.1 From 447047a8f95c6bf4b1873f390c833e91aa8af18c Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 1 Feb 2022 21:36:42 +0100 Subject: Fortran: error recovery when simplifying EOSHIFT gcc/fortran/ChangeLog: PR fortran/104331 * simplify.cc (gfc_simplify_eoshift): Avoid NULL pointer dereference when shape is not set. gcc/testsuite/ChangeLog: PR fortran/104331 * gfortran.dg/eoshift_9.f90: New test. --- gcc/fortran/simplify.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 8604162..6483f9c 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -2572,6 +2572,9 @@ gfc_simplify_eoshift (gfc_expr *array, gfc_expr *shift, gfc_expr *boundary, if (arraysize == 0) goto final; + if (array->shape == NULL) + goto final; + arrayvec = XCNEWVEC (gfc_expr *, arraysize); array_ctor = gfc_constructor_first (array->value.constructor); for (i = 0; i < arraysize; i++) -- cgit v1.1 From ae7e4af964eaa80a3d7c43e4a7e1864d9a7cb06b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 2 Feb 2022 00:17:16 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a755caf..83a7310 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-02-01 Harald Anlauf + + PR fortran/104331 + * simplify.cc (gfc_simplify_eoshift): Avoid NULL pointer + dereference when shape is not set. + 2022-01-28 Andre Vehreschild PR fortran/103790 -- cgit v1.1 From 54d21dd5b5c5c5539505b3e037cdecb3b0ab3918 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 3 Feb 2022 09:01:07 +0100 Subject: openmp, fortran: Improve !$omp atomic checks [PR104328] The testcase shows some cases that weren't verified and we ICE on invalid because of that. One problem is that unlike before, we weren't checking if some expression is EXPR_VARIABLE with non-NULL symtree in the case where there was a conversion around it. The other two issues is that we check that in an IF ->block is non-NULL and then immediately dereference ->block->next->op, but on invalid code with no statements in the then clause ->block->next might be NULL. 2022-02-02 Jakub Jelinek PR fortran/104328 * openmp.cc (is_scalar_intrinsic_expr): If must_be_var && conv_ok and expr is conversion, verify it is a conversion from EXPR_VARIABLE with non-NULL symtree. Check ->block->next before dereferencing it. * gfortran.dg/gomp/atomic-27.f90: New test. --- gcc/fortran/openmp.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 073e5a1..38c67e1 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7660,9 +7660,16 @@ static bool is_scalar_intrinsic_expr (gfc_expr *expr, bool must_be_var, bool conv_ok) { if (must_be_var - && (expr->expr_type != EXPR_VARIABLE || !expr->symtree) - && (!conv_ok || !is_conversion (expr, true, true))) - return false; + && (expr->expr_type != EXPR_VARIABLE || !expr->symtree)) + { + if (!conv_ok) + return false; + gfc_expr *conv = is_conversion (expr, true, true); + if (!conv) + return false; + if (conv->expr_type != EXPR_VARIABLE || !conv->symtree) + return false; + } return (expr->rank == 0 && !gfc_is_coindexed (expr) && (expr->ts.type == BT_INTEGER @@ -7705,6 +7712,7 @@ resolve_omp_atomic (gfc_code *code) if (next->op == EXEC_IF && next->block && next->block->op == EXEC_IF + && next->block->next && next->block->next->op == EXEC_ASSIGN) { comp_cond = next->block->expr1; @@ -7757,6 +7765,7 @@ resolve_omp_atomic (gfc_code *code) if (code->op == EXEC_IF && code->block && code->block->op == EXEC_IF + && code->block->next && code->block->next->op == EXEC_ASSIGN) { comp_cond = code->block->expr1; -- cgit v1.1 From 4e4252db0348a7274663a892c3a96d3ed7702aff Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 1 Feb 2022 23:33:24 +0100 Subject: Fortran: reject simplifying TRANSFER for MOLD with storage size 0 gcc/fortran/ChangeLog: PR fortran/104311 * check.cc (gfc_calculate_transfer_sizes): Checks for case when storage size of SOURCE is greater than zero while the storage size of MOLD is zero and MOLD is an array shall not depend on SIZE. gcc/testsuite/ChangeLog: PR fortran/104311 * gfortran.dg/transfer_simplify_15.f90: New test. --- gcc/fortran/check.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index d6c6767..fc97bb1 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -6150,7 +6150,7 @@ gfc_calculate_transfer_sizes (gfc_expr *source, gfc_expr *mold, gfc_expr *size, * representation is not shorter than that of SOURCE. * If SIZE is present, the result is an array of rank one and size SIZE. */ - if (result_elt_size == 0 && *source_size > 0 && !size + if (result_elt_size == 0 && *source_size > 0 && (mold->expr_type == EXPR_ARRAY || mold->rank)) { gfc_error ("% argument of % intrinsic at %L is an " -- cgit v1.1 From 682ede395918c830eeaedf10fae1ad7db00bcab5 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 4 Feb 2022 00:16:24 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 83a7310..2d19d1e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,17 @@ +2022-02-03 Harald Anlauf + + PR fortran/104311 + * check.cc (gfc_calculate_transfer_sizes): Checks for case when + storage size of SOURCE is greater than zero while the storage size + of MOLD is zero and MOLD is an array shall not depend on SIZE. + +2022-02-03 Jakub Jelinek + + PR fortran/104328 + * openmp.cc (is_scalar_intrinsic_expr): If must_be_var && conv_ok + and expr is conversion, verify it is a conversion from EXPR_VARIABLE + with non-NULL symtree. Check ->block->next before dereferencing it. + 2022-02-01 Harald Anlauf PR fortran/104331 -- cgit v1.1 From f3ffea93ef31c03ad8cdcb54e71ec868b57b264f Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 6 Feb 2022 21:47:20 +0100 Subject: Fortran: try simplifications during reductions of array constructors gcc/fortran/ChangeLog: PR fortran/66193 * arith.cc (reduce_binary_ac): When reducing binary expressions, try simplification. Handle case of empty constructor. (reduce_binary_ca): Likewise. gcc/testsuite/ChangeLog: PR fortran/66193 * gfortran.dg/array_constructor_55.f90: New test. --- gcc/fortran/arith.cc | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index b3323ecf..06e032e 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -1305,6 +1305,8 @@ reduce_binary_ac (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **), head = gfc_constructor_copy (op1->value.constructor); for (c = gfc_constructor_first (head); c; c = gfc_constructor_next (c)) { + gfc_simplify_expr (c->expr, 0); + if (c->expr->expr_type == EXPR_CONSTANT) rc = eval (c->expr, op2, &r); else @@ -1321,9 +1323,19 @@ reduce_binary_ac (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **), else { gfc_constructor *c = gfc_constructor_first (head); - r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind, - &op1->where); - r->shape = gfc_copy_shape (op1->shape, op1->rank); + if (c) + { + r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind, + &op1->where); + r->shape = gfc_copy_shape (op1->shape, op1->rank); + } + else + { + gcc_assert (op1->ts.type != BT_UNKNOWN); + r = gfc_get_array_expr (op1->ts.type, op1->ts.kind, + &op1->where); + r->shape = gfc_get_shape (op1->rank); + } r->rank = op1->rank; r->value.constructor = head; *result = r; @@ -1345,6 +1357,8 @@ reduce_binary_ca (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **), head = gfc_constructor_copy (op2->value.constructor); for (c = gfc_constructor_first (head); c; c = gfc_constructor_next (c)) { + gfc_simplify_expr (c->expr, 0); + if (c->expr->expr_type == EXPR_CONSTANT) rc = eval (op1, c->expr, &r); else @@ -1361,9 +1375,19 @@ reduce_binary_ca (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **), else { gfc_constructor *c = gfc_constructor_first (head); - r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind, - &op2->where); - r->shape = gfc_copy_shape (op2->shape, op2->rank); + if (c) + { + r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind, + &op2->where); + r->shape = gfc_copy_shape (op2->shape, op2->rank); + } + else + { + gcc_assert (op2->ts.type != BT_UNKNOWN); + r = gfc_get_array_expr (op2->ts.type, op2->ts.kind, + &op2->where); + r->shape = gfc_get_shape (op2->rank); + } r->rank = op2->rank; r->value.constructor = head; *result = r; -- cgit v1.1 From 3adf509fe6feca9442fb36c35dd9a81a3a369d08 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 10 Feb 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2d19d1e..7c8c265 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-02-09 Harald Anlauf + + PR fortran/66193 + * arith.cc (reduce_binary_ac): When reducing binary expressions, + try simplification. Handle case of empty constructor. + (reduce_binary_ca): Likewise. + 2022-02-03 Harald Anlauf PR fortran/104311 -- cgit v1.1 From bbb7f8604e1dfc08f44354cfd93d2287f2fdd489 Mon Sep 17 00:00:00 2001 From: Marcel Vollweiler Date: Wed, 9 Feb 2022 23:47:12 -0800 Subject: C, C++, Fortran, OpenMP: Add 'has_device_addr' clause to 'target' construct. This patch adds the 'has_device_addr' clause to the OpenMP 'target' construct which was introduced in OpenMP 5.1 (OpenMP API 5.1 specification pp. 197ff): has_device_addr(list) "The has_device_addr clause indicates that its list items already have device addresses and therefore they may be directly accessed from a target device. If the device address of a list item is not for the device on which the target region executes, accessing the list item inside the region results in unspecified behavior. The list items may include array sections." (p. 200) "A list item may not be specified in both an is_device_ptr clause and a has_device_addr clause on the directive." (p. 202) "A list item that appears in an is_device_ptr or a has_device_addr clause must not be specified in any data-sharing attribute clause on the same target construct." (p. 203) gcc/c-family/ChangeLog: * c-omp.cc (c_omp_split_clauses): Added OMP_CLAUSE_HAS_DEVICE_ADDR case. * c-pragma.h (enum pragma_kind): Added 5.1 in comment. (enum pragma_omp_clause): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_name): Parse 'has_device_addr' clause. (c_parser_omp_variable_list): Handle array sections. (c_parser_omp_clause_has_device_addr): Added. (c_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR case. (c_parser_omp_target_exit_data): Added HAS_DEVICE_ADDR to OMP_CLAUSE_MASK. * c-typeck.cc (handle_omp_array_sections): Handle clause restrictions. (c_finish_omp_clauses): Handle array sections. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_name): Parse 'has_device_addr' clause. (cp_parser_omp_var_list_no_open): Handle array sections. (cp_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR case. (cp_parser_omp_target_update): Added HAS_DEVICE_ADDR to OMP_CLAUSE_MASK. * semantics.cc (handle_omp_array_sections): Handle clause restrictions. (finish_omp_clauses): Handle array sections. gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_clauses): Added OMP_LIST_HAS_DEVICE_ADDR case. * gfortran.h: Added OMP_LIST_HAS_DEVICE_ADDR. * openmp.cc (enum omp_mask2): Added OMP_CLAUSE_HAS_DEVICE_ADDR. (gfc_match_omp_clauses): Parse HAS_DEVICE_ADDR clause. (resolve_omp_clauses): Same. * trans-openmp.cc (gfc_trans_omp_variable_list): Added OMP_LIST_HAS_DEVICE_ADDR case. (gfc_trans_omp_clauses): Firstprivatize of array descriptors. gcc/ChangeLog: * gimplify.cc (gimplify_scan_omp_clauses): Added cases for OMP_CLAUSE_HAS_DEVICE_ADDR and handle array sections. (gimplify_adjust_omp_clauses): Added OMP_CLAUSE_HAS_DEVICE_ADDR case. * omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_HAS_DEVICE_ADDR. (lower_omp_target): Same. * tree-core.h (enum omp_clause_code): Same. * tree-nested.cc (convert_nonlocal_omp_clauses): Same. (convert_local_omp_clauses): Same. * tree-pretty-print.cc (dump_omp_clause): Same. * tree.cc: Same. libgomp/ChangeLog: * libgomp.texi: Updated entry for HAS_DEVICE_ADDR. * target.c (copy_firstprivate_data): Copy only if host address is not NULL. * testsuite/libgomp.c++/target-has-device-addr-2.C: New test. * testsuite/libgomp.c++/target-has-device-addr-4.C: New test. * testsuite/libgomp.c++/target-has-device-addr-5.C: New test. * testsuite/libgomp.c++/target-has-device-addr-6.C: New test. * testsuite/libgomp.c-c++-common/target-has-device-addr-1.c: New test. * testsuite/libgomp.c/target-has-device-addr-3.c: New test. * testsuite/libgomp.fortran/target-has-device-addr-1.f90: New test. * testsuite/libgomp.fortran/target-has-device-addr-2.f90: New test. * testsuite/libgomp.fortran/target-has-device-addr-3.f90: New test. * testsuite/libgomp.fortran/target-has-device-addr-4.f90: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/clauses-1.c: Added has_device_addr to test cases. * g++.dg/gomp/attrs-1.C: Added has_device_addr to test cases. * g++.dg/gomp/attrs-2.C: Added has_device_addr to test cases. * c-c++-common/gomp/target-has-device-addr-1.c: New test. * c-c++-common/gomp/target-has-device-addr-2.c: New test. * c-c++-common/gomp/target-is-device-ptr-1.c: New test. * c-c++-common/gomp/target-is-device-ptr-2.c: New test. * gfortran.dg/gomp/is_device_ptr-3.f90: New test. * gfortran.dg/gomp/target-has-device-addr-1.f90: New test. * gfortran.dg/gomp/target-has-device-addr-2.f90: New test. --- gcc/fortran/dump-parse-tree.cc | 1 + gcc/fortran/gfortran.h | 3 ++- gcc/fortran/openmp.cc | 18 +++++++++++++----- gcc/fortran/trans-openmp.cc | 15 ++++++++++++++- 4 files changed, 30 insertions(+), 7 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 3112cae..2a2f990 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1683,6 +1683,7 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses) case OMP_LIST_CACHE: type = "CACHE"; break; case OMP_LIST_IS_DEVICE_PTR: type = "IS_DEVICE_PTR"; break; case OMP_LIST_USE_DEVICE_PTR: type = "USE_DEVICE_PTR"; break; + case OMP_LIST_HAS_DEVICE_ADDR: type = "HAS_DEVICE_ADDR"; break; case OMP_LIST_USE_DEVICE_ADDR: type = "USE_DEVICE_ADDR"; break; case OMP_LIST_NONTEMPORAL: type = "NONTEMPORAL"; break; case OMP_LIST_ALLOCATE: type = "ALLOCATE"; break; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 993879f..cb136f8 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1393,7 +1393,8 @@ enum OMP_LIST_USE_DEVICE_ADDR, OMP_LIST_NONTEMPORAL, OMP_LIST_ALLOCATE, - OMP_LIST_NUM + OMP_LIST_HAS_DEVICE_ADDR, + OMP_LIST_NUM /* Must be the last. */ }; /* Because a symbol can belong to multiple namelists, they must be diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 38c67e1..33b372f 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -926,7 +926,7 @@ enum omp_mask1 OMP_MASK1_LAST }; -/* OpenACC 2.0+ specific clauses. */ +/* More OpenMP clauses and OpenACC 2.0+ specific clauses. */ enum omp_mask2 { OMP_CLAUSE_ASYNC, @@ -955,6 +955,7 @@ enum omp_mask2 OMP_CLAUSE_FINALIZE, OMP_CLAUSE_ATTACH, OMP_CLAUSE_NOHOST, + OMP_CLAUSE_HAS_DEVICE_ADDR, /* OpenMP 5.1 */ /* This must come last. */ OMP_MASK2_LAST }; @@ -2151,6 +2152,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, } break; case 'h': + if ((mask & OMP_CLAUSE_HAS_DEVICE_ADDR) + && gfc_match_omp_variable_list + ("has_device_addr (", &c->lists[OMP_LIST_HAS_DEVICE_ADDR], + false, NULL, NULL, true) == MATCH_YES) + continue; if ((mask & OMP_CLAUSE_HINT) && (m = gfc_match_dupl_check (!c->hint, "hint", true, &c->hint)) != MATCH_NO) @@ -2923,8 +2929,8 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, continue; if ((mask & OMP_CLAUSE_USE_DEVICE_ADDR) && gfc_match_omp_variable_list - ("use_device_addr (", - &c->lists[OMP_LIST_USE_DEVICE_ADDR], false) == MATCH_YES) + ("use_device_addr (", &c->lists[OMP_LIST_USE_DEVICE_ADDR], + false, NULL, NULL, true) == MATCH_YES) continue; break; case 'v': @@ -3651,7 +3657,8 @@ cleanup: | OMP_CLAUSE_DEPEND | OMP_CLAUSE_NOWAIT | OMP_CLAUSE_PRIVATE \ | OMP_CLAUSE_FIRSTPRIVATE | OMP_CLAUSE_DEFAULTMAP \ | OMP_CLAUSE_IS_DEVICE_PTR | OMP_CLAUSE_IN_REDUCTION \ - | OMP_CLAUSE_THREAD_LIMIT | OMP_CLAUSE_ALLOCATE) + | OMP_CLAUSE_THREAD_LIMIT | OMP_CLAUSE_ALLOCATE \ + | OMP_CLAUSE_HAS_DEVICE_ADDR) #define OMP_TARGET_DATA_CLAUSES \ (omp_mask (OMP_CLAUSE_DEVICE) | OMP_CLAUSE_MAP | OMP_CLAUSE_IF \ | OMP_CLAUSE_USE_DEVICE_PTR | OMP_CLAUSE_USE_DEVICE_ADDR) @@ -6283,7 +6290,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, "IN_REDUCTION", "TASK_REDUCTION", "DEVICE_RESIDENT", "LINK", "USE_DEVICE", "CACHE", "IS_DEVICE_PTR", "USE_DEVICE_PTR", "USE_DEVICE_ADDR", - "NONTEMPORAL", "ALLOCATE" }; + "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR" }; STATIC_ASSERT (ARRAY_SIZE (clause_names) == OMP_LIST_NUM); if (omp_clauses == NULL) @@ -7132,6 +7139,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, n->sym->name, name, &n->where); } break; + case OMP_LIST_HAS_DEVICE_ADDR: case OMP_LIST_USE_DEVICE_PTR: case OMP_LIST_USE_DEVICE_ADDR: /* FIXME: Handle OMP_LIST_USE_DEVICE_PTR. */ diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index d5a6b2d..0eba0b3 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -1910,7 +1910,17 @@ gfc_trans_omp_variable_list (enum omp_clause_code code, tree t = gfc_trans_omp_variable (namelist->sym, declare_simd); if (t != error_mark_node) { - tree node = build_omp_clause (input_location, code); + tree node; + /* For HAS_DEVICE_ADDR of an array descriptor, firstprivatize the + descriptor such that the bounds are available; its data component + is unmodified; it is handled as device address inside target. */ + if (code == OMP_CLAUSE_HAS_DEVICE_ADDR + && (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (t)) + || (POINTER_TYPE_P (TREE_TYPE (t)) + && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (t)))))) + node = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); + else + node = build_omp_clause (input_location, code); OMP_CLAUSE_DECL (node) = t; list = gfc_trans_add_clause (node, list); @@ -2604,6 +2614,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, case OMP_LIST_IS_DEVICE_PTR: clause_code = OMP_CLAUSE_IS_DEVICE_PTR; goto add_clause; + case OMP_LIST_HAS_DEVICE_ADDR: + clause_code = OMP_CLAUSE_HAS_DEVICE_ADDR; + goto add_clause; case OMP_LIST_NONTEMPORAL: clause_code = OMP_CLAUSE_NONTEMPORAL; goto add_clause; -- cgit v1.1 From 9694f6121982668285a21020b55b44c3099f7042 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Thu, 10 Feb 2022 09:30:19 +0100 Subject: Fortran/OpenMP: Avoid ICE for invalid char array in omp atomic [PR104329] PR fortran/104329 gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_atomic): Defer extra-code assert after other diagnostics. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/atomic-28.f90: New test. --- gcc/fortran/openmp.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 33b372f..19142c4 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7695,7 +7695,7 @@ resolve_omp_atomic (gfc_code *code) gfc_omp_atomic_op aop = (gfc_omp_atomic_op) (atomic_code->ext.omp_clauses->atomic_op & GFC_OMP_ATOMIC_MASK); - gfc_code *stmt = NULL, *capture_stmt = NULL; + gfc_code *stmt = NULL, *capture_stmt = NULL, *tailing_stmt = NULL; gfc_expr *comp_cond = NULL; locus *loc = NULL; @@ -7833,7 +7833,8 @@ resolve_omp_atomic (gfc_code *code) stmt = code; capture_stmt = code->next; } - gcc_assert (!code->next->next); + /* Shall be NULL but can happen for invalid code. */ + tailing_stmt = code->next->next; } else { @@ -7841,7 +7842,8 @@ resolve_omp_atomic (gfc_code *code) stmt = code; if (!atomic_code->ext.omp_clauses->compare && stmt->op != EXEC_ASSIGN) goto unexpected; - gcc_assert (!code->next); + /* Shall be NULL but can happen for invalid code. */ + tailing_stmt = code->next; } if (comp_cond) @@ -7894,6 +7896,9 @@ resolve_omp_atomic (gfc_code *code) return; } + /* Should be diagnosed above already. */ + gcc_assert (tailing_stmt == NULL); + var = stmt->expr1->symtree->n.sym; stmt_expr2 = is_conversion (stmt->expr2, true, true); if (stmt_expr2 == NULL) -- cgit v1.1 From 3881e1823c5a59d988ddcddcc1e25c5738e228fb Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Thu, 10 Feb 2022 13:32:07 +0000 Subject: gfortran: Respect target's NO_DOT_IN_LABEL in trans-common.cc This patch fixes 9 unexpected failures in the gfortran testsuite on nvptx-none. The issue is that gfortran's EQUIVALENCE internally uses symbols such as "equiv.0" even on platforms that define NO_DOT_IN_LABEL. On nvptx-none, this then results in the following error message(s): ptxas application ptx input, fatal: Parsing error near '.0': syntax error ptxas fatal: Ptx assembly aborted due to errors The fix is to tweak trans-common.cc to respect the target's NO_DOT_IN_LABEL (and NO_DOLLAR_IN_LABEL) when generating internal equiv.%d symbols. Only the nvptx, mmix and xtensa backends define NO_DOT_IN_LABEL which explains why no-one has spotted/fixed this issue since the problematic code was last changed back in 2005(!). 2022-02-10 Roger Sayle Tobias Burnus gcc/fortran/ChangeLog * trans-common.cc (GFC_EQUIV_FMT): New macro respecting the target's NO_DOT_IN_LABEL and NO_DOLLAR_IN_LABEL preferences. (build_equiv_decl): Use GFC_EQUIV_FMT here. --- gcc/fortran/trans-common.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-common.cc b/gcc/fortran/trans-common.cc index 7b4d198..7c8cba0 100644 --- a/gcc/fortran/trans-common.cc +++ b/gcc/fortran/trans-common.cc @@ -338,6 +338,13 @@ build_field (segment_info *h, tree union_type, record_layout_info rli) h->field = field; } +#if !defined (NO_DOT_IN_LABEL) +#define GFC_EQUIV_FMT "equiv.%d" +#elif !defined (NO_DOLLAR_IN_LABEL) +#define GFC_EQUIV_FMT "_Equiv$%d" +#else +#define GFC_EQUIV_FMT "_Equiv_%d" +#endif /* Get storage for local equivalence. */ @@ -356,7 +363,7 @@ build_equiv_decl (tree union_type, bool is_init, bool is_saved, bool is_auto) return decl; } - snprintf (name, sizeof (name), "equiv.%d", serial++); + snprintf (name, sizeof (name), GFC_EQUIV_FMT, serial++); decl = build_decl (input_location, VAR_DECL, get_identifier (name), union_type); DECL_ARTIFICIAL (decl) = 1; -- cgit v1.1 From a645583d4d68eecdd9101e1013e7bf01907ea786 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 11 Feb 2022 00:16:25 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7c8c265..4a1e6c6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,28 @@ +2022-02-10 Roger Sayle + Tobias Burnus + + * trans-common.cc (GFC_EQUIV_FMT): New macro respecting the + target's NO_DOT_IN_LABEL and NO_DOLLAR_IN_LABEL preferences. + (build_equiv_decl): Use GFC_EQUIV_FMT here. + +2022-02-10 Tobias Burnus + + PR fortran/104329 + * openmp.cc (resolve_omp_atomic): Defer extra-code assert after + other diagnostics. + +2022-02-10 Marcel Vollweiler + + * dump-parse-tree.cc (show_omp_clauses): Added OMP_LIST_HAS_DEVICE_ADDR + case. + * gfortran.h: Added OMP_LIST_HAS_DEVICE_ADDR. + * openmp.cc (enum omp_mask2): Added OMP_CLAUSE_HAS_DEVICE_ADDR. + (gfc_match_omp_clauses): Parse HAS_DEVICE_ADDR clause. + (resolve_omp_clauses): Same. + * trans-openmp.cc (gfc_trans_omp_variable_list): Added + OMP_LIST_HAS_DEVICE_ADDR case. + (gfc_trans_omp_clauses): Firstprivatize of array descriptors. + 2022-02-09 Harald Anlauf PR fortran/66193 -- cgit v1.1 From 57da34939703a6e6d3267a0d25d1fb9369d3ac0e Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Fri, 28 Jan 2022 22:00:57 +0100 Subject: fortran: Unshare associate var charlen [PR104228] PR104228 showed that character lengths were shared between associate variable and associate targets. This is problematic when the associate target is itself a variable and gets a variable to hold the length, as the length variable is added (and all the variables following it in the chain) to both the associate variable scope and the target variable scope. This caused an ICE when compiling with -O0 -fsanitize=address. This change forces the creation of a separate character length for the associate variable. It also forces the initialization of the character length variable to avoid regressing associate_32 and associate_47 tests. PR fortran/104228 gcc/fortran/ChangeLog: * resolve.cc (resolve_assoc_var): Also create a new character length for non-dummy associate targets. * trans-stmt.cc (trans_associate_var): Initialize character length even if no temporary is used for the associate variable. gcc/testsuite/ChangeLog: * gfortran.dg/asan/associate_58.f90: New test. * gfortran.dg/asan/associate_59.f90: New test. --- gcc/fortran/resolve.cc | 1 - gcc/fortran/trans-stmt.cc | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 835a478..266e41e 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -9227,7 +9227,6 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) sym->ts.u.cl = target->ts.u.cl; if (sym->ts.deferred && target->expr_type == EXPR_VARIABLE - && target->symtree->n.sym->attr.dummy && sym->ts.u.cl == target->ts.u.cl) { sym->ts.u.cl = gfc_new_charlen (sym->ns, NULL); diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 04f8147..30b6bd5 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -1918,7 +1918,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) gfc_conv_expr_descriptor (&se, e); if (sym->ts.type == BT_CHARACTER - && !se.direct_byref && sym->ts.deferred + && sym->ts.deferred && !sym->attr.select_type_temporary && VAR_P (sym->ts.u.cl->backend_decl) && se.string_length != sym->ts.u.cl->backend_decl) -- cgit v1.1 From 0d31c8ec3fd9d1e8a16cac8605c862fbede07d46 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 14 Feb 2022 00:16:23 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4a1e6c6..418b5eb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-02-13 Mikael Morin + + PR fortran/104228 + * resolve.cc (resolve_assoc_var): Also create a new character + length for non-dummy associate targets. + * trans-stmt.cc (trans_associate_var): Initialize character length + even if no temporary is used for the associate variable. + 2022-02-10 Roger Sayle Tobias Burnus -- cgit v1.1 From 19b517dff37b8e25f6babf8883483be73cad8fb3 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 10 Feb 2022 21:22:48 +0100 Subject: Fortran: improve error recovery on bad array section gcc/fortran/ChangeLog: PR fortran/104211 * expr.cc (find_array_section): Replace assertion by error recovery when encountering bad array constructor. gcc/testsuite/ChangeLog: PR fortran/104211 * gfortran.dg/pr104211.f90: New test. --- gcc/fortran/expr.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index ed82a94..c9c0ba4 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1718,7 +1718,13 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) } cons = gfc_constructor_lookup (base, limit); - gcc_assert (cons); + if (cons == NULL) + { + gfc_error ("Error in array constructor referenced at %L", + &ref->u.ar.where); + t = false; + goto cleanup; + } gfc_constructor_append_expr (&expr->value.constructor, gfc_copy_expr (cons->expr), NULL); } -- cgit v1.1 From 1f8a09d2f3c69fff32729c4fa0680c4621babb83 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 15 Feb 2022 00:16:41 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 418b5eb..6f46835 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-02-14 Harald Anlauf + + PR fortran/104211 + * expr.cc (find_array_section): Replace assertion by error + recovery when encountering bad array constructor. + 2022-02-13 Mikael Morin PR fortran/104228 -- cgit v1.1 From 3939c1b11279dc950d2f160eb940dd791f7b40f1 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 15 Feb 2022 12:26:48 +0100 Subject: Fortran/OpenMP: Fix depend-clause handling gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): Depend on the proper addr, for ptr/alloc depend on pointee. libgomp/ChangeLog: * testsuite/libgomp.fortran/depend-4.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/depend-4.f90: New test. * gfortran.dg/gomp/depend-5.f90: New test. --- gcc/fortran/trans-openmp.cc | 46 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 0eba0b3..e1c9d46 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -2881,15 +2881,14 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, tree decl = gfc_trans_omp_variable (n->sym, false); if (gfc_omp_privatize_by_reference (decl)) decl = build_fold_indirect_ref (decl); - if (n->u.depend_op == OMP_DEPEND_DEPOBJ - && POINTER_TYPE_P (TREE_TYPE (decl))) - decl = build_fold_indirect_ref (decl); if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl))) { decl = gfc_conv_descriptor_data_get (decl); gcc_assert (POINTER_TYPE_P (TREE_TYPE (decl))); decl = build_fold_indirect_ref (decl); } + else if (n->sym->attr.allocatable || n->sym->attr.pointer) + decl = build_fold_indirect_ref (decl); else if (DECL_P (decl)) TREE_ADDRESSABLE (decl) = 1; OMP_CLAUSE_DECL (node) = decl; @@ -5508,12 +5507,43 @@ gfc_trans_omp_depobj (gfc_code *code) if (n) { tree var; - if (n->expr) - var = gfc_convert_expr_to_tree (&block, n->expr); + if (n->expr && n->expr->ref->u.ar.type != AR_FULL) + { + gfc_init_se (&se, NULL); + if (n->expr->ref->u.ar.type == AR_ELEMENT) + { + gfc_conv_expr_reference (&se, n->expr); + var = se.expr; + } + else + { + gfc_conv_expr_descriptor (&se, n->expr); + var = gfc_conv_array_data (se.expr); + } + gfc_add_block_to_block (&block, &se.pre); + gfc_add_block_to_block (&block, &se.post); + gcc_assert (POINTER_TYPE_P (TREE_TYPE (var))); + } else - var = gfc_get_symbol_decl (n->sym); - if (!POINTER_TYPE_P (TREE_TYPE (var))) - var = gfc_build_addr_expr (NULL, var); + { + var = gfc_get_symbol_decl (n->sym); + if (POINTER_TYPE_P (TREE_TYPE (var)) + && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (var)))) + var = build_fold_indirect_ref (var); + if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (var))) + { + var = gfc_conv_descriptor_data_get (var); + gcc_assert (POINTER_TYPE_P (TREE_TYPE (var))); + } + else if ((n->sym->attr.allocatable || n->sym->attr.pointer) + && n->sym->attr.optional) + var = build_fold_indirect_ref (var); + else if (!POINTER_TYPE_P (TREE_TYPE (var))) + { + TREE_ADDRESSABLE (var) = 1; + var = gfc_build_addr_expr (NULL, var); + } + } depobj = save_expr (depobj); tree r = build_fold_indirect_ref_loc (loc, depobj); gfc_add_expr_to_block (&block, -- cgit v1.1 From 4d74ea551734694c225643c4069b1b4d4d2b05ed Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 15 Feb 2022 21:42:33 +0100 Subject: Fortran/OpenMP: Fix depend-clause handling for c_ptr gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_trans_omp_depobj): Fix to alloc/ptr dummy and for c_ptr. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/depend-4.f90: Add VALUE test, update scan test. * gfortran.dg/gomp/depend-5.f90: Fix scan tree for -m32. * gfortran.dg/gomp/depend-6.f90: New test. --- gcc/fortran/trans-openmp.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index e1c9d46..4d56a771 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -5536,9 +5536,12 @@ gfc_trans_omp_depobj (gfc_code *code) gcc_assert (POINTER_TYPE_P (TREE_TYPE (var))); } else if ((n->sym->attr.allocatable || n->sym->attr.pointer) - && n->sym->attr.optional) + && n->sym->attr.dummy) var = build_fold_indirect_ref (var); - else if (!POINTER_TYPE_P (TREE_TYPE (var))) + else if (!POINTER_TYPE_P (TREE_TYPE (var)) + || (n->sym->ts.f90_type == BT_VOID + && !POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (var))) + && !GFC_ARRAY_TYPE_P (TREE_TYPE (TREE_TYPE (var))))) { TREE_ADDRESSABLE (var) = 1; var = gfc_build_addr_expr (NULL, var); -- cgit v1.1 From 875e493bf5eb04c11bc3846a6bfee47a6f183e3f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 16 Feb 2022 00:16:26 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6f46835..4a1371b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-02-15 Tobias Burnus + + * trans-openmp.cc (gfc_trans_omp_depobj): Fix to alloc/ptr dummy + and for c_ptr. + +2022-02-15 Tobias Burnus + + * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): + Depend on the proper addr, for ptr/alloc depend on pointee. + 2022-02-14 Harald Anlauf PR fortran/104211 -- cgit v1.1 From e49508ac6b36adb8a2056c5a1fb6e0178de2439d Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 9 Feb 2022 21:54:29 +0100 Subject: Fortran: improve check of pointer initialization in DATA statements gcc/fortran/ChangeLog: PR fortran/77693 * data.cc (gfc_assign_data_value): If a variable in a data statement has the POINTER attribute, check for allowed initial data target that is compatible with pointer assignment. * gfortran.h (IS_POINTER): New macro. gcc/testsuite/ChangeLog: PR fortran/77693 * gfortran.dg/data_pointer_2.f90: New test. --- gcc/fortran/data.cc | 4 ++++ gcc/fortran/gfortran.h | 3 +++ 2 files changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc index f7c9143..7a5866f 100644 --- a/gcc/fortran/data.cc +++ b/gcc/fortran/data.cc @@ -618,6 +618,10 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index, gfc_convert_type (expr, &lvalue->ts, 0); } + if (IS_POINTER (symbol) + && !gfc_check_pointer_assign (lvalue, rvalue, false, true)) + return false; + if (last_con == NULL) symbol->value = expr; else diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index cb136f8..f8fd1ba 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -3897,6 +3897,9 @@ bool gfc_is_finalizable (gfc_symbol *, gfc_expr **); && CLASS_DATA (sym) \ && CLASS_DATA (sym)->attr.dimension \ && !CLASS_DATA (sym)->attr.class_pointer) +#define IS_POINTER(sym) \ + (sym->ts.type == BT_CLASS && sym->attr.class_ok && CLASS_DATA (sym) \ + ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer) /* frontend-passes.cc */ -- cgit v1.1 From c42f1e7734412c64e45a0fb0e519d40e144d6f9d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 21 Feb 2022 00:16:24 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4a1371b..99282bb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-02-20 Harald Anlauf + + PR fortran/77693 + * data.cc (gfc_assign_data_value): If a variable in a data + statement has the POINTER attribute, check for allowed initial + data target that is compatible with pointer assignment. + * gfortran.h (IS_POINTER): New macro. + 2022-02-15 Tobias Burnus * trans-openmp.cc (gfc_trans_omp_depobj): Fix to alloc/ptr dummy -- cgit v1.1 From bc66b471d16ef2fd8cb66fd1131b41f80ecb9961 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 21 Feb 2022 22:49:05 +0100 Subject: Fortran: skip compile-time shape check if constructor shape is not known gcc/fortran/ChangeLog: PR fortran/104619 * resolve.cc (resolve_structure_cons): Skip shape check if shape of constructor cannot be determined at compile time. gcc/testsuite/ChangeLog: PR fortran/104619 * gfortran.dg/derived_constructor_comps_7.f90: New test. --- gcc/fortran/resolve.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 266e41e..451bc97 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -1472,6 +1472,8 @@ resolve_structure_cons (gfc_expr *expr, int init) t = false; break; }; + if (cons->expr->shape == NULL) + continue; mpz_set_ui (len, 1); mpz_add (len, len, comp->as->upper[n]->value.integer); mpz_sub (len, len, comp->as->lower[n]->value.integer); -- cgit v1.1 From 2cfb33fc1e71a76bd20d48d291539804ec342e0d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 23 Feb 2022 00:16:24 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 99282bb..f919454 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-02-22 Harald Anlauf + + PR fortran/104619 + * resolve.cc (resolve_structure_cons): Skip shape check if shape + of constructor cannot be determined at compile time. + 2022-02-20 Harald Anlauf PR fortran/77693 -- cgit v1.1 From 916b809fbfdd2740006270baf549bf22fe9ec3c4 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 23 Feb 2022 23:08:29 +0100 Subject: Fortran: frontend code for F2018 QUIET specifier to STOP and ERROR STOP Fortran 2018 allows for a QUIET specifier to the STOP and ERROR STOP statements. Whilst the gfortran library code provides support for this specifier for quite some time, the frontend implementation was missing. gcc/fortran/ChangeLog: PR fortran/84519 * dump-parse-tree.cc (show_code_node): Dump QUIET specifier when present. * match.cc (gfc_match_stopcode): Implement parsing of F2018 QUIET specifier. F2018 stopcodes may have non-default integer kind. * resolve.cc (gfc_resolve_code): Add checks for QUIET argument. * trans-stmt.cc (gfc_trans_stop): Pass QUIET specifier to call of library function. gcc/testsuite/ChangeLog: PR fortran/84519 * gfortran.dg/stop_1.f90: New test. * gfortran.dg/stop_2.f: New test. * gfortran.dg/stop_3.f90: New test. * gfortran.dg/stop_4.f90: New test. --- gcc/fortran/dump-parse-tree.cc | 5 ++++ gcc/fortran/match.cc | 62 +++++++++++++++++++++++++++++++++++------- gcc/fortran/resolve.cc | 9 ++++++ gcc/fortran/trans-stmt.cc | 15 ++++++++-- 4 files changed, 78 insertions(+), 13 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 2a2f990..322416e 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -2370,6 +2370,11 @@ show_code_node (int level, gfc_code *c) show_expr (c->expr1); else fprintf (dumpfile, "%d", c->ext.stop_code); + if (c->expr2 != NULL) + { + fputs (" QUIET=", dumpfile); + show_expr (c->expr2); + } break; diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 8edfe4a..715a74e 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -2978,6 +2978,13 @@ Fortran 2008 has R856 allstop-stmt is ALL STOP [ stop-code ] R857 stop-code is scalar-default-char-constant-expr or scalar-int-constant-expr +Fortran 2018 has + + R1160 stop-stmt is STOP [ stop-code ] [ , QUIET = scalar-logical-expr] + R1161 error-stop-stmt is + ERROR STOP [ stop-code ] [ , QUIET = scalar-logical-expr] + R1162 stop-code is scalar-default-char-expr + or scalar-int-expr For free-form source code, all standards contain a statement of the form: @@ -2994,8 +3001,10 @@ static match gfc_match_stopcode (gfc_statement st) { gfc_expr *e = NULL; + gfc_expr *quiet = NULL; match m; bool f95, f03, f08; + char c; /* Set f95 for -std=f95. */ f95 = (gfc_option.allow_std == GFC_STD_OPT_F95); @@ -3006,11 +3015,16 @@ gfc_match_stopcode (gfc_statement st) /* Set f08 for -std=f2008. */ f08 = (gfc_option.allow_std == GFC_STD_OPT_F08); - /* Look for a blank between STOP and the stop-code for F2008 or later. */ - if (gfc_current_form != FORM_FIXED && !(f95 || f03)) - { - char c = gfc_peek_ascii_char (); + /* Plain STOP statement? */ + if (gfc_match_eos () == MATCH_YES) + goto checks; + + /* Look for a blank between STOP and the stop-code for F2008 or later. + But allow for F2018's ,QUIET= specifier. */ + c = gfc_peek_ascii_char (); + if (gfc_current_form != FORM_FIXED && !(f95 || f03) && c != ',') + { /* Look for end-of-statement. There is no stop-code. */ if (c == '\n' || c == '!' || c == ';') goto done; @@ -3023,7 +3037,12 @@ gfc_match_stopcode (gfc_statement st) } } - if (gfc_match_eos () != MATCH_YES) + if (c == ' ') + { + gfc_gobble_whitespace (); + c = gfc_peek_ascii_char (); + } + if (c != ',') { int stopcode; locus old_locus; @@ -3053,11 +3072,20 @@ gfc_match_stopcode (gfc_statement st) goto cleanup; if (m == MATCH_NO) goto syntax; + } - if (gfc_match_eos () != MATCH_YES) - goto syntax; + if (gfc_match (" , quiet = %e", &quiet) == MATCH_YES) + { + if (!gfc_notify_std (GFC_STD_F2018, "QUIET= specifier for %s at %L", + gfc_ascii_statement (st), &quiet->where)) + goto cleanup; } + if (gfc_match_eos () != MATCH_YES) + goto syntax; + +checks: + if (gfc_pure (NULL)) { if (st == ST_ERROR_STOP) @@ -3133,10 +3161,22 @@ gfc_match_stopcode (gfc_statement st) goto cleanup; } - if (e->ts.type == BT_INTEGER && e->ts.kind != gfc_default_integer_kind) + if (e->ts.type == BT_INTEGER && e->ts.kind != gfc_default_integer_kind + && !gfc_notify_std (GFC_STD_F2018, + "STOP code at %L must be default integer KIND=%d", + &e->where, (int) gfc_default_integer_kind)) + goto cleanup; + } + + if (quiet != NULL) + { + if (!gfc_simplify_expr (quiet, 0)) + goto cleanup; + + if (quiet->rank != 0) { - gfc_error ("STOP code at %L must be default integer KIND=%d", - &e->where, (int) gfc_default_integer_kind); + gfc_error ("QUIET specifier at %L must be a scalar LOGICAL", + &quiet->where); goto cleanup; } } @@ -3159,6 +3199,7 @@ done: } new_st.expr1 = e; + new_st.expr2 = quiet; new_st.ext.stop_code = -1; return MATCH_YES; @@ -3169,6 +3210,7 @@ syntax: cleanup: gfc_free_expr (e); + gfc_free_expr (quiet); return MATCH_ERROR; } diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 451bc97..753aa27 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -11944,8 +11944,17 @@ start: case EXEC_END_NESTED_BLOCK: case EXEC_CYCLE: case EXEC_PAUSE: + break; + case EXEC_STOP: case EXEC_ERROR_STOP: + if (code->expr2 != NULL + && (code->expr2->ts.type != BT_LOGICAL + || code->expr2->rank != 0)) + gfc_error ("QUIET specifier at %L must be a scalar LOGICAL", + &code->expr2->where); + break; + case EXEC_EXIT: case EXEC_CONTINUE: case EXEC_DT_END: diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 30b6bd5..7909681 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -652,11 +652,20 @@ gfc_trans_stop (gfc_code *code, bool error_stop) { gfc_se se; tree tmp; + tree quiet; /* Start a new block for this statement. */ gfc_init_se (&se, NULL); gfc_start_block (&se.pre); + if (code->expr2) + { + gfc_conv_expr_val (&se, code->expr2); + quiet = fold_convert (boolean_type_node, se.expr); + } + else + quiet = boolean_false_node; + if (code->expr1 == NULL) { tmp = build_int_cst (size_type_node, 0); @@ -669,7 +678,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) ? gfor_fndecl_caf_stop_str : gfor_fndecl_stop_string), 3, build_int_cst (pchar_type_node, 0), tmp, - boolean_false_node); + quiet); } else if (code->expr1->ts.type == BT_INTEGER) { @@ -683,7 +692,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) ? gfor_fndecl_caf_stop_numeric : gfor_fndecl_stop_numeric), 2, fold_convert (integer_type_node, se.expr), - boolean_false_node); + quiet); } else { @@ -698,7 +707,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) : gfor_fndecl_stop_string), 3, se.expr, fold_convert (size_type_node, se.string_length), - boolean_false_node); + quiet); } gfc_add_expr_to_block (&se.pre, tmp); -- cgit v1.1 From 756a61851c11ffb6b5bcc21f147f6f102bf8e1f3 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 25 Feb 2022 00:16:20 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f919454..e26a720 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2022-02-24 Harald Anlauf + + PR fortran/84519 + * dump-parse-tree.cc (show_code_node): Dump QUIET specifier when + present. + * match.cc (gfc_match_stopcode): Implement parsing of F2018 QUIET + specifier. F2018 stopcodes may have non-default integer kind. + * resolve.cc (gfc_resolve_code): Add checks for QUIET argument. + * trans-stmt.cc (gfc_trans_stop): Pass QUIET specifier to call of + library function. + 2022-02-22 Harald Anlauf PR fortran/104619 -- cgit v1.1 From 12463f1ecbcb30b39b8212454a6e598645123305 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 1 Mar 2022 23:13:17 +0100 Subject: Fortran: error recovery after invalid assumed type declaration gcc/fortran/ChangeLog: PR fortran/104573 * resolve.cc (resolve_structure_cons): Avoid NULL pointer dereference when there is no valid component. gcc/testsuite/ChangeLog: PR fortran/104573 * gfortran.dg/assumed_type_14.f90: New test. --- gcc/fortran/resolve.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 753aa27..0afa5d3 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -1288,15 +1288,19 @@ resolve_structure_cons (gfc_expr *expr, int init) } } - cons = gfc_constructor_first (expr->value.constructor); - /* A constructor may have references if it is the result of substituting a parameter variable. In this case we just pull out the component we want. */ if (expr->ref) comp = expr->ref->u.c.sym->components; - else + else if ((expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS + || expr->ts.type == BT_UNION) + && expr->ts.u.derived) comp = expr->ts.u.derived->components; + else + return false; + + cons = gfc_constructor_first (expr->value.constructor); for (; comp && cons; comp = comp->next, cons = gfc_constructor_next (cons)) { -- cgit v1.1 From ea4911c4fa629a97d22b6e48975d8f1c4e04549d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 3 Mar 2022 00:16:24 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e26a720..1c6387b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-03-02 Harald Anlauf + + PR fortran/104573 + * resolve.cc (resolve_structure_cons): Avoid NULL pointer + dereference when there is no valid component. + 2022-02-24 Harald Anlauf PR fortran/84519 -- cgit v1.1 From 88c4d85e27e18bf991ab8728b73127a0385f2c27 Mon Sep 17 00:00:00 2001 From: Kwok Cheung Yeung Date: Thu, 3 Mar 2022 10:23:26 +0000 Subject: openmp, fortran: Check that the type of an event handle in a detach clause is suitable [PR104131] This rejects variables that are array types, array elements or derived type members when used as the event handle inside a detach clause (in accordance with the OpenMP specification). This would previously lead to an ICE. 2022-03-03 Kwok Cheung Yeung gcc/fortran/ PR fortran/104131 * openmp.cc (gfc_match_omp_detach): Move check for type of event handle to... (resolve_omp_clauses) ...here. Also check that the event handle is not an array, or an array access or structure element access. gcc/testsuite/ PR fortran/104131 * gfortran.dg/gomp/pr104131.f90: New. * gfortran.dg/gomp/task-detach-1.f90: Update expected error message. --- gcc/fortran/openmp.cc | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 19142c4..16cd03a 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -531,14 +531,6 @@ gfc_match_omp_detach (gfc_expr **expr) if (gfc_match_variable (expr, 0) != MATCH_YES) goto syntax_error; - if ((*expr)->ts.type != BT_INTEGER || (*expr)->ts.kind != gfc_c_intptr_kind) - { - gfc_error ("%qs at %L should be of type " - "integer(kind=omp_event_handle_kind)", - (*expr)->symtree->n.sym->name, &(*expr)->where); - return MATCH_ERROR; - } - if (gfc_match_char (')') != MATCH_YES) goto syntax_error; @@ -7581,9 +7573,29 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, gfc_error ("%s must contain at least one MAP clause at %L", p, &code->loc); } - if (!openacc && omp_clauses->mergeable && omp_clauses->detach) - gfc_error ("% clause at %L must not be used together with " - "% clause", &omp_clauses->detach->where); + + if (!openacc && omp_clauses->detach) + { + if (!gfc_resolve_expr (omp_clauses->detach) + || omp_clauses->detach->ts.type != BT_INTEGER + || omp_clauses->detach->ts.kind != gfc_c_intptr_kind + || omp_clauses->detach->rank != 0) + gfc_error ("%qs at %L should be a scalar of type " + "integer(kind=omp_event_handle_kind)", + omp_clauses->detach->symtree->n.sym->name, + &omp_clauses->detach->where); + else if (omp_clauses->detach->symtree->n.sym->attr.dimension > 0) + gfc_error ("The event handle at %L must not be an array element", + &omp_clauses->detach->where); + else if (omp_clauses->detach->symtree->n.sym->ts.type == BT_DERIVED + || omp_clauses->detach->symtree->n.sym->ts.type == BT_CLASS) + gfc_error ("The event handle at %L must not be part of " + "a derived type or class", &omp_clauses->detach->where); + + if (omp_clauses->mergeable) + gfc_error ("% clause at %L must not be used together with " + "% clause", &omp_clauses->detach->where); + } } -- cgit v1.1 From fc03ebdceafce7948596aa3b9bb9653ba8205c6d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 4 Mar 2022 00:16:21 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1c6387b..03eb245 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-03-03 Kwok Cheung Yeung + + PR fortran/104131 + * openmp.cc (gfc_match_omp_detach): Move check for type of event + handle to... + (resolve_omp_clauses) ...here. Also check that the event handle is + not an array, or an array access or structure element access. + 2022-03-02 Harald Anlauf PR fortran/104573 -- cgit v1.1 From d73ae7a72a9bcac6a8b031cd902630eaeddf577e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 7 Mar 2022 10:41:11 +0100 Subject: Fix translation strings. PR translation/90148 gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_linux64_override_options): Put quote to a proper place. * plugin.cc (default_plugin_dir_name): Likewise. gcc/fortran/ChangeLog: * intrinsic.cc (gfc_is_intrinsic): Put quote to a proper place. --- gcc/fortran/intrinsic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc index 52e5f4e..2b92185 100644 --- a/gcc/fortran/intrinsic.cc +++ b/gcc/fortran/intrinsic.cc @@ -1184,7 +1184,7 @@ gfc_is_intrinsic (gfc_symbol* sym, int subroutine_flag, locus loc) gfc_warning_now (OPT_Wintrinsics_std, "The intrinsic %qs at %L is not " "included in the selected standard but %s and %qs will" " be treated as if declared EXTERNAL. Use an" - " appropriate %<-std=%>* option or define" + " appropriate %<-std=*%> option or define" " %<-fall-intrinsics%> to allow this intrinsic.", sym->name, &loc, symstd, sym->name); -- cgit v1.1 From 93ecb25cc63f92d12821f8e5186bf165a4f54ab3 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 7 Mar 2022 11:02:15 +0100 Subject: translation: small fixes PR translation/90148 gcc/fortran/ChangeLog: * intrinsic.cc (gfc_is_intrinsic): Remove asterisk from error message. gcc/ChangeLog: * plugin.cc (default_plugin_dir_name): Remove from error message. --- gcc/fortran/intrinsic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc index 2b92185..2339d90 100644 --- a/gcc/fortran/intrinsic.cc +++ b/gcc/fortran/intrinsic.cc @@ -1184,7 +1184,7 @@ gfc_is_intrinsic (gfc_symbol* sym, int subroutine_flag, locus loc) gfc_warning_now (OPT_Wintrinsics_std, "The intrinsic %qs at %L is not " "included in the selected standard but %s and %qs will" " be treated as if declared EXTERNAL. Use an" - " appropriate %<-std=*%> option or define" + " appropriate %<-std=%> option or define" " %<-fall-intrinsics%> to allow this intrinsic.", sym->name, &loc, symstd, sym->name); -- cgit v1.1 From 027e30414492d50feb2854aff38227b14300dc4b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 7 Mar 2022 15:00:20 +0100 Subject: Fix up duplicated duplicated words in comments Like in r10-7215-g700d4cb08c88aec37c13e21e63dd61fd698baabc 2 years ago, I've run grep -v 'long long\|optab optab\|template template\|double double' *.{[chS],cc} */*.{[chS],cc} *.def config/*/* 2>/dev/null | grep ' \([a-zA-Z]\+\) \1 ' and for the cases that looked clearly wrong changed them, mostly by removing one of the duplicated words but in some cases with other changes. 2022-03-07 Jakub Jelinek gcc/ * tree-ssa-propagate.cc: Fix up duplicated word issue in a comment. * config/riscv/riscv.cc: Likewise. * config/darwin.h: Likewise. * config/i386/i386.cc: Likewise. * config/aarch64/thunderx3t110.md: Likewise. * config/aarch64/fractional-cost.h: Likewise. * config/vax/vax.cc: Likewise. * config/rs6000/pcrel-opt.md: Likewise. * config/rs6000/predicates.md: Likewise. * ctfc.h: Likewise. * tree-ssa-uninit.cc: Likewise. * value-relation.h: Likewise. * gimple-range-gori.cc: Likewise. * ipa-polymorphic-call.cc: Likewise. * pointer-query.cc: Likewise. * ipa-sra.cc: Likewise. * internal-fn.cc: Likewise. * varasm.cc: Likewise. * gimple-ssa-warn-access.cc: Likewise. gcc/analyzer/ * store.cc: Fix up duplicated word issue in a comment. * analyzer.cc: Likewise. * engine.cc: Likewise. * sm-taint.cc: Likewise. gcc/c-family/ * c-attribs.cc: Fix up duplicated word issue in a comment. gcc/cp/ * cvt.cc: Fix up duplicated word issue in a comment. * pt.cc: Likewise. * module.cc: Likewise. * coroutines.cc: Likewise. gcc/fortran/ * trans-expr.cc: Fix up duplicated word issue in a comment. * gfortran.h: Likewise. * scanner.cc: Likewise. gcc/jit/ * libgccjit.h: Fix up duplicated word issue in a comment. --- gcc/fortran/gfortran.h | 2 +- gcc/fortran/scanner.cc | 2 +- gcc/fortran/trans-expr.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index f8fd1ba..7bf1d5a 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2137,7 +2137,7 @@ typedef struct gfc_namespace /* Linked list of !$omp declare variant constructs. */ struct gfc_omp_declare_variant *omp_declare_variant; - /* A hash set for the the gfc expressions that have already + /* A hash set for the gfc expressions that have already been finalized in this namespace. */ gfc_was_finalized *was_finalized; diff --git a/gcc/fortran/scanner.cc b/gcc/fortran/scanner.cc index 4df6576..b52282b 100644 --- a/gcc/fortran/scanner.cc +++ b/gcc/fortran/scanner.cc @@ -1915,7 +1915,7 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char) /* For truncation and tab warnings, set seen_comment to false if one has either an OpenMP or OpenACC directive - or a !GCC$ attribute. If - OpenMP is enabled, use '!$' as as conditional compilation sentinel + OpenMP is enabled, use '!$' as conditional compilation sentinel and OpenMP directive ('!$omp'). */ if (seen_comment && first_comment && flag_openmp && comment_ix + 1 == i && c == '$') diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index eb6a78c..2549d32 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -5678,7 +5678,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) Note that allocatable implies 'len=:'. */ if (e->ts.type != BT_ASSUMED && e->ts.type != BT_CHARACTER ) { - /* Length is known at compile time; use use 'block' for it. */ + /* Length is known at compile time; use 'block' for it. */ tmp = size_in_bytes (gfc_typenode_for_spec (&e->ts)); tmp2 = gfc_get_cfi_desc_elem_len (cfi); gfc_add_modify (&block, tmp2, fold_convert (TREE_TYPE (tmp2), tmp)); -- cgit v1.1 From e3ca3e7993696affe95a3ea24c2b133c14a056e4 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 7 Mar 2022 17:20:52 +0100 Subject: Fortran: Fix typos gcc/fortran/ChangeLog: * array.cc (gfc_ref_dimen_size): Fix comment typo. * dump-parse-tree.cc (gfc_dump_c_prototypes): Likewise. * frontend-passes.cc (cfe_code): Likewise. * gfortran.texi: Likewise. * resolve.cc (generate_component_assignments): Likewise. * simplify.cc (gfc_simplify_this_image): Likewise. * trans-expr.cc (trans_scalar_class_assign, gfc_maybe_dereference_var): Likewise. * intrinsic.texi: Remove word duplication. * invoke.texi: Likewise. --- gcc/fortran/array.cc | 2 +- gcc/fortran/dump-parse-tree.cc | 2 +- gcc/fortran/frontend-passes.cc | 2 +- gcc/fortran/gfortran.texi | 2 +- gcc/fortran/intrinsic.texi | 4 ++-- gcc/fortran/invoke.texi | 4 ++-- gcc/fortran/resolve.cc | 2 +- gcc/fortran/simplify.cc | 2 +- gcc/fortran/trans-expr.cc | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index f1d92e0..eb9ed85 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -2420,7 +2420,7 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end) gfc_free_expr(stride_expr); } - /* Calculate the number of elements via gfc_dep_differce, but only if + /* Calculate the number of elements via gfc_dep_difference, but only if start and end are both supplied in the reference or the array spec. This is to guard against strange but valid code like diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 322416e..3635460 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -3543,7 +3543,7 @@ gfc_dump_c_prototypes (gfc_namespace *ns, FILE *file) gfc_traverse_ns (ns, write_interop_decl); } -/* Loop over all global symbols, writing out their declrations. */ +/* Loop over all global symbols, writing out their declarations. */ void gfc_dump_external_c_prototypes (FILE * file) diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 22f1bb5..4033f27 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -974,7 +974,7 @@ cfe_code (gfc_code **c, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) changed_statement = NULL; /* Do not do anything inside a WHERE statement; scalar assignments, BLOCKs - and allocation on assigment are prohibited inside WHERE, and finally + and allocation on assignment are prohibited inside WHERE, and finally masking an expression would lead to wrong-code when replacing WHERE (a>0) diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 2a55676..f8737f4 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1093,7 +1093,7 @@ variable. The maximum number of bytes of user data in a subrecord is 2147483639 (2 GiB - 9) for a four-byte record marker. This limit can be lowered -with the @option{-fmax-subrecord-length} option, altough this is +with the @option{-fmax-subrecord-length} option, although this is rarely useful. If the length of a logical record exceeds this limit, the data is distributed among several subrecords. diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index f182cac..e3cd827 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -12897,7 +12897,7 @@ end program real_kinds @table @asis @item @emph{Description}: @code{SET_EXPONENT(X, I)} returns the real number whose fractional part -is that that of @var{X} and whose exponent part is @var{I}. +is that of @var{X} and whose exponent part is @var{I}. @item @emph{Standard}: Fortran 90 and later @@ -12917,7 +12917,7 @@ Elemental function @item @emph{Return value}: The return value is of the same type and kind as @var{X}. The real number whose fractional part -is that that of @var{X} and whose exponent part if @var{I} is returned; +is that of @var{X} and whose exponent part if @var{I} is returned; it is @code{FRACTION(X) * RADIX(X)**I}. @item @emph{Example}: diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 6435dc4..5c7501a 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -1858,7 +1858,7 @@ except when optimizing for size via @option{-Os}. If the code contains a very large number of argument that have to be packed, code size and also compilation time may become excessive. If that is the case, it may be better to disable this option. Instances of packing -can be found by using by using @option{-Warray-temporaries}. +can be found by using @option{-Warray-temporaries}. @item -fexternal-blas @opindex @code{fexternal-blas} @@ -2068,7 +2068,7 @@ does not generate prototypes for @code{BIND(C)} procedures, use @option{-fc-prototypes} for that. The generated prototypes may need inclusion of an appropriate -header, such as as @code{} or @code{}. +header, such as @code{} or @code{}. This is primarily meant for legacy code to ensure that existing C bindings match what @command{gfortran} emits. The generated C diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 0afa5d3..0b55961 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -11539,7 +11539,7 @@ generate_component_assignments (gfc_code **code, gfc_namespace *ns) || comp1->attr.proc_pointer) continue; - /* Make an assigment for this component. */ + /* Make an assignment for this component. */ this_code = build_assignment (EXEC_ASSIGN, (*code)->expr1, (*code)->expr2, comp1, comp2, (*code)->loc); diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 6483f9c..0c15bcb 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -8424,7 +8424,7 @@ gfc_simplify_this_image (gfc_expr *coarray, gfc_expr *dim, return NULL; /* If no coarray argument has been passed or when the first argument - is actually a distance argment. */ + is actually a distance argument. */ if (coarray == NULL || !gfc_is_coarray (coarray)) { gfc_expr *result; diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 2549d32..c9d9a91 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1777,7 +1777,7 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) bool not_call_expr = TREE_CODE (rse->expr) != CALL_EXPR; bool not_lhs_array_type; - /* Temporaries arising from depencies in assignment get cast as a + /* Temporaries arising from dependencies in assignment get cast as a character type of the dynamic size of the rhs. Use the vptr copy for this case. */ tmp = TREE_TYPE (lse->expr); @@ -2934,7 +2934,7 @@ gfc_maybe_dereference_var (gfc_symbol *sym, tree var, bool descriptor_only_p, || CLASS_DATA (sym)->attr.class_pointer)) var = build_fold_indirect_ref_loc (input_location, var); /* And the case where a non-dummy, non-result, non-function, - non-allotable and non-pointer classarray is present. This case was + non-allocable and non-pointer classarray is present. This case was previously covered by the first if, but with introducing the condition !is_classarray there, that case has to be covered explicitly. */ -- cgit v1.1 From c0134b7383992aab5c1a91440dbdd8fbb747169c Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 7 Mar 2022 22:11:33 +0100 Subject: Fortran: Fix gfc_maybe_dereference_var [PR104430][PR99585] PR fortran/99585 PR fortran/104430 gcc/fortran/ChangeLog: * trans-expr.cc (conv_parent_component_references): Fix comment; simplify comparison. (gfc_maybe_dereference_var): Avoid d referencing a nonpointer. gcc/testsuite/ChangeLog: * gfortran.dg/class_result_10.f90: New test. --- gcc/fortran/trans-expr.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index c9d9a91..71d0371 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -2805,9 +2805,9 @@ conv_parent_component_references (gfc_se * se, gfc_ref * ref) dt = ref->u.c.sym; c = ref->u.c.component; - /* Return if the component is in the parent type. */ + /* Return if the component is in this type, i.e. not in the parent type. */ for (cmp = dt->components; cmp; cmp = cmp->next) - if (strcmp (c->name, cmp->name) == 0) + if (c == cmp) return; /* Build a gfc_ref to recursively call gfc_conv_component_ref. */ @@ -2867,6 +2867,8 @@ tree gfc_maybe_dereference_var (gfc_symbol *sym, tree var, bool descriptor_only_p, bool is_classarray) { + if (!POINTER_TYPE_P (TREE_TYPE (var))) + return var; if (is_CFI_desc (sym, NULL)) return build_fold_indirect_ref_loc (input_location, var); -- cgit v1.1 From e6533e2ebec964e77d3a2462abbabd214d677552 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 8 Mar 2022 00:16:32 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 03eb245..7c79739 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,41 @@ +2022-03-07 Tobias Burnus + + PR fortran/99585 + PR fortran/104430 + * trans-expr.cc (conv_parent_component_references): Fix comment; + simplify comparison. + (gfc_maybe_dereference_var): Avoid d referencing a nonpointer. + +2022-03-07 Tobias Burnus + + * array.cc (gfc_ref_dimen_size): Fix comment typo. + * dump-parse-tree.cc (gfc_dump_c_prototypes): Likewise. + * frontend-passes.cc (cfe_code): Likewise. + * gfortran.texi: Likewise. + * resolve.cc (generate_component_assignments): Likewise. + * simplify.cc (gfc_simplify_this_image): Likewise. + * trans-expr.cc (trans_scalar_class_assign, + gfc_maybe_dereference_var): Likewise. + * intrinsic.texi: Remove word duplication. + * invoke.texi: Likewise. + +2022-03-07 Jakub Jelinek + + * trans-expr.cc: Fix up duplicated word issue in a comment. + * gfortran.h: Likewise. + * scanner.cc: Likewise. + +2022-03-07 Martin Liska + + * intrinsic.cc (gfc_is_intrinsic): Remove asterisk from error + message. + +2022-03-07 Martin Liska + + PR translation/90148 + * intrinsic.cc (gfc_is_intrinsic): Put + quote to a proper place. + 2022-03-03 Kwok Cheung Yeung PR fortran/104131 -- cgit v1.1 From e3e369dad6cbecb1b490b3f3b154c600fba5a6f3 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 8 Mar 2022 21:47:04 +0100 Subject: Fortran: do not frontend-optimize MINLOC/MAXLOC for character arrays gcc/fortran/ChangeLog: PR fortran/104811 * frontend-passes.cc (optimize_minmaxloc): Do not attempt frontend-optimization of MINLOC/MAXLOC for character arrays, as there is no suitable code yet for inline expansion. gcc/testsuite/ChangeLog: PR fortran/104811 * gfortran.dg/minmaxloc_16.f90: New test. --- gcc/fortran/frontend-passes.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 4033f27..5eba634 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -2276,6 +2276,7 @@ optimize_minmaxloc (gfc_expr **e) if (fn->rank != 1 || fn->value.function.actual == NULL || fn->value.function.actual->expr == NULL + || fn->value.function.actual->expr->ts.type == BT_CHARACTER || fn->value.function.actual->expr->rank != 1) return; -- cgit v1.1 From 48777d982add74cef14ec6704a622fce4d4a2609 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 9 Mar 2022 00:26:14 +0100 Subject: Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126] PR fortran/104126 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Handle NULL without MOLD. gcc/testsuite/ChangeLog: * gfortran.dg/null_actual_2.f90: New test. --- gcc/fortran/trans-expr.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 71d0371..06713f2 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -5610,8 +5610,11 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) itype = (e->ts.u.derived->intmod_sym_id == ISOCBINDING_FUNPTR ? CFI_type_cfunptr : CFI_type_cptr); else - switch (e->ts.type) - { + { + if (e->expr_type == EXPR_NULL && e->ts.type == BT_UNKNOWN) + e->ts = fsym->ts; + switch (e->ts.type) + { case BT_INTEGER: case BT_LOGICAL: case BT_REAL: @@ -5649,7 +5652,8 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) case BT_UNKNOWN: // FIXME: Really unreachable? Or reachable for type(*) ? If so, CFI_type_other? gcc_unreachable (); - } + } + } tmp = gfc_get_cfi_desc_type (cfi); gfc_add_modify (&block, tmp, @@ -5702,7 +5706,8 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) gfc_init_block (&block2); /* Set elem_len, which may be only known at run time. */ - if (e->ts.type == BT_CHARACTER) + if (e->ts.type == BT_CHARACTER + && (e->expr_type != EXPR_NULL || gfc_strlen != NULL_TREE)) { gcc_assert (gfc_strlen); tmp = gfc_strlen; -- cgit v1.1 From 8d038a841a6bb8e11c122d96e8f72b47ca3895c0 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 9 Mar 2022 00:16:29 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7c79739..e0c71d0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,16 @@ +2022-03-08 Tobias Burnus + + PR fortran/104126 + * trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Handle NULL + without MOLD. + +2022-03-08 Harald Anlauf + + PR fortran/104811 + * frontend-passes.cc (optimize_minmaxloc): Do not attempt + frontend-optimization of MINLOC/MAXLOC for character arrays, as + there is no suitable code yet for inline expansion. + 2022-03-07 Tobias Burnus PR fortran/99585 -- cgit v1.1 From a5c9b7c4f95ef77b83da82241cabdf80d8b1cad5 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 9 Mar 2022 10:25:11 +0100 Subject: Fortran: Fix CLASS handling in SIZEOF intrinsic gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_sizeof): Fix CLASS handling. gcc/testsuite/ChangeLog: * gfortran.dg/sizeof_6.f90: New test. --- gcc/fortran/trans-intrinsic.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index e680de1..2249723 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -8099,12 +8099,14 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *expr) class object. The class object may be a non-pointer object, e.g. located on the stack, or a memory location pointed to, e.g. a parameter, i.e., an indirect_ref. */ - if (arg->rank < 0 - || (arg->rank > 0 && !VAR_P (argse.expr) - && ((INDIRECT_REF_P (TREE_OPERAND (argse.expr, 0)) - && GFC_DECL_CLASS (TREE_OPERAND ( - TREE_OPERAND (argse.expr, 0), 0))) - || GFC_DECL_CLASS (TREE_OPERAND (argse.expr, 0))))) + if (POINTER_TYPE_P (TREE_TYPE (argse.expr)) + && GFC_CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (argse.expr)))) + byte_size + = gfc_class_vtab_size_get (build_fold_indirect_ref (argse.expr)); + else if (GFC_CLASS_TYPE_P (TREE_TYPE (argse.expr))) + byte_size = gfc_class_vtab_size_get (argse.expr); + else if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (argse.expr)) + && TREE_CODE (argse.expr) == COMPONENT_REF) byte_size = gfc_class_vtab_size_get (TREE_OPERAND (argse.expr, 0)); else if (arg->rank > 0 || (arg->rank == 0 @@ -8114,7 +8116,7 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *expr) byte_size = gfc_class_vtab_size_get ( GFC_DECL_SAVED_DESCRIPTOR (arg->symtree->n.sym->backend_decl)); else - byte_size = gfc_class_vtab_size_get (argse.expr); + gcc_unreachable (); } else { -- cgit v1.1 From 22015e77d3e45306077396b9de8a8a28bb67fb20 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 9 Mar 2022 21:58:26 +0100 Subject: Fortran: improve error recovery on invalid array section gcc/fortran/ChangeLog: PR fortran/104849 * expr.cc (find_array_section): Avoid NULL pointer dereference on invalid array section. gcc/testsuite/ChangeLog: PR fortran/104849 * gfortran.dg/pr104849.f90: New test. --- gcc/fortran/expr.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index c9c0ba4..86d61fe 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1594,7 +1594,9 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) { if ((begin && begin->expr_type != EXPR_CONSTANT) || (finish && finish->expr_type != EXPR_CONSTANT) - || (step && step->expr_type != EXPR_CONSTANT)) + || (step && step->expr_type != EXPR_CONSTANT) + || (!begin && !lower) + || (!finish && !upper)) { t = false; goto cleanup; -- cgit v1.1 From 8cc4f9cd824d195178632569c749f96b306475f9 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 10 Mar 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e0c71d0..f49b8e2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-03-09 Harald Anlauf + + PR fortran/104849 + * expr.cc (find_array_section): Avoid NULL pointer dereference on + invalid array section. + +2022-03-09 Tobias Burnus + + * trans-intrinsic.cc (gfc_conv_intrinsic_sizeof): Fix CLASS handling. + 2022-03-08 Tobias Burnus PR fortran/104126 -- cgit v1.1 From 41bda0036ce81e7ac513f325e7b0f41ccf11cbab Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 11 Mar 2022 08:48:58 +0100 Subject: Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause): Obtain size for mapping only if allocatable array is allocated. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/array-with-dt-1.f90: Update/add comments; remove dg-warning for 'is used uninitialized'. * gfortran.dg/goacc/pr93464.f90: Likewise. * gfortran.dg/goacc/array-with-dt-1a.f90: New; copied from gfortran.dg/goacc/array-with-dt-1.f90 but run with -O0. Update dg-warning for 'may be used uninitialized'. * gfortran.dg/goacc/pr93464-2.f90: Likewise; copied from gfortran.dg/goacc/pr93464.f90. --- gcc/fortran/trans-openmp.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 4d56a771..fad76a4 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -1597,7 +1597,8 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc) tree size = create_tmp_var (gfc_array_index_type); tree elemsz = TYPE_SIZE_UNIT (gfc_get_element_type (type)); elemsz = fold_convert (gfc_array_index_type, elemsz); - if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER + if (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE + || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT) { stmtblock_t cond_block; @@ -3208,7 +3209,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, /* We have to check for n->sym->attr.dimension because of scalar coarrays. */ - if (n->sym->attr.pointer && n->sym->attr.dimension) + if ((n->sym->attr.pointer || n->sym->attr.allocatable) + && n->sym->attr.dimension) { stmtblock_t cond_block; tree size -- cgit v1.1 From b00f9761b9b9bfa2be6dfd41b3f56a8ae9dba6d0 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 12 Mar 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f49b8e2..bd5a8e6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-03-11 Tobias Burnus + + * trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause): + Obtain size for mapping only if allocatable array is allocated. + 2022-03-09 Harald Anlauf PR fortran/104849 -- cgit v1.1 From 6393122d271a92d5d9d8656a57ea167e92498871 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 18 Mar 2022 14:50:36 +0100 Subject: Fortran/OpenMP: Improve associate-name diagnostic [PR103039] gcc/fortran/ChangeLog: PR fortran/103039 * openmp.cc (resolve_omp_clauses): Improve associate-name diagnostic for select type/rank. gcc/testsuite/ChangeLog: PR fortran/103039 * gfortran.dg/gomp/associate1.f90: Update dg-error. * gfortran.dg/gomp/associate2.f90: New test. --- gcc/fortran/openmp.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 16cd03a..7141481 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -6782,8 +6782,10 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, gfc_error ("Cray pointee %qs in SHARED clause at %L", n->sym->name, &n->where); if (n->sym->attr.associate_var) - gfc_error ("ASSOCIATE name %qs in SHARED clause at %L", - n->sym->name, &n->where); + gfc_error ("Associate name %qs in SHARED clause at %L", + n->sym->attr.select_type_temporary + ? n->sym->assoc->target->symtree->n.sym->name + : n->sym->name, &n->where); if (omp_clauses->detach && n->sym == omp_clauses->detach->symtree->n.sym) gfc_error ("DETACH event handle %qs in SHARED clause at %L", @@ -7163,8 +7165,10 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, gfc_error ("Cray pointee %qs in %s clause at %L", n->sym->name, name, &n->where); if (n->sym->attr.associate_var) - gfc_error ("ASSOCIATE name %qs in %s clause at %L", - n->sym->name, name, &n->where); + gfc_error ("Associate name %qs in %s clause at %L", + n->sym->attr.select_type_temporary + ? n->sym->assoc->target->symtree->n.sym->name + : n->sym->name, name, &n->where); if (list != OMP_LIST_PRIVATE && is_reduction) { if (n->sym->attr.proc_pointer) -- cgit v1.1 From c133bdfa9e7d9225510d00dbb7270cc052e4e4ee Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 18 Mar 2022 17:40:22 +0100 Subject: Fortran/OpenMP: Fix privatization of associated names gfc_omp_predetermined_sharing cases the associate-name pointer variable to be OMP_CLAUSE_DEFAULT_FIRSTPRIVATE, which is fine. However, the associated selector is shared. Thus, the target of associate-name pointer should not get copied. (It was before but because of gfc_omp_privatize_by_reference returning false, the selector was not only wrongly copied but this was also not done properly.) gcc/fortran/ChangeLog: PR fortran/103039 * trans-openmp.cc (gfc_omp_clause_copy_ctor, gfc_omp_clause_dtor): Only privatize pointer for associate names. libgomp/ChangeLog: PR fortran/103039 * testsuite/libgomp.fortran/associate4.f90: New test. --- gcc/fortran/trans-openmp.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index fad76a4..101924f 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -808,6 +808,11 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) gcc_assert (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_FIRSTPRIVATE || OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_LINEAR); + /* Privatize pointer, only; cf. gfc_omp_predetermined_sharing. */ + if (DECL_P (OMP_CLAUSE_DECL (clause)) + && GFC_DECL_ASSOCIATE_VAR_P (OMP_CLAUSE_DECL (clause))) + return build2 (MODIFY_EXPR, TREE_TYPE (dest), dest, src); + if (DECL_ARTIFICIAL (OMP_CLAUSE_DECL (clause)) && DECL_LANG_SPECIFIC (OMP_CLAUSE_DECL (clause)) && GFC_DECL_SAVED_DESCRIPTOR (OMP_CLAUSE_DECL (clause))) @@ -1321,6 +1326,11 @@ gfc_omp_clause_dtor (tree clause, tree decl) tree type = TREE_TYPE (decl), tem; tree decl_type = TREE_TYPE (OMP_CLAUSE_DECL (clause)); + /* Only pointer was privatized; cf. gfc_omp_clause_copy_ctor. */ + if (DECL_P (OMP_CLAUSE_DECL (clause)) + && GFC_DECL_ASSOCIATE_VAR_P (OMP_CLAUSE_DECL (clause))) + return NULL_TREE; + if (DECL_ARTIFICIAL (OMP_CLAUSE_DECL (clause)) && DECL_LANG_SPECIFIC (OMP_CLAUSE_DECL (clause)) && GFC_DECL_SAVED_DESCRIPTOR (OMP_CLAUSE_DECL (clause))) -- cgit v1.1 From 8ca61ad148ffedaae1914741c78dfd13962aab92 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 19 Mar 2022 00:16:22 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index bd5a8e6..782589f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,15 @@ +2022-03-18 Tobias Burnus + + PR fortran/103039 + * trans-openmp.cc (gfc_omp_clause_copy_ctor, gfc_omp_clause_dtor): + Only privatize pointer for associate names. + +2022-03-18 Tobias Burnus + + PR fortran/103039 + * openmp.cc (resolve_omp_clauses): Improve associate-name diagnostic + for select type/rank. + 2022-03-11 Tobias Burnus * trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause): -- cgit v1.1 From 907811ddc35da6c1701ed22355ece63a8c3ed7fb Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Sun, 13 Mar 2022 22:22:55 +0100 Subject: fortran: Separate associate character lengths earlier [PR104570] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change workarounds an ICE in the evaluation of the character length of an array expression referencing an associate variable; the code is not prepared to see a non-scalar expression as it doesn’t initialize the scalarizer. Before this change, associate length symbols get a new gfc_charlen at resolution stage to unshare them from the associate expression, so that at translation stage it is a decl specific to the associate symbol that is initialized, not the decl of some other symbol. This reinitialization of gfc_charlen happens after expressions referencing the associate symbol have been parsed, so that those expressions retain the original gfc_charlen they have copied from the symbol. At translation stage, the gfc_charlen for the associate symbol is setup with the decl holding the actual length value, but the expressions have retained the original gfc_charlen without any decl. So they need to evaluate the character length, and this is where the ICE happens. This change moves the reinitialization of gfc_charlen earlier at parsing stage, so that at resolution stage the gfc_charlen can be retained as it’s already not shared with any other symbol, and the expressions which now share their gfc_charlen with the symbol are automatically updated when the length decl is setup at translation stage. There is no need any more to evaluate the character length as it has all the required information, and the ICE doesn’t happen. The first resolve.cc hunk is necessary to avoid regressing on the associate_35.f90 testcase. PR fortran/104228 PR fortran/104570 gcc/fortran/ChangeLog: * parse.cc (parse_associate): Use a new distinct gfc_charlen if the copied type has one whose length is not known to be constant. * resolve.cc (resolve_assoc_var): Reset charlen if it’s shared with the associate target regardless of the expression type. Don’t reinitialize charlen if it’s deferred. gcc/testsuite/ChangeLog: * gfortran.dg/associate_58.f90: New test. --- gcc/fortran/parse.cc | 18 ++++++++++++++++++ gcc/fortran/resolve.cc | 9 ++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index db91829..e6e915d 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -4924,6 +4924,24 @@ parse_associate (void) in case of association to a derived-type. */ sym->ts = a->target->ts; + /* Don’t share the character length information between associate + variable and target if the length is not a compile-time constant, + as we don’t want to touch some other character length variable when + we try to initialize the associate variable’s character length + variable. + We do it here rather than later so that expressions referencing the + associate variable will automatically have the correctly setup length + information. If we did it at resolution stage the expressions would + use the original length information, and the variable a new different + one, but only the latter one would be correctly initialized at + translation stage, and the former one would need some additional setup + there. */ + if (sym->ts.type == BT_CHARACTER + && sym->ts.u.cl + && !(sym->ts.u.cl->length + && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)) + sym->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL); + /* Check if the target expression is array valued. This cannot always be done by looking at target.rank, because that might not have been set yet. Therefore traverse the chain of refs, looking for the last diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 0b55961..5522be7 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -9232,7 +9232,7 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) if (!sym->ts.u.cl) sym->ts.u.cl = target->ts.u.cl; - if (sym->ts.deferred && target->expr_type == EXPR_VARIABLE + if (sym->ts.deferred && sym->ts.u.cl == target->ts.u.cl) { sym->ts.u.cl = gfc_new_charlen (sym->ns, NULL); @@ -9251,8 +9251,11 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) || sym->ts.u.cl->length->expr_type != EXPR_CONSTANT) && target->expr_type != EXPR_VARIABLE) { - sym->ts.u.cl = gfc_new_charlen (sym->ns, NULL); - sym->ts.deferred = 1; + if (!sym->ts.deferred) + { + sym->ts.u.cl = gfc_new_charlen (sym->ns, NULL); + sym->ts.deferred = 1; + } /* This is reset in trans-stmt.cc after the assignment of the target expression to the associate name. */ -- cgit v1.1 From d7f00da1c0ed414175305c41a07b3a50fa577cce Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 20 Mar 2022 00:16:30 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 782589f..59cb22e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-03-19 Mikael Morin + + PR fortran/104228 + PR fortran/104570 + * parse.cc (parse_associate): Use a new distinct gfc_charlen if the + copied type has one whose length is not known to be constant. + * resolve.cc (resolve_assoc_var): Reset charlen if it’s shared with + the associate target regardless of the expression type. + Don’t reinitialize charlen if it’s deferred. + 2022-03-18 Tobias Burnus PR fortran/103039 -- cgit v1.1 From 774ab2edcb5f3a24ed3a5cffd1143bd49a69f1ee Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 22 Mar 2022 20:54:18 +0100 Subject: Fortran: ensure intialization of stride array gcc/fortran/ChangeLog: PR fortran/104999 * simplify.cc (gfc_simplify_cshift): Ensure temporary holding source array stride is initialized. --- gcc/fortran/simplify.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 0c15bcb..233cc42 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -2134,6 +2134,7 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim) resultvec = XCNEWVEC (gfc_expr *, arraysize); + sstride[0] = 0; extent[0] = 1; count[0] = 0; -- cgit v1.1 From a2287813b1369b8fae67f2220d23c552945180ed Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 23 Mar 2022 00:16:45 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 59cb22e..2dfdf06 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-03-22 Harald Anlauf + + PR fortran/104999 + * simplify.cc (gfc_simplify_cshift): Ensure temporary holding + source array stride is initialized. + 2022-03-19 Mikael Morin PR fortran/104228 -- cgit v1.1 From 5e33fea21957c97d63e3738be6056ae2a94e3284 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 23 Mar 2022 16:54:12 +0100 Subject: Fortran: Fix directory stat check for '.' [PR103560] MinGW does not like a call to 'stat' for './' via gfc_do_check_include_dir. Solution: Only append '/' when concatenating the path with the filename. gcc/fortran/ChangeLog: PR fortran/103560 * scanner.cc (add_path_to_list): Don't append '/' to the save include path. (open_included_file): Use '/' in concatenating path + file name. * module.cc (gzopen_included_file_1): Likewise. gcc/testsuite/ChangeLog: PR fortran/103560 * gfortran.dg/include_14.f90: Update dg-warning. * gfortran.dg/include_17.f90: Likewise. * gfortran.dg/include_18.f90: Likewise. * gfortran.dg/include_6.f90: Update dg-*. --- gcc/fortran/module.cc | 3 ++- gcc/fortran/scanner.cc | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 281b1b1..85aa153 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -1095,8 +1095,9 @@ gzopen_included_file_1 (const char *name, gfc_directorylist *list, if (module && !p->use_for_modules) continue; - fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1); + fullname = (char *) alloca(strlen (p->path) + strlen (name) + 2); strcpy (fullname, p->path); + strcat (fullname, "/"); strcat (fullname, name); f = gzopen (fullname, "r"); diff --git a/gcc/fortran/scanner.cc b/gcc/fortran/scanner.cc index b52282b..2dff251 100644 --- a/gcc/fortran/scanner.cc +++ b/gcc/fortran/scanner.cc @@ -409,9 +409,7 @@ add_path_to_list (gfc_directorylist **list, const char *path, *list = dir; dir->use_for_modules = use_for_modules; dir->warn = warn; - dir->path = XCNEWVEC (char, strlen (p) + 2); - strcpy (dir->path, p); - strcat (dir->path, "/"); /* make '/' last character */ + dir->path = xstrdup (p); } /* defer_warn is set to true while parsing the commandline. */ @@ -476,8 +474,9 @@ open_included_file (const char *name, gfc_directorylist *list, if (module && !p->use_for_modules) continue; - fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1); + fullname = (char *) alloca(strlen (p->path) + strlen (name) + 2); strcpy (fullname, p->path); + strcat (fullname, "/"); strcat (fullname, name); f = gfc_open_file (fullname); -- cgit v1.1 From d1ca63a1b7d5986913b14567a4950b055a5a3f07 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 24 Mar 2022 00:16:44 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2dfdf06..95ca699 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-03-23 Tobias Burnus + + PR fortran/103560 + * scanner.cc (add_path_to_list): Don't append '/' to the + save include path. + (open_included_file): Use '/' in concatenating path + file name. + * module.cc (gzopen_included_file_1): Likewise. + 2022-03-22 Harald Anlauf PR fortran/104999 -- cgit v1.1 From 45e955b0a936eafc9838cdc00dcc31b3799b321b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 25 Mar 2022 11:22:15 +0100 Subject: fortran: Fix up initializers of param(0) PARAMETERs [PR103691] On the gfortran.dg/pr103691.f90 testcase the Fortran ICE emits static real(kind=4) a[0] = {[0 ... -1]=2.0e+0}; That is an invalid RANGE_EXPR where the maximum is smaller than the minimum. The following patch fixes that. If TYPE_MAX_VALUE is smaller than TYPE_MIN_VALUE, the array is empty and so doesn't need any initializer, if the two are equal, we don't need to bother with a RANGE_EXPR and can just use that INTEGER_CST as the index and finally for the 2+ values in the range it uses a RANGE_EXPR as before. 2022-03-25 Jakub Jelinek PR fortran/103691 * trans-array.cc (gfc_conv_array_initializer): If TYPE_MAX_VALUE is smaller than TYPE_MIN_VALUE (i.e. empty array), ignore the initializer; if TYPE_MIN_VALUE is equal to TYPE_MAX_VALUE, use just the TYPE_MIN_VALUE as index instead of RANGE_EXPR. --- gcc/fortran/trans-array.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index cfb6eac..b3f8871 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -6267,10 +6267,17 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) else gfc_conv_structure (&se, expr, 1); - CONSTRUCTOR_APPEND_ELT (v, build2 (RANGE_EXPR, gfc_array_index_type, - TYPE_MIN_VALUE (TYPE_DOMAIN (type)), - TYPE_MAX_VALUE (TYPE_DOMAIN (type))), - se.expr); + if (tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), + TYPE_MIN_VALUE (TYPE_DOMAIN (type)))) + break; + else if (tree_int_cst_equal (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), + TYPE_MAX_VALUE (TYPE_DOMAIN (type)))) + range = TYPE_MIN_VALUE (TYPE_DOMAIN (type)); + else + range = build2 (RANGE_EXPR, gfc_array_index_type, + TYPE_MIN_VALUE (TYPE_DOMAIN (type)), + TYPE_MAX_VALUE (TYPE_DOMAIN (type))); + CONSTRUCTOR_APPEND_ELT (v, range, se.expr); break; case EXPR_ARRAY: -- cgit v1.1 From 31e989a2785bee8d507f2a06b5d3bd8c45989ab5 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 26 Mar 2022 10:22:39 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 95ca699..a2aac51 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-03-25 Jakub Jelinek + + PR fortran/103691 + * trans-array.cc (gfc_conv_array_initializer): If TYPE_MAX_VALUE is + smaller than TYPE_MIN_VALUE (i.e. empty array), ignore the + initializer; if TYPE_MIN_VALUE is equal to TYPE_MAX_VALUE, use just + the TYPE_MIN_VALUE as index instead of RANGE_EXPR. + 2022-03-23 Tobias Burnus PR fortran/103560 -- cgit v1.1 From 0712f356374c2cf26015cccfa3141537e42cbb12 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 27 Mar 2022 21:35:15 +0200 Subject: Fortran: character length of pointer assignments in structure constructors gcc/fortran/ChangeLog: PR fortran/50549 * resolve.cc (resolve_structure_cons): Reject pointer assignments of character with different lengths in structure constructor. gcc/testsuite/ChangeLog: PR fortran/50549 * gfortran.dg/char_pointer_assign_7.f90: New test. --- gcc/fortran/resolve.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 5522be7..2907677 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -1375,11 +1375,22 @@ resolve_structure_cons (gfc_expr *expr, int init) && comp->ts.u.cl->length->expr_type == EXPR_CONSTANT && cons->expr->ts.u.cl && cons->expr->ts.u.cl->length && cons->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT - && cons->expr->rank != 0 && mpz_cmp (cons->expr->ts.u.cl->length->value.integer, comp->ts.u.cl->length->value.integer) != 0) { + if (comp->attr.pointer) + { + HOST_WIDE_INT la, lb; + la = gfc_mpz_get_hwi (comp->ts.u.cl->length->value.integer); + lb = gfc_mpz_get_hwi (cons->expr->ts.u.cl->length->value.integer); + gfc_error ("Unequal character lengths (%wd/%wd) for pointer " + "component %qs in constructor at %L", + la, lb, comp->name, &cons->expr->where); + t = false; + } + if (cons->expr->expr_type == EXPR_VARIABLE + && cons->expr->rank != 0 && cons->expr->symtree->n.sym->attr.flavor == FL_PARAMETER) { /* Wrap the parameter in an array constructor (EXPR_ARRAY) -- cgit v1.1 From 69db6e7f4e1d07bf8f33e93a29139cc16c1e0a2f Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 29 Mar 2022 22:12:15 +0200 Subject: Fortran: avoid NULL pointer dereference checking elemental procedure args gcc/fortran/ChangeLog: PR fortran/104571 * resolve.cc (resolve_elemental_actual): Avoid NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/104571 * gfortran.dg/pr104571.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/resolve.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 2907677..21c8797 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -2397,8 +2397,9 @@ resolve_elemental_actual (gfc_expr *expr, gfc_code *c) if (rank > 0 && esym && expr == NULL) for (eformal = esym->formal, arg = arg0; arg && eformal; arg = arg->next, eformal = eformal->next) - if ((eformal->sym->attr.intent == INTENT_OUT - || eformal->sym->attr.intent == INTENT_INOUT) + if (eformal->sym + && (eformal->sym->attr.intent == INTENT_OUT + || eformal->sym->attr.intent == INTENT_INOUT) && arg->expr && arg->expr->rank == 0) { gfc_error ("Actual argument at %L for INTENT(%s) dummy %qs of " -- cgit v1.1 From 9f774626c021c244be6f4c9589c9dac71d544b15 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 30 Mar 2022 00:16:49 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a2aac51..0e05013 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,16 @@ +2022-03-29 Harald Anlauf + Steven G. Kargl + + PR fortran/104571 + * resolve.cc (resolve_elemental_actual): Avoid NULL pointer + dereference. + +2022-03-29 Harald Anlauf + + PR fortran/50549 + * resolve.cc (resolve_structure_cons): Reject pointer assignments + of character with different lengths in structure constructor. + 2022-03-25 Jakub Jelinek PR fortran/103691 -- cgit v1.1 From b4e4b35f4ebe561826489bed971324efc99c5423 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 30 Mar 2022 22:36:12 +0200 Subject: Fortran: NULL pointer dereference checking arguments to ASSOCIATED intrinsic gcc/fortran/ChangeLog: PR fortran/100892 * check.cc (gfc_check_associated): Avoid NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/100892 * gfortran.dg/associated_target_8.f90: New test. --- gcc/fortran/check.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index fc97bb1..0c2cb50 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -1504,7 +1504,7 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *target) argument of intrinsic inquiry functions. */ if (pointer->rank != -1 && !rank_check (target, 0, pointer->rank)) t = false; - if (target->rank > 0) + if (target->rank > 0 && target->ref) { for (i = 0; i < target->rank; i++) if (target->ref->u.ar.dimen_type[i] == DIMEN_VECTOR) -- cgit v1.1 From 150ab50f7449cf5b496bbe6e5c60cb1adb2e2d6c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 31 Mar 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0e05013..3f5ccf6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-03-30 Harald Anlauf + + PR fortran/100892 + * check.cc (gfc_check_associated): Avoid NULL pointer dereference. + 2022-03-29 Harald Anlauf Steven G. Kargl -- cgit v1.1 From d46685b04071a485b56de353d997a866bfc8caba Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 4 Apr 2022 20:42:51 +0200 Subject: Fortran: a RECURSIVE procedure cannot be an INTRINSIC gcc/fortran/ChangeLog: PR fortran/105138 * intrinsic.cc (gfc_is_intrinsic): When a symbol refers to a RECURSIVE procedure, it cannot be an INTRINSIC. gcc/testsuite/ChangeLog: PR fortran/105138 * gfortran.dg/recursive_reference_3.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/intrinsic.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc index 2339d90..e89131f 100644 --- a/gcc/fortran/intrinsic.cc +++ b/gcc/fortran/intrinsic.cc @@ -1164,6 +1164,7 @@ gfc_is_intrinsic (gfc_symbol* sym, int subroutine_flag, locus loc) /* Check for attributes which prevent the symbol from being INTRINSIC. */ if (sym->attr.external || sym->attr.contained + || sym->attr.recursive || sym->attr.if_source == IFSRC_IFBODY) return false; -- cgit v1.1 From 892c7f03ae63121766a8be48f7e3b672547fd627 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 29 Mar 2022 23:33:23 +0200 Subject: Fortran: improve error recovery for invalid coarray function declarations gcc/fortran/ChangeLog: PR fortran/104210 * arith.cc (eval_intrinsic): Avoid NULL pointer dereference. (gfc_zero_size_array): Likewise. gcc/testsuite/ChangeLog: PR fortran/104210 * gfortran.dg/pr104210.f90: New test. --- gcc/fortran/arith.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index 06e032e..d57059a 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -1489,6 +1489,9 @@ eval_intrinsic (gfc_intrinsic_op op, int unary; arith rc; + if (!op1) + return NULL; + gfc_clear_ts (&temp.ts); switch (op) @@ -1703,11 +1706,11 @@ eval_type_intrinsic0 (gfc_intrinsic_op iop, gfc_expr *op) /* Return nonzero if the expression is a zero size array. */ -static int +static bool gfc_zero_size_array (gfc_expr *e) { - if (e->expr_type != EXPR_ARRAY) - return 0; + if (e == NULL || e->expr_type != EXPR_ARRAY) + return false; return e->value.constructor == NULL; } -- cgit v1.1 From 7de46116aa8c9bc4c5d24cb58ff717be8f0b650e Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Tue, 5 Apr 2022 12:06:56 -0700 Subject: Fortran: Fix clause splitting for OMP masked taskloop directive This patch fixes an obvious coding goof that caused all clauses for the combined OMP masked taskloop directive to be discarded. gcc/fortran/ * trans-openmp.cc (gfc_split_omp_clauses): Fix mask for EXEC_OMP_MASKED_TASKLOOP. gcc/testsuite/ * gfortran.dg/gomp/masked-taskloop.f90: New. --- gcc/fortran/trans-openmp.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 101924f..25dde82 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -5998,7 +5998,7 @@ gfc_split_omp_clauses (gfc_code *code, innermost = GFC_OMP_SPLIT_DO; break; case EXEC_OMP_MASKED_TASKLOOP: - mask = GFC_OMP_SPLIT_MASKED | GFC_OMP_SPLIT_TASKLOOP; + mask = GFC_OMP_MASK_MASKED | GFC_OMP_MASK_TASKLOOP; innermost = GFC_OMP_SPLIT_TASKLOOP; break; case EXEC_OMP_MASTER_TASKLOOP: -- cgit v1.1 From 9d84ed6812dce4a50e64334e7cc4abdeebe41523 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 6 Apr 2022 00:16:22 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3f5ccf6..0328328 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,21 @@ +2022-04-05 Sandra Loosemore + + * trans-openmp.cc (gfc_split_omp_clauses): Fix mask for + EXEC_OMP_MASKED_TASKLOOP. + +2022-04-05 Harald Anlauf + + PR fortran/104210 + * arith.cc (eval_intrinsic): Avoid NULL pointer dereference. + (gfc_zero_size_array): Likewise. + +2022-04-05 Harald Anlauf + Steven G. Kargl + + PR fortran/105138 + * intrinsic.cc (gfc_is_intrinsic): When a symbol refers to a + RECURSIVE procedure, it cannot be an INTRINSIC. + 2022-03-30 Harald Anlauf PR fortran/100892 -- cgit v1.1 From 54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 6 Apr 2022 22:24:21 +0200 Subject: Fortran: fix checking of coshape specification in ALLOCATE statement gcc/fortran/ChangeLog: PR fortran/105184 * array.cc (match_subscript): Reject assumed size coarray specification with missing lower bound. * resolve.cc (resolve_allocate_expr): Fix logic for checking allocate-coshape-spec in ALLOCATE statement. gcc/testsuite/ChangeLog: PR fortran/105184 * gfortran.dg/coarray_44.f90: Adjust expected output. * gfortran.dg/coarray_allocate_11.f90: Likewise. * gfortran.dg/coarray_allocate_12.f90: New test. --- gcc/fortran/array.cc | 7 +++++++ gcc/fortran/resolve.cc | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index eb9ed85..90ea812 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -134,6 +134,13 @@ end_element: if (m == MATCH_ERROR) return MATCH_ERROR; + if (star && ar->start[i] == NULL) + { + gfc_error ("Missing lower bound in assumed size " + "coarray specification at %C"); + return MATCH_ERROR; + } + /* See if we have an optional stride. */ if (gfc_match_char (':') == MATCH_YES) { diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 21c8797..05f8f1b 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -8108,12 +8108,13 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec) goto failure; case DIMEN_RANGE: - if (ar->start[i] == 0 || ar->end[i] == 0) + /* F2018:R937: + * allocate-coshape-spec is [ lower-bound-expr : ] upper-bound-expr + */ + if (ar->start[i] == 0 || ar->end[i] == 0 || ar->stride[i] != NULL) { - /* If ar->stride[i] is NULL, we issued a previous error. */ - if (ar->stride[i] == NULL) - gfc_error ("Bad array specification in ALLOCATE statement " - "at %L", &e->where); + gfc_error ("Bad coarray specification in ALLOCATE statement " + "at %L", &e->where); goto failure; } else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1) -- cgit v1.1 From a1950f5282d2c82fb180689023e234484ac9a61d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 11 Apr 2022 00:16:26 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0328328..3984032 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-04-10 Harald Anlauf + + PR fortran/105184 + * array.cc (match_subscript): Reject assumed size coarray + specification with missing lower bound. + * resolve.cc (resolve_allocate_expr): Fix logic for checking + allocate-coshape-spec in ALLOCATE statement. + 2022-04-05 Sandra Loosemore * trans-openmp.cc (gfc_split_omp_clauses): Fix mask for -- cgit v1.1 From 469fad0161afeb9369010ad498198297993ca592 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 13 Apr 2022 18:40:52 +0200 Subject: OpenMP/Fortran: Fix EXIT in loop diagnostic [PR105242] gcc/fortran/ChangeLog: PR fortran/105242 * match.cc (match_exit_cycle): Handle missing OMP LOOP, DO and SIMD directives in the EXIT/CYCLE diagnostic. gcc/testsuite/ChangeLog: PR fortran/105242 * gfortran.dg/gomp/loop-exit.f90: New test. --- gcc/fortran/match.cc | 166 +++++++++++++++++++++++++++++---------------------- 1 file changed, 95 insertions(+), 71 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 715a74e..205811b 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -2857,83 +2857,107 @@ match_exit_cycle (gfc_statement st, gfc_exec_op op) for (o = p, cnt = 0; o->state == COMP_DO && o->previous != NULL; cnt++) o = o->previous; + + int count = 1; if (cnt > 0 && o != NULL - && o->state == COMP_OMP_STRUCTURED_BLOCK - && (o->head->op == EXEC_OACC_LOOP - || o->head->op == EXEC_OACC_KERNELS_LOOP - || o->head->op == EXEC_OACC_PARALLEL_LOOP - || o->head->op == EXEC_OACC_SERIAL_LOOP)) - { - int collapse = 1; - gcc_assert (o->head->next != NULL - && (o->head->next->op == EXEC_DO - || o->head->next->op == EXEC_DO_WHILE) - && o->previous != NULL - && o->previous->tail->op == o->head->op); - if (o->previous->tail->ext.omp_clauses != NULL) - { - /* Both collapsed and tiled loops are lowered the same way, but are not - compatible. In gfc_trans_omp_do, the tile is prioritized. */ - if (o->previous->tail->ext.omp_clauses->tile_list) - { - collapse = 0; - gfc_expr_list *el = o->previous->tail->ext.omp_clauses->tile_list; - for ( ; el; el = el->next) - ++collapse; - } - else if (o->previous->tail->ext.omp_clauses->collapse > 1) - collapse = o->previous->tail->ext.omp_clauses->collapse; - } - if (st == ST_EXIT && cnt <= collapse) - { - gfc_error ("EXIT statement at %C terminating !$ACC LOOP loop"); - return MATCH_ERROR; - } - if (st == ST_CYCLE && cnt < collapse) - { - gfc_error (o->previous->tail->ext.omp_clauses->tile_list - ? G_("CYCLE statement at %C to non-innermost tiled" - " !$ACC LOOP loop") - : G_("CYCLE statement at %C to non-innermost collapsed" - " !$ACC LOOP loop")); - return MATCH_ERROR; - } - } - if (cnt > 0 - && o != NULL - && (o->state == COMP_OMP_STRUCTURED_BLOCK) - && (o->head->op == EXEC_OMP_DO - || o->head->op == EXEC_OMP_PARALLEL_DO - || o->head->op == EXEC_OMP_SIMD - || o->head->op == EXEC_OMP_DO_SIMD - || o->head->op == EXEC_OMP_PARALLEL_DO_SIMD)) - { - int count = 1; - gcc_assert (o->head->next != NULL + && o->state == COMP_OMP_STRUCTURED_BLOCK) + switch (o->head->op) + { + case EXEC_OACC_LOOP: + case EXEC_OACC_KERNELS_LOOP: + case EXEC_OACC_PARALLEL_LOOP: + case EXEC_OACC_SERIAL_LOOP: + gcc_assert (o->head->next != NULL + && (o->head->next->op == EXEC_DO + || o->head->next->op == EXEC_DO_WHILE) + && o->previous != NULL + && o->previous->tail->op == o->head->op); + if (o->previous->tail->ext.omp_clauses != NULL) + { + /* Both collapsed and tiled loops are lowered the same way, but are + not compatible. In gfc_trans_omp_do, the tile is prioritized. */ + if (o->previous->tail->ext.omp_clauses->tile_list) + { + count = 0; + gfc_expr_list *el + = o->previous->tail->ext.omp_clauses->tile_list; + for ( ; el; el = el->next) + ++count; + } + else if (o->previous->tail->ext.omp_clauses->collapse > 1) + count = o->previous->tail->ext.omp_clauses->collapse; + } + if (st == ST_EXIT && cnt <= count) + { + gfc_error ("EXIT statement at %C terminating !$ACC LOOP loop"); + return MATCH_ERROR; + } + if (st == ST_CYCLE && cnt < count) + { + gfc_error (o->previous->tail->ext.omp_clauses->tile_list + ? G_("CYCLE statement at %C to non-innermost tiled " + "!$ACC LOOP loop") + : G_("CYCLE statement at %C to non-innermost collapsed " + "!$ACC LOOP loop")); + return MATCH_ERROR; + } + break; + case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: + case EXEC_OMP_TARGET_PARALLEL_DO_SIMD: + case EXEC_OMP_TARGET_SIMD: + case EXEC_OMP_TASKLOOP_SIMD: + case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD: + case EXEC_OMP_MASTER_TASKLOOP_SIMD: + case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD: + case EXEC_OMP_MASKED_TASKLOOP_SIMD: + case EXEC_OMP_PARALLEL_DO_SIMD: + case EXEC_OMP_DISTRIBUTE_SIMD: + case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: + case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: + case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: + case EXEC_OMP_LOOP: + case EXEC_OMP_PARALLEL_LOOP: + case EXEC_OMP_TEAMS_LOOP: + case EXEC_OMP_TARGET_PARALLEL_LOOP: + case EXEC_OMP_TARGET_TEAMS_LOOP: + case EXEC_OMP_DO: + case EXEC_OMP_PARALLEL_DO: + case EXEC_OMP_SIMD: + case EXEC_OMP_DO_SIMD: + case EXEC_OMP_DISTRIBUTE_PARALLEL_DO: + case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO: + case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO: + case EXEC_OMP_TARGET_PARALLEL_DO: + case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: + + gcc_assert (o->head->next != NULL && (o->head->next->op == EXEC_DO || o->head->next->op == EXEC_DO_WHILE) && o->previous != NULL && o->previous->tail->op == o->head->op); - if (o->previous->tail->ext.omp_clauses != NULL) - { - if (o->previous->tail->ext.omp_clauses->collapse > 1) - count = o->previous->tail->ext.omp_clauses->collapse; - if (o->previous->tail->ext.omp_clauses->orderedc) - count = o->previous->tail->ext.omp_clauses->orderedc; - } - if (st == ST_EXIT && cnt <= count) - { - gfc_error ("EXIT statement at %C terminating !$OMP DO loop"); - return MATCH_ERROR; - } - if (st == ST_CYCLE && cnt < count) - { - gfc_error ("CYCLE statement at %C to non-innermost collapsed" - " !$OMP DO loop"); - return MATCH_ERROR; - } - } + if (o->previous->tail->ext.omp_clauses != NULL) + { + if (o->previous->tail->ext.omp_clauses->collapse > 1) + count = o->previous->tail->ext.omp_clauses->collapse; + if (o->previous->tail->ext.omp_clauses->orderedc) + count = o->previous->tail->ext.omp_clauses->orderedc; + } + if (st == ST_EXIT && cnt <= count) + { + gfc_error ("EXIT statement at %C terminating !$OMP DO loop"); + return MATCH_ERROR; + } + if (st == ST_CYCLE && cnt < count) + { + gfc_error ("CYCLE statement at %C to non-innermost collapsed " + "!$OMP DO loop"); + return MATCH_ERROR; + } + break; + default: + break; + } /* Save the first statement in the construct - needed by the backend. */ new_st.ext.which_construct = p->construct; -- cgit v1.1 From 247bbed1b8a63201b39714bb705a9d75cbba0090 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 14 Apr 2022 00:16:40 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3984032..b822c18 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-04-13 Tobias Burnus + + PR fortran/105242 + * match.cc (match_exit_cycle): Handle missing OMP LOOP, DO and SIMD + directives in the EXIT/CYCLE diagnostic. + 2022-04-10 Harald Anlauf PR fortran/105184 -- cgit v1.1 From c049f638da4f7b32b11e4d895184e0960bae5291 Mon Sep 17 00:00:00 2001 From: Fritz Reese Date: Tue, 19 Apr 2022 16:45:46 -0400 Subject: fortran: Fix conv of UNION constructors [PR105310] This fixes an ICE when a UNION is the (1+8*2^n)-th field in a DEC STRUCTURE when compiled with -finit-derived -finit-local-zero. The problem was CONSTRUCTOR_APPEND_ELT from within gfc_conv_union_initializer modified the vector pointer, but the pointer was passed by-value, so the old pointer from the caller (gfc_conv_structure) pointed to freed memory. PR fortran/105310 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_union_initializer): Pass vec* by reference. gcc/testsuite/ChangeLog: * gfortran.dg/dec_union_12.f90: New test. --- gcc/fortran/trans-expr.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 06713f2..ab710ef 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -9194,8 +9194,8 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr, bool init, bool coarray) return gfc_finish_block (&block); } -void -gfc_conv_union_initializer (vec *v, +static void +gfc_conv_union_initializer (vec *&v, gfc_component *un, gfc_expr *init) { gfc_constructor *ctor; -- cgit v1.1 From c1a9cf679153719d066f1ec79154c406e1e48cdf Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 22 Apr 2022 00:16:43 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b822c18..e1d1a75 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-04-21 Fritz Reese + + PR fortran/105310 + * trans-expr.cc (gfc_conv_union_initializer): Pass vec* by reference. + 2022-04-13 Tobias Burnus PR fortran/105242 -- cgit v1.1 From 89ca0fffa48b799b228beee48a16e26e24d8e199 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Fri, 22 Apr 2022 22:52:12 +0200 Subject: fortran: Pre-evaluate string pointers. [PR102043] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids a regression on deferred_character_23.f90 later in the patch series when array references are rewritten to use pointer arithmetic. The problem is a SAVE_EXPR tree as TYPE_SIZE_UNIT of one array element type, which is used by the pointer arithmetic expressions. As these expressions appear in both branches of an if-then-else block, the tree is lowered to a variable in one of the branches but it’s used in both branches, which is invalid middle-end code. This change pre-evaluates the array references or pointer arithmetics to variables before the if-then-else block, so that the SAVE_EXPR are expanded to variables in the parent scope of the if-then-else block, and expressions referencing the variables remain valid in both branches. PR fortran/102043 gcc/fortran/ChangeLog: * trans-expr.cc: Pre-evaluate src and dest to variables before using them. gcc/testsuite/ChangeLog: * gfortran.dg/dependency_49.f90: Update variable occurence count. --- gcc/fortran/trans-expr.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index ab710ef..d7a368a 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -8093,6 +8093,13 @@ gfc_trans_string_copy (stmtblock_t * block, tree dlength, tree dest, cond2 = fold_build2_loc (input_location, LT_EXPR, logical_type_node, slen, dlen); + /* Pre-evaluate pointers unless one of the IF arms will be optimized away. */ + if (!CONSTANT_CLASS_P (cond2)) + { + dest = gfc_evaluate_now (dest, block); + src = gfc_evaluate_now (src, block); + } + /* Copy and pad with spaces. */ tmp3 = build_call_expr_loc (input_location, builtin_decl_explicit (BUILT_IN_MEMMOVE), -- cgit v1.1 From e72fbb6915c1dd1a52ecef55e10329e353cc3072 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Fri, 22 Apr 2022 22:52:26 +0200 Subject: fortran: Update index extraction code. [PR102043] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids a regression on hollerith4.f90 and hollerith6.f90 later in the patch series when code generation for array references is changed to use pointer arithmetic. The problem comes from the extraction of the array index from an ARRAY_REF tree, which doesn’t work if the tree is not an ARRAY_REF any more. This updates the code generated for remaining size evaluation to work with a source tree that uses either array indexing or pointer arithmetic. PR fortran/102043 gcc/fortran/ChangeLog: * trans-io.cc: Add handling for the case where the array is referenced using pointer arithmetic. --- gcc/fortran/trans-io.cc | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc index 732221f..9f86815 100644 --- a/gcc/fortran/trans-io.cc +++ b/gcc/fortran/trans-io.cc @@ -737,7 +737,6 @@ set_parameter_ref (stmtblock_t *block, stmtblock_t *postblock, static void gfc_convert_array_to_string (gfc_se * se, gfc_expr * e) { - tree size; if (e->rank == 0) { @@ -755,12 +754,13 @@ gfc_convert_array_to_string (gfc_se * se, gfc_expr * e) array = sym->backend_decl; type = TREE_TYPE (array); + tree elts_count; if (GFC_ARRAY_TYPE_P (type)) - size = GFC_TYPE_ARRAY_SIZE (type); + elts_count = GFC_TYPE_ARRAY_SIZE (type); else { gcc_assert (GFC_DESCRIPTOR_TYPE_P (type)); - size = gfc_conv_array_stride (array, rank); + tree stride = gfc_conv_array_stride (array, rank); tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, gfc_conv_array_ubound (array, rank), @@ -768,23 +768,49 @@ gfc_convert_array_to_string (gfc_se * se, gfc_expr * e) tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, tmp, gfc_index_one_node); + elts_count = fold_build2_loc (input_location, MULT_EXPR, + gfc_array_index_type, tmp, stride); + } + gcc_assert (elts_count); + + tree elt_size = TYPE_SIZE_UNIT (gfc_get_element_type (type)); + elt_size = fold_convert (gfc_array_index_type, elt_size); + + tree size; + if (TREE_CODE (se->expr) == ARRAY_REF) + { + tree index = TREE_OPERAND (se->expr, 1); + index = fold_convert (gfc_array_index_type, index); + + elts_count = fold_build2_loc (input_location, MINUS_EXPR, + gfc_array_index_type, + elts_count, index); + size = fold_build2_loc (input_location, MULT_EXPR, - gfc_array_index_type, tmp, size); + gfc_array_index_type, elts_count, elt_size); + } + else + { + gcc_assert (TREE_CODE (se->expr) == INDIRECT_REF); + tree ptr = TREE_OPERAND (se->expr, 0); + + gcc_assert (TREE_CODE (ptr) == POINTER_PLUS_EXPR); + tree offset = fold_convert_loc (input_location, gfc_array_index_type, + TREE_OPERAND (ptr, 1)); + + size = fold_build2_loc (input_location, MULT_EXPR, + gfc_array_index_type, elts_count, elt_size); + size = fold_build2_loc (input_location, MINUS_EXPR, + gfc_array_index_type, size, offset); } gcc_assert (size); - size = fold_build2_loc (input_location, MINUS_EXPR, - gfc_array_index_type, size, - TREE_OPERAND (se->expr, 1)); se->expr = gfc_build_addr_expr (NULL_TREE, se->expr); - tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type)); - size = fold_build2_loc (input_location, MULT_EXPR, - gfc_array_index_type, size, - fold_convert (gfc_array_index_type, tmp)); se->string_length = fold_convert (gfc_charlen_type_node, size); return; } + tree size; gfc_conv_array_parameter (se, e, true, NULL, NULL, &size); se->string_length = fold_convert (gfc_charlen_type_node, size); } -- cgit v1.1 From 761dda57482295f9c41fcf87e5defa2ac1959f03 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Fri, 22 Apr 2022 22:52:38 +0200 Subject: fortran: Generate an array temporary reference [PR102043] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids regressing on char_cast_1.f90 and char_cast_2.f90 later in the patch series when the code generation for array references is changed to use pointer arithmetic. The regressing testcases match part of an array reference in the generated tree dump and it’s not clear how the pattern should be rewritten to match the equivalent with pointer arithmetic. This change uses a method specific to array temporaries to generate array-references, so that these array references are flagged as safe for array indexing and will not be updated to use pointer arithmetic. PR fortran/102043 gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_expr_descriptor): Use gfc_conv_tmp_array_ref. --- gcc/fortran/trans-array.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index b3f8871..11e47c0 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -7723,7 +7723,7 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) lse.ss = loop.temp_ss; rse.ss = ss; - gfc_conv_scalarized_array_ref (&lse, NULL); + gfc_conv_tmp_array_ref (&lse); if (expr->ts.type == BT_CHARACTER) { gfc_conv_expr (&rse, expr); -- cgit v1.1 From 7964ab6c364c410c34efe7ca2eba797d36525349 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Fri, 22 Apr 2022 22:52:50 +0200 Subject: fortran: Use pointer arithmetic to index arrays [PR102043] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code generated for array references used to be ARRAY_REF trees as could be expected. However, the middle-end may conclude from those trees that the indexes used are non-negative (more precisely not below the lower bound), which is a wrong assumption in the case of "reversed- order" arrays. The problematic arrays are those with a descriptor and having a negative stride for at least one dimension. The descriptor data points to the first element in array order (which is not the first in memory order in that case), and the negative stride(s) makes walking the array backwards (towards lower memory addresses), and we can access elements with negative index wrt data pointer. With this change, pointer arithmetic is generated by default for array references, unless we are in a case where negative indexes can’t happen (array descriptor’s dim element, substrings, explicit shape, allocatable, or assumed shape contiguous). A new flag is added to choose between array indexing and pointer arithmetic, and it’s set if the context can tell array indexing is safe (descriptor dim element, substring, temporary array), or a new method is called to decide on whether the flag should be set for one given array expression. PR fortran/102043 gcc/fortran/ChangeLog: * trans.h (gfc_build_array_ref): Add non_negative_offset argument. * trans.cc (gfc_build_array_ref): Ditto. Use pointer arithmetic if non_negative_offset is false. * trans-expr.cc (gfc_conv_substring): Set flag in the call to gfc_build_array_ref. * trans-array.cc (gfc_get_cfi_dim_item, gfc_conv_descriptor_dimension): Same. (build_array_ref): Decide on whether to set the flag and update the call. (gfc_conv_scalarized_array_ref): Same. New argument tmp_array. (gfc_conv_tmp_array_ref): Update call to gfc_conv_scalarized_ref. (non_negative_strides_array_p): New function. gcc/testsuite/ChangeLog: * gfortran.dg/array_reference_3.f90: New. * gfortran.dg/negative_stride_1.f90: New. * gfortran.dg/vector_subscript_8.f90: New. * gfortran.dg/vector_subscript_9.f90: New. * gfortran.dg/c_loc_test_22.f90: Update dump patterns. * gfortran.dg/finalize_10.f90: Same. Co-Authored-By: Richard Biener --- gcc/fortran/trans-array.cc | 58 +++++++++++++++++++++++++++++++++++++++++----- gcc/fortran/trans-expr.cc | 2 +- gcc/fortran/trans.cc | 42 +++++++++++++++++++++++++++++---- gcc/fortran/trans.h | 4 +++- 4 files changed, 94 insertions(+), 12 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 11e47c0..e4b6270 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -172,7 +172,7 @@ static tree gfc_get_cfi_dim_item (tree desc, tree idx, unsigned field_idx) { tree tmp = gfc_get_cfi_descriptor_field (desc, CFI_FIELD_DIM); - tmp = gfc_build_array_ref (tmp, idx, NULL); + tmp = gfc_build_array_ref (tmp, idx, NULL_TREE, true); tree field = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (tmp)), field_idx); gcc_assert (field != NULL_TREE); return fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field), @@ -424,7 +424,7 @@ gfc_conv_descriptor_dimension (tree desc, tree dim) tmp = gfc_get_descriptor_dimension (desc); - return gfc_build_array_ref (tmp, dim, NULL); + return gfc_build_array_ref (tmp, dim, NULL_TREE, true); } @@ -3664,10 +3664,51 @@ build_class_array_ref (gfc_se *se, tree base, tree index) } +/* Indicates that the tree EXPR is a reference to an array that can’t + have any negative stride. */ + +static bool +non_negative_strides_array_p (tree expr) +{ + if (expr == NULL_TREE) + return false; + + tree type = TREE_TYPE (expr); + if (POINTER_TYPE_P (type)) + type = TREE_TYPE (type); + + if (TYPE_LANG_SPECIFIC (type)) + { + gfc_array_kind array_kind = GFC_TYPE_ARRAY_AKIND (type); + + if (array_kind == GFC_ARRAY_ALLOCATABLE + || array_kind == GFC_ARRAY_ASSUMED_SHAPE_CONT) + return true; + } + + /* An array with descriptor can have negative strides. + We try to be conservative and return false by default here + if we don’t recognize a contiguous array instead of + returning false if we can identify a non-contiguous one. */ + if (!GFC_ARRAY_TYPE_P (type)) + return false; + + /* If the array was originally a dummy with a descriptor, strides can be + negative. */ + if (DECL_P (expr) + && DECL_LANG_SPECIFIC (expr)) + if (tree orig_decl = GFC_DECL_SAVED_DESCRIPTOR (expr)) + return non_negative_strides_array_p (orig_decl); + + return true; +} + + /* Build a scalarized reference to an array. */ static void -gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar) +gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar, + bool tmp_array = false) { gfc_array_info *info; tree decl = NULL_TREE; @@ -3717,7 +3758,10 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar) decl = info->descriptor; } - se->expr = gfc_build_array_ref (base, index, decl); + bool non_negative_stride = tmp_array + || non_negative_strides_array_p (info->descriptor); + se->expr = gfc_build_array_ref (base, index, decl, + non_negative_stride); } @@ -3727,7 +3771,7 @@ void gfc_conv_tmp_array_ref (gfc_se * se) { se->string_length = se->ss->info->string_length; - gfc_conv_scalarized_array_ref (se, NULL); + gfc_conv_scalarized_array_ref (se, NULL, true); gfc_advance_se_ss_chain (se); } @@ -3779,7 +3823,9 @@ build_array_ref (tree desc, tree offset, tree decl, tree vptr) tmp = gfc_conv_array_data (desc); tmp = build_fold_indirect_ref_loc (input_location, tmp); - tmp = gfc_build_array_ref (tmp, offset, decl, vptr); + tmp = gfc_build_array_ref (tmp, offset, decl, + non_negative_strides_array_p (desc), + vptr); return tmp; } diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index d7a368a..850007f 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -2612,7 +2612,7 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, /* For BIND(C), a BT_CHARACTER is not an ARRAY_TYPE. */ if (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE) { - tmp = gfc_build_array_ref (tmp, start.expr, NULL); + tmp = gfc_build_array_ref (tmp, start.expr, NULL_TREE, true); se->expr = gfc_build_addr_expr (type, tmp); } } diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 333dfa6..f0a5dfb 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -446,10 +446,14 @@ gfc_build_spanned_array_ref (tree base, tree offset, tree span) } -/* Build an ARRAY_REF with its natural type. */ +/* Build an ARRAY_REF with its natural type. + NON_NEGATIVE_OFFSET indicates if it’s true that OFFSET can’t be negative, + and thus that an ARRAY_REF can safely be generated. If it’s false, we + have to play it safe and use pointer arithmetic. */ tree -gfc_build_array_ref (tree base, tree offset, tree decl, tree vptr) +gfc_build_array_ref (tree base, tree offset, tree decl, + bool non_negative_offset, tree vptr) { tree type = TREE_TYPE (base); tree span = NULL_TREE; @@ -495,10 +499,40 @@ gfc_build_array_ref (tree base, tree offset, tree decl, tree vptr) pointer arithmetic. */ if (span != NULL_TREE) return gfc_build_spanned_array_ref (base, offset, span); - /* Otherwise use a straightforward array reference. */ - else + /* Else use a straightforward array reference if possible. */ + else if (non_negative_offset) return build4_loc (input_location, ARRAY_REF, type, base, offset, NULL_TREE, NULL_TREE); + /* Otherwise use pointer arithmetic. */ + else + { + gcc_assert (TREE_CODE (TREE_TYPE (base)) == ARRAY_TYPE); + tree min = NULL_TREE; + if (TYPE_DOMAIN (TREE_TYPE (base)) + && !integer_zerop (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (base))))) + min = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (base))); + + tree zero_based_index + = min ? fold_build2_loc (input_location, MINUS_EXPR, + gfc_array_index_type, + fold_convert (gfc_array_index_type, offset), + fold_convert (gfc_array_index_type, min)) + : fold_convert (gfc_array_index_type, offset); + + tree elt_size = fold_convert (gfc_array_index_type, + TYPE_SIZE_UNIT (type)); + + tree offset_bytes = fold_build2_loc (input_location, MULT_EXPR, + gfc_array_index_type, + zero_based_index, elt_size); + + tree base_addr = gfc_build_addr_expr (pvoid_type_node, base); + + tree ptr = fold_build_pointer_plus_loc (input_location, base_addr, + offset_bytes); + return build1_loc (input_location, INDIRECT_REF, type, + fold_convert (build_pointer_type (type), ptr)); + } } diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 738c748..623acee 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -619,7 +619,9 @@ tree gfc_get_extern_function_decl (gfc_symbol *, tree gfc_build_addr_expr (tree, tree); /* Build an ARRAY_REF. */ -tree gfc_build_array_ref (tree, tree, tree, tree vptr = NULL_TREE); +tree gfc_build_array_ref (tree, tree, tree, + bool non_negative_offset = false, + tree vptr = NULL_TREE); /* Build an array ref using pointer arithmetic. */ tree gfc_build_spanned_array_ref (tree base, tree offset, tree span); -- cgit v1.1 From ab54f6007c79711fc2192098d4ccc3c24e95f3e6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 23 Apr 2022 00:16:24 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e1d1a75..c6e3a9f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,40 @@ +2022-04-22 Mikael Morin + Richard Biener + + PR fortran/102043 + * trans.h (gfc_build_array_ref): Add non_negative_offset + argument. + * trans.cc (gfc_build_array_ref): Ditto. Use pointer arithmetic + if non_negative_offset is false. + * trans-expr.cc (gfc_conv_substring): Set flag in the call to + gfc_build_array_ref. + * trans-array.cc (gfc_get_cfi_dim_item, + gfc_conv_descriptor_dimension): Same. + (build_array_ref): Decide on whether to set the flag and update + the call. + (gfc_conv_scalarized_array_ref): Same. New argument tmp_array. + (gfc_conv_tmp_array_ref): Update call to + gfc_conv_scalarized_ref. + (non_negative_strides_array_p): New function. + +2022-04-22 Mikael Morin + + PR fortran/102043 + * trans-array.cc (gfc_conv_expr_descriptor): Use + gfc_conv_tmp_array_ref. + +2022-04-22 Mikael Morin + + PR fortran/102043 + * trans-io.cc: Add handling for the case where the array + is referenced using pointer arithmetic. + +2022-04-22 Mikael Morin + + PR fortran/102043 + * trans-expr.cc: Pre-evaluate src and dest to variables + before using them. + 2022-04-21 Fritz Reese PR fortran/105310 -- cgit v1.1 From fa5cd7102da676dcb1757b1288421f5f3439ae0e Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Sun, 24 Apr 2022 15:05:41 +0200 Subject: fortran: Detect duplicate unlimited polymorphic types [PR103662] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a type-based alias analysis issue with unlimited polymorphic class descriptors (types behind class(*)) causing data initialisation to be removed by optimization. The fortran front-end may create multiple declarations for types, for example if a type is redeclared in each program unit it is used in. To avoid optimization seeing them as non-aliasing, a list of derived types is created at resolution time, and used at translation to set the same TYPE_CANONICAL type for each duplicate type declaration. This mechanism didn’t work for unlimited polymorphic descriptors types, as there is a short-circuit return skipping all the resolution handling for them, including the type registration. This change adds type registration at the short-circuit return, and updates type comparison to handle specifically unlimited polymorphic fake symbols, class descriptor types and virtual table types. The test, which exhibited mismatching dynamic types had to be fixed as well. PR fortran/103662 gcc/fortran/ChangeLog: * interface.cc (gfc_compare_derived_types): Support comparing unlimited polymorphic fake symbols. Recursively compare class descriptor types and virtual table types. * resolve.cc (resolve_fl_derived): Add type to the types list on unlimited polymorphic short-circuit return. gcc/testsuite/ChangeLog: * gfortran.dg/unlimited_polymorphic_3.f03 (foo): Separate bind(c) and sequence checks to... (foo_bc, foo_sq): ... two different procedures. (main, foo*): Change type declarations so that type name, component name, and either bind(c) or sequence attribute match between the main type declarations and the procedure type declarations. (toplevel): Add optimization dump checks. Co-Authored-By: Jakub Jelinek --- gcc/fortran/interface.cc | 19 +++++++++++++++---- gcc/fortran/resolve.cc | 5 ++++- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 000a530..7ed6e13 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -618,6 +618,14 @@ gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2) if (!derived1 || !derived2) gfc_internal_error ("gfc_compare_derived_types: invalid derived type"); + if (derived1->attr.unlimited_polymorphic + && derived2->attr.unlimited_polymorphic) + return true; + + if (derived1->attr.unlimited_polymorphic + != derived2->attr.unlimited_polymorphic) + return false; + /* Compare UNION types specially. */ if (derived1->attr.flavor == FL_UNION || derived2->attr.flavor == FL_UNION) return compare_union_types (derived1, derived2); @@ -630,10 +638,11 @@ gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2) && strcmp (derived1->module, derived2->module) == 0) return true; - /* Compare type via the rules of the standard. Both types must have - the SEQUENCE or BIND(C) attribute to be equal. STRUCTUREs are special - because they can be anonymous; therefore two structures with different - names may be equal. */ + /* Compare type via the rules of the standard. Both types must have the + SEQUENCE or BIND(C) attribute to be equal. We also compare types + recursively if they are class descriptors types or virtual tables types. + STRUCTUREs are special because they can be anonymous; therefore two + structures with different names may be equal. */ /* Compare names, but not for anonymous types such as UNION or MAP. */ if (!is_anonymous_dt (derived1) && !is_anonymous_dt (derived2) @@ -646,6 +655,8 @@ gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2) if (!(derived1->attr.sequence && derived2->attr.sequence) && !(derived1->attr.is_bind_c && derived2->attr.is_bind_c) + && !(derived1->attr.is_class && derived2->attr.is_class) + && !(derived1->attr.vtype && derived2->attr.vtype) && !(derived1->attr.pdt_type && derived2->attr.pdt_type)) return false; diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 05f8f1b..29df531 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -15151,7 +15151,10 @@ resolve_fl_derived (gfc_symbol *sym) /* Nothing more to do for unlimited polymorphic entities. */ if (data->ts.u.derived->attr.unlimited_polymorphic) - return true; + { + add_dt_to_dt_list (sym); + return true; + } else if (vptr->ts.u.derived == NULL) { gfc_symbol *vtab = gfc_find_derived_vtab (data->ts.u.derived); -- cgit v1.1 From bd64885971be856a0feffb0d6eb59e62655d1285 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 25 Apr 2022 00:16:21 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c6e3a9f..9fe9530 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-04-24 Mikael Morin + Jakub Jelinek + + PR fortran/103662 + * interface.cc (gfc_compare_derived_types): Support comparing + unlimited polymorphic fake symbols. Recursively compare class + descriptor types and virtual table types. + * resolve.cc (resolve_fl_derived): Add type to the types list + on unlimited polymorphic short-circuit return. + 2022-04-22 Mikael Morin Richard Biener -- cgit v1.1 From b2202431910e30d8505c94d1cb9341cac7080d10 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 20 Apr 2022 19:06:17 +0200 Subject: fortran: Fix up gfc_trans_oacc_construct [PR104717] So that move_sese_region_to_fn works properly, OpenMP/OpenACC constructs for which that function is invoked need an extra artificial BIND_EXPR around their body so that we move all variables of the bodies. The C/C++ FEs do that both for OpenMP constructs like OMP_PARALLEL, OMP_TASK or OMP_TARGET and for OpenACC constructs that behave similarly to OMP_TARGET, but the Fortran FE only does that for OpenMP constructs. The following patch does that for OpenACC constructs too. PR fortran/104717 gcc/fortran/ * trans-openmp.cc (gfc_trans_oacc_construct): Wrap construct body in an extra BIND_EXPR. gcc/testsuite/ * gfortran.dg/goacc/pr104717.f90: New test. * gfortran.dg/goacc/privatization-1-compute-loop.f90: Adjust. libgomp/ * testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Adjust. Co-authored-by: Thomas Schwinge --- gcc/fortran/trans-openmp.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 25dde82..43d59ab 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -4444,7 +4444,9 @@ gfc_trans_oacc_construct (gfc_code *code) gfc_start_block (&block); oacc_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses, code->loc, false, true); + pushlevel (); stmt = gfc_trans_omp_code (code->block->next, true); + stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0)); stmt = build2_loc (gfc_get_location (&code->loc), construct_code, void_type_node, stmt, oacc_clauses); gfc_add_expr_to_block (&block, stmt); -- cgit v1.1 From 98de0da6035771b5fd9185f2a2c53dd65581b886 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 26 Apr 2022 00:16:51 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9fe9530..8c66dff 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-04-25 Jakub Jelinek + Thomas Schwinge + + PR fortran/104717 + * trans-openmp.cc (gfc_trans_oacc_construct): Wrap construct body + in an extra BIND_EXPR. + 2022-04-24 Mikael Morin Jakub Jelinek -- cgit v1.1 From 3e0c9fdfd00b5b5cbff1a0bd6ac012a10fe81348 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Wed, 27 Apr 2022 11:36:00 +0200 Subject: fortran: Avoid infinite self-recursion [PR105381] Dummy array decls are local decls different from the argument decl accessible through GFC_DECL_SAVED_DESCRIPTOR. If the argument decl has a DECL_LANG_SPECIFIC set, it is copied over to the local decl at the time the latter is created, so that the DECL_LANG_SPECIFIC object is shared between local dummy decl and argument decl, and thus the GFC_DECL_SAVED_DESCRIPTOR of the argument decl is the argument decl itself. The r12-8230-g7964ab6c364c410c34efe7ca2eba797d36525349 change introduced the non_negative_strides_array_p predicate which recurses through GFC_DECL_SAVED_DESCRIPTOR to avoid seeing dummy decls as purely local decls. As the GFC_DECL_SAVED_DESCRIPTOR of the argument decl is itself, this can cause infinite recursion. This change adds a check to avoid infinite recursion. PR fortran/102043 PR fortran/105381 gcc/fortran/ChangeLog: * trans-array.cc (non_negative_strides_array_p): Inline variable orig_decl and merge nested if conditions. Add condition to not recurse if the next argument is the same as the current. gcc/testsuite/ChangeLog: * gfortran.dg/character_array_dummy_1.f90: New test. --- gcc/fortran/trans-array.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index e4b6270..0513495 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -3696,9 +3696,10 @@ non_negative_strides_array_p (tree expr) /* If the array was originally a dummy with a descriptor, strides can be negative. */ if (DECL_P (expr) - && DECL_LANG_SPECIFIC (expr)) - if (tree orig_decl = GFC_DECL_SAVED_DESCRIPTOR (expr)) - return non_negative_strides_array_p (orig_decl); + && DECL_LANG_SPECIFIC (expr) + && GFC_DECL_SAVED_DESCRIPTOR (expr) + && GFC_DECL_SAVED_DESCRIPTOR (expr) != expr) + return non_negative_strides_array_p (GFC_DECL_SAVED_DESCRIPTOR (expr)); return true; } -- cgit v1.1 From 6a460a2007dd9c527c5f9d5bbbedb852db7c1373 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Wed, 27 Apr 2022 11:36:16 +0200 Subject: fortran: Compare non-constant bound expressions. [PR105379] Starting with r12-8235-gfa5cd7102da676dcb1757b1288421f5f3439ae0e, class descriptor types are compared to detect duplicate declarations. This caused ICEs as the comparison of array spec supported only constant explicit bounds, but dummy class variable descriptor types can have a _data field with non-constant array spec bounds. This change adds support for non-constant bounds. For that, gfc_dep_compare_expr is used. It does probably more than strictly necessary, but using it avoids rewriting a specific comparison function, making mistakes and forgetting cases. PR fortran/103662 PR fortran/105379 gcc/fortran/ChangeLog: * array.cc (compare_bounds): Use bool as return type. Support non-constant expressions. (gfc_compare_array_spec): Update call to compare_bounds. gcc/testsuite/ChangeLog: * gfortran.dg/class_dummy_8.f90: New test. * gfortran.dg/class_dummy_9.f90: New test. --- gcc/fortran/array.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index 90ea812..bbdb5b3 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -957,23 +957,28 @@ gfc_copy_array_spec (gfc_array_spec *src) } -/* Returns nonzero if the two expressions are equal. Only handles integer - constants. */ +/* Returns nonzero if the two expressions are equal. + We should not need to support more than constant values, as that’s what is + allowed in derived type component array spec. However, we may create types + with non-constant array spec for dummy variable class container types, for + which the _data component holds the array spec of the variable declaration. + So we have to support non-constant bounds as well. */ -static int +static bool compare_bounds (gfc_expr *bound1, gfc_expr *bound2) { if (bound1 == NULL || bound2 == NULL - || bound1->expr_type != EXPR_CONSTANT - || bound2->expr_type != EXPR_CONSTANT || bound1->ts.type != BT_INTEGER || bound2->ts.type != BT_INTEGER) gfc_internal_error ("gfc_compare_array_spec(): Array spec clobbered"); - if (mpz_cmp (bound1->value.integer, bound2->value.integer) == 0) - return 1; - else - return 0; + /* What qualifies as identical bounds? We could probably just check that the + expressions are exact clones. We avoid rewriting a specific comparison + function and re-use instead the rather involved gfc_dep_compare_expr which + is just a bit more permissive, as it can also detect identical values for + some mismatching expressions (extra parenthesis, swapped operands, unary + plus, etc). It probably only makes a difference in corner cases. */ + return gfc_dep_compare_expr (bound1, bound2) == 0; } @@ -1006,10 +1011,10 @@ gfc_compare_array_spec (gfc_array_spec *as1, gfc_array_spec *as2) if (as1->type == AS_EXPLICIT) for (i = 0; i < as1->rank + as1->corank; i++) { - if (compare_bounds (as1->lower[i], as2->lower[i]) == 0) + if (!compare_bounds (as1->lower[i], as2->lower[i])) return 0; - if (compare_bounds (as1->upper[i], as2->upper[i]) == 0) + if (!compare_bounds (as1->upper[i], as2->upper[i])) return 0; } -- cgit v1.1 From ba949a6af46993fbd7160a7fea0b8f8ab11bc7bd Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 28 Apr 2022 00:16:52 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8c66dff..9b6e55a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,19 @@ +2022-04-27 Mikael Morin + + PR fortran/103662 + PR fortran/105379 + * array.cc (compare_bounds): Use bool as return type. + Support non-constant expressions. + (gfc_compare_array_spec): Update call to compare_bounds. + +2022-04-27 Mikael Morin + + PR fortran/102043 + PR fortran/105381 + * trans-array.cc (non_negative_strides_array_p): Inline variable + orig_decl and merge nested if conditions. Add condition to not + recurse if the next argument is the same as the current. + 2022-04-25 Jakub Jelinek Thomas Schwinge -- cgit v1.1 From 1a5ae012ff3303a8232a03ac9a0925c709775076 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Thu, 28 Apr 2022 18:23:16 +0200 Subject: Document changes to CONVERT for -mabi-ieeelongdouble for POWER. gcc/fortran/ChangeLog: * gfortran.texi: Mention r16_ieee and r16_ibm. * invoke.texi: Likewise. --- gcc/fortran/gfortran.texi | 30 +++++++++++++++++++++++++----- gcc/fortran/invoke.texi | 18 ++++++++++++++---- 2 files changed, 39 insertions(+), 9 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index f8737f4..6f622fb 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -589,7 +589,7 @@ Malformed environment variables are silently ignored. * GFORTRAN_SHOW_LOCUS:: Show location for runtime errors * GFORTRAN_OPTIONAL_PLUS:: Print leading + where permitted * GFORTRAN_LIST_SEPARATOR:: Separator for list output -* GFORTRAN_CONVERT_UNIT:: Set endianness for unformatted I/O +* GFORTRAN_CONVERT_UNIT:: Set conversion for unformatted I/O * GFORTRAN_ERROR_BACKTRACE:: Show backtrace on run-time errors * GFORTRAN_FORMATTED_BUFFER_SIZE:: Buffer size for formatted files * GFORTRAN_UNFORMATTED_BUFFER_SIZE:: Buffer size for unformatted files @@ -686,11 +686,12 @@ when @command{a.out} is the compiled Fortran program that you want to run. Default is a single space. @node GFORTRAN_CONVERT_UNIT -@section @env{GFORTRAN_CONVERT_UNIT}---Set endianness for unformatted I/O +@section @env{GFORTRAN_CONVERT_UNIT}---Set conversion for unformatted I/O By setting the @env{GFORTRAN_CONVERT_UNIT} variable, it is possible to change the representation of data for unformatted files. -The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable is: +The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable for +most systems is: @smallexample GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ; mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ; @@ -711,14 +712,24 @@ the modes are the same as for the @code{CONVERT} specifier: for unformatted files. @item @code{BIG_ENDIAN} Use the big-endian format for unformatted files. @end itemize +For POWER systems which support @option{-mabi=ieeelongdouble}, +there are additional options, which can be combined with the +others with commas. Those are +@itemize @w{} +@item @code{R16_IEEE} Use IEEE 128-bit format for @code{REAL(KIND=16)}. +@item @code{R16_IBM} Use IBM @code{long double} format for +@code{REAL(KIND=16)}. +@end itemize A missing mode for an exception is taken to mean @code{BIG_ENDIAN}. Examples of values for @env{GFORTRAN_CONVERT_UNIT} are: @itemize @w{} -@item @code{'big_endian'} Do all unformatted I/O in big_endian mode. +@item @code{'big_endian'} Do all unformatted I/O in big_endian mod.e @item @code{'little_endian;native:10-20,25'} Do all unformatted I/O in little_endian mode, except for units 10 to 20 and 25, which are in native format. @item @code{'10-20'} Units 10 to 20 are big-endian, the rest is native. +@item @code{'big_endian,r16_ibm'} Do all unformatted I/O in big-endian +mode and use IBM long double for output of @code{REAL(KIND=16)} values. @end itemize Setting the environment variables should be done on the command @@ -1736,7 +1747,7 @@ the @code{CONVERT} specifier on the @code{OPEN} statement. @xref{GFORTRAN_CONVERT_UNIT}, for an alternative way of specifying the data format via an environment variable. -Valid values for @code{CONVERT} are: +Valid values for @code{CONVERT} on most systems are: @itemize @w{} @item @code{CONVERT='NATIVE'} Use the native format. This is the default. @item @code{CONVERT='SWAP'} Swap between little- and big-endian. @@ -1745,6 +1756,15 @@ for unformatted files. @item @code{CONVERT='BIG_ENDIAN'} Use the big-endian representation for unformatted files. @end itemize +On POWER systems which support @option{-mabi=ieeelongdouble}, +there are additional options, which can be combined with the others +with commas. Those are +@itemize @w{} +@item @code{CONVERT='R16_IEEE'} Use IEEE 128-bit format for +@code{REAL(KIND=16)}. +@item @code{CONVERT='R16_IBM'} Use IBM @code{long double} format for +real@code{REAL(KIND=16)}. +@end itemize Using the option could look like this: @smallexample diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 5c7501a..c0932f6 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -1435,10 +1435,20 @@ These options affect the runtime behavior of programs compiled with GNU Fortran. @item -fconvert=@var{conversion} @opindex @code{fconvert=}@var{conversion} Specify the representation of data for unformatted files. Valid -values for conversion are: @samp{native}, the default; @samp{swap}, -swap between big- and little-endian; @samp{big-endian}, use big-endian -representation for unformatted files; @samp{little-endian}, use little-endian -representation for unformatted files. +values for conversion on most systems are: @samp{native}, the default; +@samp{swap}, swap between big- and little-endian; @samp{big-endian}, use +big-endian representation for unformatted files; @samp{little-endian}, use +little-endian representation for unformatted files. + +On POWER systems which suppport @option{-mabi=ieeelongdouble}, +there are additional options, which can be combined with others with +commas. Those are +@itemize @w{} +@item @option{-fconvert=r16_ieee} Use IEEE 128-bit format for +@code{REAL(KIND=16)}. +@item @option{-fconvert=r16_ibm} Use IBM long double format for +@code{REAL(KIND=16)}. +@end itemize @emph{This option has an effect only when used in the main program. The @code{CONVERT} specifier and the GFORTRAN_CONVERT_UNIT environment -- cgit v1.1 From 6b6f53d8afdb3744530a93e1f8dc00de69052493 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 29 Apr 2022 00:16:26 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9b6e55a..017f3e6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-04-28 Thomas Koenig + + * gfortran.texi: Mention r16_ieee and r16_ibm. + * invoke.texi: Likewise. + 2022-04-27 Mikael Morin PR fortran/103662 -- cgit v1.1 From 4a8b45e8bc8246bd141dad65f571a3e0cc499c6b Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Fri, 29 Apr 2022 19:57:05 +0200 Subject: Fix exchanged period and letter in gfortan.texi. gcc/fortran/ChangeLog: * gfortran.texi: Fix exchanged period and letter. --- gcc/fortran/gfortran.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 6f622fb..d34e0b5 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -723,7 +723,7 @@ others with commas. Those are A missing mode for an exception is taken to mean @code{BIG_ENDIAN}. Examples of values for @env{GFORTRAN_CONVERT_UNIT} are: @itemize @w{} -@item @code{'big_endian'} Do all unformatted I/O in big_endian mod.e +@item @code{'big_endian'} Do all unformatted I/O in big_endian mode. @item @code{'little_endian;native:10-20,25'} Do all unformatted I/O in little_endian mode, except for units 10 to 20 and 25, which are in native format. -- cgit v1.1 From 66d1e440e14377a373d0e3d67f478cca4fd14dea Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 30 Apr 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 017f3e6..fa58d47 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2022-04-29 Thomas Koenig + + * gfortran.texi: Fix exchanged period and letter. + 2022-04-28 Thomas Koenig * gfortran.texi: Mention r16_ieee and r16_ibm. -- cgit v1.1 From 198bd0d599e0a91df1cfa6ab37545d05dff48e97 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Thu, 24 Mar 2022 21:02:34 -0700 Subject: Fortran: Add location info to OpenMP tree nodes gcc/fortran/ * trans-openmp.cc (gfc_trans_omp_critical): Set location on OMP tree node. (gfc_trans_omp_do): Likewise. (gfc_trans_omp_masked): Likewise. (gfc_trans_omp_do_simd): Likewise. (gfc_trans_omp_scope): Likewise. (gfc_trans_omp_taskgroup): Likewise. (gfc_trans_omp_taskwait): Likewise. (gfc_trans_omp_distribute): Likewise. (gfc_trans_omp_taskloop): Likewise. (gfc_trans_omp_master_masked_taskloop): Likewise. --- gcc/fortran/trans-openmp.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 43d59ab..7f3ac97 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -5014,6 +5014,7 @@ gfc_trans_omp_critical (gfc_code *code) name = get_identifier (code->ext.omp_clauses->critical_name); gfc_start_block (&block); stmt = make_node (OMP_CRITICAL); + SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_CRITICAL_BODY (stmt) = gfc_trans_code (code->block->next); OMP_CRITICAL_NAME (stmt) = name; @@ -5046,6 +5047,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, unsigned ix; vec *saved_doacross_steps = doacross_steps; gfc_expr_list *tile = do_clauses ? do_clauses->tile_list : clauses->tile_list; + gfc_code *orig_code = code; /* Both collapsed and tiled loops are lowered the same way. In OpenACC, those clauses are not compatible, so prioritize the tile @@ -5400,6 +5402,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, default: gcc_unreachable (); } + SET_EXPR_LOCATION (stmt, gfc_get_location (&orig_code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_FOR_BODY (stmt) = gfc_finish_block (&body); OMP_FOR_CLAUSES (stmt) = omp_clauses; @@ -5672,6 +5675,7 @@ gfc_trans_omp_masked (gfc_code *code, gfc_omp_clauses *clauses) gfc_start_block (&block); tree omp_clauses = gfc_trans_omp_clauses (&block, clauses, code->loc); tree stmt = make_node (OMP_MASKED); + SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_MASKED_BODY (stmt) = body; OMP_MASKED_CLAUSES (stmt) = omp_clauses; @@ -6446,6 +6450,7 @@ gfc_trans_omp_do_simd (gfc_code *code, stmtblock_t *pblock, if (flag_openmp) { stmt = make_node (OMP_FOR); + SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_FOR_BODY (stmt) = body; OMP_FOR_CLAUSES (stmt) = omp_do_clauses; @@ -6618,6 +6623,7 @@ gfc_trans_omp_scope (gfc_code *code) tree omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses, code->loc); tree stmt = make_node (OMP_SCOPE); + SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_SCOPE_BODY (stmt) = body; OMP_SCOPE_CLAUSES (stmt) = omp_clauses; @@ -6693,6 +6699,7 @@ gfc_trans_omp_taskgroup (gfc_code *code) gfc_start_block (&block); tree body = gfc_trans_code (code->block->next); tree stmt = make_node (OMP_TASKGROUP); + SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_TASKGROUP_BODY (stmt) = body; OMP_TASKGROUP_CLAUSES (stmt) = gfc_trans_omp_clauses (&block, @@ -6713,6 +6720,7 @@ gfc_trans_omp_taskwait (gfc_code *code) stmtblock_t block; gfc_start_block (&block); tree stmt = make_node (OMP_TASK); + SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc)); TREE_TYPE (stmt) = void_type_node; OMP_TASK_BODY (stmt) = NULL_TREE; OMP_TASK_CLAUSES (stmt) = gfc_trans_omp_clauses (&block, @@ -6790,6 +6798,7 @@ gfc_trans_omp_distribute (gfc_code *code, gfc_omp_clauses *clausesa) if (flag_openmp) { tree distribute = make_node (OMP_DISTRIBUTE); + SET_EXPR_LOCATION (distribute, gfc_get_location (&code->loc)); TREE_TYPE (distribute) = void_type_node; OMP_FOR_BODY (distribute) = stmt; OMP_FOR_CLAUSES (distribute) = omp_clauses; @@ -7010,6 +7019,7 @@ gfc_trans_omp_taskloop (gfc_code *code, gfc_exec_op op) if (flag_openmp) { tree taskloop = make_node (OMP_TASKLOOP); + SET_EXPR_LOCATION (taskloop, gfc_get_location (&code->loc)); TREE_TYPE (taskloop) = void_type_node; OMP_FOR_BODY (taskloop) = stmt; OMP_FOR_CLAUSES (taskloop) = omp_clauses; @@ -7055,6 +7065,7 @@ gfc_trans_omp_master_masked_taskloop (gfc_code *code, gfc_exec_op op) &clausesa[GFC_OMP_SPLIT_MASKED], code->loc); tree msk = make_node (OMP_MASKED); + SET_EXPR_LOCATION (msk, gfc_get_location (&code->loc)); TREE_TYPE (msk) = void_type_node; OMP_MASKED_BODY (msk) = stmt; OMP_MASKED_CLAUSES (msk) = clauses; -- cgit v1.1 From 6259d8aa73f6c4742c1aa22cccc325701307b3af Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 3 May 2022 00:16:25 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fa58d47..fbae4f0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,17 @@ +2022-05-02 Sandra Loosemore + + * trans-openmp.cc (gfc_trans_omp_critical): Set location on OMP + tree node. + (gfc_trans_omp_do): Likewise. + (gfc_trans_omp_masked): Likewise. + (gfc_trans_omp_do_simd): Likewise. + (gfc_trans_omp_scope): Likewise. + (gfc_trans_omp_taskgroup): Likewise. + (gfc_trans_omp_taskwait): Likewise. + (gfc_trans_omp_distribute): Likewise. + (gfc_trans_omp_taskloop): Likewise. + (gfc_trans_omp_master_masked_taskloop): Likewise. + 2022-04-29 Thomas Koenig * gfortran.texi: Fix exchanged period and letter. -- cgit v1.1 From 705bcedf6eae2d7c68bd3df2c98dad4f06650fde Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Thu, 5 May 2022 11:37:16 -0700 Subject: Fortran: Add support for OMP non-rectangular loops. This patch adds support for OMP 5.1 "canonical loop nest form" to the Fortran front end, marks non-rectangular loops for processing by the middle end, and implements missing checks in the gimplifier for additional prohibitions on non-rectangular loops. Note that the OMP spec also prohibits non-rectangular loops with the TILE construct; that construct hasn't been implemented yet, so that error will need to be filled in later. gcc/fortran/ * gfortran.h (struct gfc_omp_clauses): Add non_rectangular bit. * openmp.cc (is_outer_iteration_variable): New function. (expr_is_invariant): New function. (bound_expr_is_canonical): New function. (resolve_omp_do): Replace existing non-rectangularity error with check for canonical form and setting non_rectangular bit. * trans-openmp.cc (gfc_trans_omp_do): Transfer non_rectangular flag to generated tree structure. gcc/ * gimplify.cc (gimplify_omp_for): Update messages for SCHEDULED and ORDERED clause conflict errors. Add check for GRAINSIZE and NUM_TASKS on TASKLOOP. gcc/testsuite/ * c-c++-common/gomp/loop-6.c (f3): New function to test TASKLOOP diagnostics. * gfortran.dg/gomp/collapse1.f90: Update expected messages. * gfortran.dg/gomp/pr85313.f90: Remove dg-error on non-rectangular loops that are now accepted. * gfortran.dg/gomp/non-rectangular-loop.f90: New file. * gfortran.dg/gomp/canonical-loop-1.f90: New file. * gfortran.dg/gomp/canonical-loop-2.f90: New file. --- gcc/fortran/gfortran.h | 1 + gcc/fortran/openmp.cc | 159 +++++++++++++++++++++++++++++++++++++++----- gcc/fortran/trans-openmp.cc | 1 + 3 files changed, 143 insertions(+), 18 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 7bf1d5a..1bce283 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1533,6 +1533,7 @@ typedef struct gfc_omp_clauses unsigned simd:1, threads:1, depend_source:1, destroy:1, order_concurrent:1; unsigned order_unconstrained:1, order_reproducible:1, capture:1; unsigned grainsize_strict:1, num_tasks_strict:1, compare:1, weak:1; + unsigned non_rectangular:1; ENUM_BITFIELD (gfc_omp_sched_kind) sched_kind:3; ENUM_BITFIELD (gfc_omp_device_type) device_type:2; ENUM_BITFIELD (gfc_omp_memorder) memorder:3; diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 7141481..4d3fcc8 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -8446,6 +8446,105 @@ gfc_resolve_omp_local_vars (gfc_namespace *ns) gfc_traverse_ns (ns, handle_local_var); } +/* CODE is an OMP loop construct. Return true if VAR matches an iteration + variable outer to level DEPTH. */ +static bool +is_outer_iteration_variable (gfc_code *code, int depth, gfc_symbol *var) +{ + int i; + gfc_code *do_code = code->block->next; + + for (i = 1; i < depth; i++) + { + gfc_symbol *ivar = do_code->ext.iterator->var->symtree->n.sym; + if (var == ivar) + return true; + do_code = do_code->block->next; + } + return false; +} + +/* CODE is an OMP loop construct. Return true if EXPR does not reference + any iteration variables outer to level DEPTH. */ +static bool +expr_is_invariant (gfc_code *code, int depth, gfc_expr *expr) +{ + int i; + gfc_code *do_code = code->block->next; + + for (i = 1; i < depth; i++) + { + gfc_symbol *ivar = do_code->ext.iterator->var->symtree->n.sym; + if (gfc_find_sym_in_expr (ivar, expr)) + return false; + do_code = do_code->block->next; + } + return true; +} + +/* CODE is an OMP loop construct. Return true if EXPR matches one of the + canonical forms for a bound expression. It may include references to + an iteration variable outer to level DEPTH; set OUTER_VARP if so. */ +static bool +bound_expr_is_canonical (gfc_code *code, int depth, gfc_expr *expr, + gfc_symbol **outer_varp) +{ + gfc_expr *expr2 = NULL; + + /* Rectangular case. */ + if (depth == 0 || expr_is_invariant (code, depth, expr)) + return true; + + /* Any simple variable that didn't pass expr_is_invariant must be + an outer_var. */ + if (expr->expr_type == EXPR_VARIABLE && expr->rank == 0) + { + *outer_varp = expr->symtree->n.sym; + return true; + } + + /* All other permitted forms are binary operators. */ + if (expr->expr_type != EXPR_OP) + return false; + + /* Check for plus/minus a loop invariant expr. */ + if (expr->value.op.op == INTRINSIC_PLUS + || expr->value.op.op == INTRINSIC_MINUS) + { + if (expr_is_invariant (code, depth, expr->value.op.op1)) + expr2 = expr->value.op.op2; + else if (expr_is_invariant (code, depth, expr->value.op.op2)) + expr2 = expr->value.op.op1; + else + return false; + } + else + expr2 = expr; + + /* Check for a product with a loop-invariant expr. */ + if (expr2->expr_type == EXPR_OP + && expr2->value.op.op == INTRINSIC_TIMES) + { + if (expr_is_invariant (code, depth, expr2->value.op.op1)) + expr2 = expr2->value.op.op2; + else if (expr_is_invariant (code, depth, expr2->value.op.op2)) + expr2 = expr2->value.op.op1; + else + return false; + } + + /* What's left must be a reference to an outer loop variable. */ + if (expr2->expr_type == EXPR_VARIABLE + && expr2->rank == 0 + && is_outer_iteration_variable (code, depth, expr2->symtree->n.sym)) + { + *outer_varp = expr2->symtree->n.sym; + return true; + } + + return false; +} + static void resolve_omp_do (gfc_code *code) { @@ -8564,8 +8663,15 @@ resolve_omp_do (gfc_code *code) if (collapse <= 0) collapse = 1; } + + /* While the spec defines the loop nest depth independently of the COLLAPSE + clause, in practice the middle end only pays attention to the COLLAPSE + depth and treats any further inner loops as the final-loop-body. So + here we also check canonical loop nest form only for the number of + outer loops specified by the COLLAPSE clause too. */ for (i = 1; i <= collapse; i++) { + gfc_symbol *start_var = NULL, *end_var = NULL; if (do_code->op == EXEC_DO_WHILE) { gfc_error ("%s cannot be a DO WHILE or DO without loop control " @@ -8606,26 +8712,43 @@ resolve_omp_do (gfc_code *code) "LINEAR at %L", name, &do_code->loc); break; } - if (i > 1) + if (is_outer_iteration_variable (code, i, dovar)) { - gfc_code *do_code2 = code->block->next; - int j; - - for (j = 1; j < i; j++) - { - gfc_symbol *ivar = do_code2->ext.iterator->var->symtree->n.sym; - if (dovar == ivar - || gfc_find_sym_in_expr (ivar, do_code->ext.iterator->start) - || gfc_find_sym_in_expr (ivar, do_code->ext.iterator->end) - || gfc_find_sym_in_expr (ivar, do_code->ext.iterator->step)) - { - gfc_error ("%s collapsed loops don't form rectangular " - "iteration space at %L", name, &do_code->loc); - break; - } - do_code2 = do_code2->block->next; - } + gfc_error ("%s iteration variable used in more than one loop at %L", + name, &do_code->loc); + break; } + else if (!bound_expr_is_canonical (code, i, + do_code->ext.iterator->start, + &start_var)) + { + gfc_error ("%s loop start expression not in canonical form at %L", + name, &do_code->loc); + break; + } + else if (!bound_expr_is_canonical (code, i, + do_code->ext.iterator->end, + &end_var)) + { + gfc_error ("%s loop end expression not in canonical form at %L", + name, &do_code->loc); + break; + } + else if (start_var && end_var && start_var != end_var) + { + gfc_error ("%s loop bounds reference different " + "iteration variables at %L", name, &do_code->loc); + break; + } + else if (!expr_is_invariant (code, i, do_code->ext.iterator->step)) + { + gfc_error ("%s loop increment not in canonical form at %L", + name, &do_code->loc); + break; + } + if (start_var || end_var) + code->ext.omp_clauses->non_rectangular = 1; + for (c = do_code->next; c; c = c->next) if (c->op != EXEC_NOP && c->op != EXEC_CONTINUE) { diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 7f3ac97..baa45f7 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -5411,6 +5411,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, OMP_FOR_INCR (stmt) = incr; if (orig_decls) OMP_FOR_ORIG_DECLS (stmt) = orig_decls; + OMP_FOR_NON_RECTANGULAR (stmt) = clauses->non_rectangular; gfc_add_expr_to_block (&block, stmt); vec_free (doacross_steps); -- cgit v1.1 From ab869e7f7548537a16b57658fb0826f92b3d2af6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 6 May 2022 00:16:26 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fbae4f0..e084d98 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2022-05-05 Sandra Loosemore + + * gfortran.h (struct gfc_omp_clauses): Add non_rectangular bit. + * openmp.cc (is_outer_iteration_variable): New function. + (expr_is_invariant): New function. + (bound_expr_is_canonical): New function. + (resolve_omp_do): Replace existing non-rectangularity error with + check for canonical form and setting non_rectangular bit. + * trans-openmp.cc (gfc_trans_omp_do): Transfer non_rectangular + flag to generated tree structure. + 2022-05-02 Sandra Loosemore * trans-openmp.cc (gfc_trans_omp_critical): Set location on OMP -- cgit v1.1 From 8c97f7fd2382aa77f36567207e949447db90a1fb Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 8 May 2022 22:04:27 +0200 Subject: Fortran: check for non-optional spaces between adjacent keywords In free format, spaces between adjacent keywords are not optional except when a combination is explicitly listed (e.g. F2018: table 6.2). The following combinations thus require separating blanks: CHANGE TEAM, ERROR STOP, EVENT POST, EVENT WAIT, FAIL IMAGE, FORM TEAM, SELECT RANK, SYNC ALL, SYNC IMAGES, SYNC MEMORY, SYNC TEAM, TYPE IS. gcc/fortran/ChangeLog: PR fortran/105501 * match.cc (gfc_match_if): Adjust patterns used for matching. (gfc_match_select_rank): Likewise. * parse.cc (decode_statement): Likewise. gcc/testsuite/ChangeLog: PR fortran/105501 * gfortran.dg/pr105501.f90: New test. --- gcc/fortran/match.cc | 22 +++++++++++----------- gcc/fortran/parse.cc | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 205811b..1aa3053 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -1606,21 +1606,21 @@ gfc_match_if (gfc_statement *if_type) match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT) match ("backspace", gfc_match_backspace, ST_BACKSPACE) match ("call", gfc_match_call, ST_CALL) - match ("change team", gfc_match_change_team, ST_CHANGE_TEAM) + match ("change% team", gfc_match_change_team, ST_CHANGE_TEAM) match ("close", gfc_match_close, ST_CLOSE) match ("continue", gfc_match_continue, ST_CONTINUE) match ("cycle", gfc_match_cycle, ST_CYCLE) match ("deallocate", gfc_match_deallocate, ST_DEALLOCATE) match ("end file", gfc_match_endfile, ST_END_FILE) match ("end team", gfc_match_end_team, ST_END_TEAM) - match ("error stop", gfc_match_error_stop, ST_ERROR_STOP) - match ("event post", gfc_match_event_post, ST_EVENT_POST) - match ("event wait", gfc_match_event_wait, ST_EVENT_WAIT) + match ("error% stop", gfc_match_error_stop, ST_ERROR_STOP) + match ("event% post", gfc_match_event_post, ST_EVENT_POST) + match ("event% wait", gfc_match_event_wait, ST_EVENT_WAIT) match ("exit", gfc_match_exit, ST_EXIT) - match ("fail image", gfc_match_fail_image, ST_FAIL_IMAGE) + match ("fail% image", gfc_match_fail_image, ST_FAIL_IMAGE) match ("flush", gfc_match_flush, ST_FLUSH) match ("forall", match_simple_forall, ST_FORALL) - match ("form team", gfc_match_form_team, ST_FORM_TEAM) + match ("form% team", gfc_match_form_team, ST_FORM_TEAM) match ("go to", gfc_match_goto, ST_GOTO) match ("if", match_arithmetic_if, ST_ARITHMETIC_IF) match ("inquire", gfc_match_inquire, ST_INQUIRE) @@ -1634,10 +1634,10 @@ gfc_match_if (gfc_statement *if_type) match ("rewind", gfc_match_rewind, ST_REWIND) match ("stop", gfc_match_stop, ST_STOP) match ("wait", gfc_match_wait, ST_WAIT) - match ("sync all", gfc_match_sync_all, ST_SYNC_CALL); - match ("sync images", gfc_match_sync_images, ST_SYNC_IMAGES); - match ("sync memory", gfc_match_sync_memory, ST_SYNC_MEMORY); - match ("sync team", gfc_match_sync_team, ST_SYNC_TEAM) + match ("sync% all", gfc_match_sync_all, ST_SYNC_CALL); + match ("sync% images", gfc_match_sync_images, ST_SYNC_IMAGES); + match ("sync% memory", gfc_match_sync_memory, ST_SYNC_MEMORY); + match ("sync% team", gfc_match_sync_team, ST_SYNC_TEAM) match ("unlock", gfc_match_unlock, ST_UNLOCK) match ("where", match_simple_where, ST_WHERE) match ("write", gfc_match_write, ST_WRITE) @@ -6716,7 +6716,7 @@ gfc_match_select_rank (void) if (m == MATCH_ERROR) return m; - m = gfc_match (" select rank ( "); + m = gfc_match (" select% rank ( "); if (m != MATCH_YES) return m; diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index e6e915d..7356d1b 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -454,7 +454,7 @@ decode_statement (void) case 'c': match ("call", gfc_match_call, ST_CALL); - match ("change team", gfc_match_change_team, ST_CHANGE_TEAM); + match ("change% team", gfc_match_change_team, ST_CHANGE_TEAM); match ("close", gfc_match_close, ST_CLOSE); match ("continue", gfc_match_continue, ST_CONTINUE); match ("contiguous", gfc_match_contiguous, ST_ATTR_DECL); @@ -479,7 +479,7 @@ decode_statement (void) match ("else", gfc_match_else, ST_ELSE); match ("else where", gfc_match_elsewhere, ST_ELSEWHERE); match ("else if", gfc_match_elseif, ST_ELSEIF); - match ("error stop", gfc_match_error_stop, ST_ERROR_STOP); + match ("error% stop", gfc_match_error_stop, ST_ERROR_STOP); match ("enum , bind ( c )", gfc_match_enum, ST_ENUM); if (gfc_match_end (&st) == MATCH_YES) @@ -488,15 +488,15 @@ decode_statement (void) match ("entry% ", gfc_match_entry, ST_ENTRY); match ("equivalence", gfc_match_equivalence, ST_EQUIVALENCE); match ("external", gfc_match_external, ST_ATTR_DECL); - match ("event post", gfc_match_event_post, ST_EVENT_POST); - match ("event wait", gfc_match_event_wait, ST_EVENT_WAIT); + match ("event% post", gfc_match_event_post, ST_EVENT_POST); + match ("event% wait", gfc_match_event_wait, ST_EVENT_WAIT); break; case 'f': - match ("fail image", gfc_match_fail_image, ST_FAIL_IMAGE); + match ("fail% image", gfc_match_fail_image, ST_FAIL_IMAGE); match ("final", gfc_match_final_decl, ST_FINAL); match ("flush", gfc_match_flush, ST_FLUSH); - match ("form team", gfc_match_form_team, ST_FORM_TEAM); + match ("form% team", gfc_match_form_team, ST_FORM_TEAM); match ("format", gfc_match_format, ST_FORMAT); break; @@ -562,16 +562,16 @@ decode_statement (void) match ("save", gfc_match_save, ST_ATTR_DECL); match ("static", gfc_match_static, ST_ATTR_DECL); match ("submodule", gfc_match_submodule, ST_SUBMODULE); - match ("sync all", gfc_match_sync_all, ST_SYNC_ALL); - match ("sync images", gfc_match_sync_images, ST_SYNC_IMAGES); - match ("sync memory", gfc_match_sync_memory, ST_SYNC_MEMORY); - match ("sync team", gfc_match_sync_team, ST_SYNC_TEAM); + match ("sync% all", gfc_match_sync_all, ST_SYNC_ALL); + match ("sync% images", gfc_match_sync_images, ST_SYNC_IMAGES); + match ("sync% memory", gfc_match_sync_memory, ST_SYNC_MEMORY); + match ("sync% team", gfc_match_sync_team, ST_SYNC_TEAM); break; case 't': match ("target", gfc_match_target, ST_ATTR_DECL); match ("type", gfc_match_derived_decl, ST_DERIVED_DECL); - match ("type is", gfc_match_type_is, ST_TYPE_IS); + match ("type% is", gfc_match_type_is, ST_TYPE_IS); break; case 'u': -- cgit v1.1 From bd022ff9752262a70f44b57808447f823392989e Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 10 May 2022 00:17:14 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e084d98..4f63845 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-05-09 Harald Anlauf + + PR fortran/105501 + * match.cc (gfc_match_if): Adjust patterns used for matching. + (gfc_match_select_rank): Likewise. + * parse.cc (decode_statement): Likewise. + 2022-05-05 Sandra Loosemore * gfortran.h (struct gfc_omp_clauses): Add non_rectangular bit. -- cgit v1.1 From 5edd0802696f94012731306c704eaf61d184e09c Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 9 May 2022 22:14:21 +0200 Subject: Fortran: check TEAM arguments to coarray intrinsics TEAM arguments to coarray intrinsics must be scalar expressions of type TEAM_TYPE of intrinsic module ISO_FORTRAN_ENV. gcc/fortran/ChangeLog: PR fortran/105526 * resolve.cc (check_team): New. (gfc_resolve_code): Add checks for arguments to coarray intrinsics FORM TEAM, CHANGE TEAM, and SYNC TEAM. gcc/testsuite/ChangeLog: PR fortran/105526 * gfortran.dg/coarray_50.f90: New test. --- gcc/fortran/resolve.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 29df531..c8335f9 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -11831,6 +11831,23 @@ deferred_op_assign (gfc_code **code, gfc_namespace *ns) } +static bool +check_team (gfc_expr *team, const char *intrinsic) +{ + if (team->rank != 0 + || team->ts.type != BT_DERIVED + || team->ts.u.derived->from_intmod != INTMOD_ISO_FORTRAN_ENV + || team->ts.u.derived->intmod_sym_id != ISOFORTRAN_TEAM_TYPE) + { + gfc_error ("TEAM argument to %qs at %L must be a scalar expression " + "of type TEAM_TYPE", intrinsic, &team->where); + return false; + } + + return true; +} + + /* Given a block of code, recursively resolve everything pointed to by this code block. */ @@ -11999,10 +12016,25 @@ start: break; case EXEC_FAIL_IMAGE: + break; + case EXEC_FORM_TEAM: + if (code->expr1 != NULL + && (code->expr1->ts.type != BT_INTEGER || code->expr1->rank)) + gfc_error ("TEAM NUMBER argument to FORM TEAM at %L must be " + "a scalar INTEGER", &code->expr1->where); + check_team (code->expr2, "FORM TEAM"); + break; + case EXEC_CHANGE_TEAM: + check_team (code->expr1, "CHANGE TEAM"); + break; + case EXEC_END_TEAM: + break; + case EXEC_SYNC_TEAM: + check_team (code->expr1, "SYNC TEAM"); break; case EXEC_ENTRY: -- cgit v1.1 From e877898911574037af5aaa68ff6451ec5ced20e9 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 11 May 2022 00:16:40 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4f63845..828f74d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-05-10 Harald Anlauf + + PR fortran/105526 + * resolve.cc (check_team): New. + (gfc_resolve_code): Add checks for arguments to coarray intrinsics + FORM TEAM, CHANGE TEAM, and SYNC TEAM. + 2022-05-09 Harald Anlauf PR fortran/105501 -- cgit v1.1 From 0acdbe29f66017fc5cca40dcbd72a0dd41491d07 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 10 May 2022 23:41:57 +0200 Subject: Fortran: fix error recovery on invalid array section gcc/fortran/ChangeLog: PR fortran/105230 * expr.cc (find_array_section): Correct logic to avoid NULL pointer dereference on invalid array section. gcc/testsuite/ChangeLog: PR fortran/105230 * gfortran.dg/pr105230.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/expr.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 86d61fe..be94c18 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1595,8 +1595,8 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) if ((begin && begin->expr_type != EXPR_CONSTANT) || (finish && finish->expr_type != EXPR_CONSTANT) || (step && step->expr_type != EXPR_CONSTANT) - || (!begin && !lower) - || (!finish && !upper)) + || !lower + || !upper) { t = false; goto cleanup; -- cgit v1.1 From d0d513b5eae70f26c664fa81c2f56e907b66aeff Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 12 May 2022 00:16:36 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 828f74d..395fad9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-05-11 Harald Anlauf + Steven G. Kargl + + PR fortran/105230 + * expr.cc (find_array_section): Correct logic to avoid NULL + pointer dereference on invalid array section. + 2022-05-10 Harald Anlauf PR fortran/105526 -- cgit v1.1 From a46d6268371c446566f656858aada8775a0c988e Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 13 May 2022 20:00:34 +0200 Subject: OpenMP/Fortran: Use firstprivat not alloc for ptr attach for arrays For a non-descriptor array, map(A(n:m)) was mapped as map(tofrom:A[n-1] [len: ...]) map(alloc:A [pointer assign, bias: ...]) with this patch, it is changed to map(tofrom:A[n-1] [len: ...]) map(firstprivate:A [pointer assign, bias: ...]) The latter avoids an alloc - and also avoids the race condition with nowait in the enclosed testcase. (Note: predantically, the testcase is invalid since OpenMP 5.1, violating the map clause restriction at [354:10-13]. gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_trans_omp_clauses): When mapping nondescriptor array sections, use GOMP_MAP_FIRSTPRIVATE_POINTER instead of GOMP_MAP_POINTER for the pointer attachment. libgomp/ChangeLog: * testsuite/libgomp.fortran/target-nowait-array-section.f90: New test. --- gcc/fortran/trans-openmp.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index baa45f7..eb5870c 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -3312,9 +3312,15 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, /* An array element or array section which is not part of a derived type, etc. */ bool element = n->expr->ref->u.ar.type == AR_ELEMENT; - gfc_trans_omp_array_section (block, n, decl, element, - GOMP_MAP_POINTER, node, node2, - node3, node4); + tree type = TREE_TYPE (decl); + gomp_map_kind k = GOMP_MAP_POINTER; + if (!openacc + && !GFC_DESCRIPTOR_TYPE_P (type) + && !(POINTER_TYPE_P (type) + && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (type)))) + k = GOMP_MAP_FIRSTPRIVATE_POINTER; + gfc_trans_omp_array_section (block, n, decl, element, k, + node, node2, node3, node4); } else if (n->expr && n->expr->expr_type == EXPR_VARIABLE -- cgit v1.1 From 9df4ffe493a4616b276c66e73df3b2e929db023b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 14 May 2022 00:17:19 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 395fad9..b4f2ff8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-05-13 Tobias Burnus + + * trans-openmp.cc (gfc_trans_omp_clauses): When mapping nondescriptor + array sections, use GOMP_MAP_FIRSTPRIVATE_POINTER instead of + GOMP_MAP_POINTER for the pointer attachment. + 2022-05-11 Harald Anlauf Steven G. Kargl -- cgit v1.1 From ca32b29ec3e92dcf8dda5c2501d0baf9dd1cb09d Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 13 Jan 2022 18:46:26 +0100 Subject: Use more ARRAY_SIZE. gcc/ada/ChangeLog: * locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE. (language_name_to_639_3): Likewise. (country_name_to_3166): Likewise. gcc/analyzer/ChangeLog: * engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE. * function-set.cc (test_stdio_example): Likewise. * sm-file.cc (get_file_using_fns): Likewise. * sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise. * sm-signal.cc (get_async_signal_unsafe_fns): Likewise. gcc/ChangeLog: * attribs.cc (diag_attr_exclusions): Use ARRAY_SIZE. (decls_mismatched_attributes): Likewise. * builtins.cc (c_strlen): Likewise. * cfg.cc (DEF_BASIC_BLOCK_FLAG): Likewise. * common/config/aarch64/aarch64-common.cc (aarch64_option_init_struct): Likewise. * config/aarch64/aarch64-builtins.cc (aarch64_lookup_simd_builtin_type): Likewise. (aarch64_init_simd_builtin_types): Likewise. (aarch64_init_builtin_rsqrt): Likewise. * config/aarch64/aarch64.cc (is_madd_op): Likewise. * config/arm/arm-builtins.cc (arm_lookup_simd_builtin_type): Likewise. (arm_init_simd_builtin_types): Likewise. * config/avr/gen-avr-mmcu-texi.cc (mcus[ARRAY_SIZE): Likewise. (c_prefix): Likewise. (main): Likewise. * config/c6x/c6x.cc (N_SAVE_ORDER): Likewise. * config/darwin-c.cc (darwin_register_frameworks): Likewise. * config/gcn/mkoffload.cc (process_obj): Likewise. * config/i386/i386-builtins.cc (get_builtin_code_for_version): Likewise. (fold_builtin_cpu): Likewise. * config/m32c/m32c.cc (PUSHM_N): Likewise. * config/nvptx/mkoffload.cc (process): Likewise. * config/rs6000/driver-rs6000.cc (host_detect_local_cpu): Likewise. * config/s390/s390.cc (NR_C_MODES): Likewise. * config/tilepro/gen-mul-tables.cc (find_sequences): Likewise. (create_insn_code_compression_table): Likewise. * config/vms/vms.cc (NBR_CRTL_NAMES): Likewise. * diagnostic-format-json.cc (json_from_expanded_location): Likewise. * dwarf2out.cc (ARRAY_SIZE): Likewise. * genhooks.cc (emit_documentation): Likewise. (emit_init_macros): Likewise. * gimple-ssa-sprintf.cc (format_floating): Likewise. * gimple-ssa-warn-access.cc (memmodel_name): Likewise. * godump.cc (keyword_hash_init): Likewise. * hash-table.cc (hash_table_higher_prime_index): Likewise. * input.cc (for_each_line_table_case): Likewise. * ipa-free-lang-data.cc (free_lang_data): Likewise. * ipa-inline.cc (sanitize_attrs_match_for_inline_p): Likewise. * optc-save-gen.awk: Likewise. * spellcheck.cc (test_metric_conditions): Likewise. * tree-vect-slp-patterns.cc (sizeof): Likewise. (ARRAY_SIZE): Likewise. * tree.cc (build_common_tree_nodes): Likewise. gcc/c-family/ChangeLog: * c-common.cc (ARRAY_SIZE): Use ARRAY_SIZE. (c_common_nodes_and_builtins): Likewise. * c-format.cc (check_tokens): Likewise. (check_plain): Likewise. * c-pragma.cc (c_pp_lookup_pragma): Likewise. (init_pragma): Likewise. * known-headers.cc (get_string_macro_hint): Likewise. (get_stdlib_header_for_name): Likewise. * c-attribs.cc: Likewise. gcc/c/ChangeLog: * c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE. gcc/cp/ChangeLog: * module.cc (depset::entity_kind_name): Use ARRAY_SIZE. * name-lookup.cc (get_std_name_hint): Likewise. * parser.cc (cp_parser_new): Likewise. gcc/fortran/ChangeLog: * frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE. * openmp.cc (gfc_match_omp_context_selector_specification): Likewise. * trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise. * trans-types.cc (gfc_get_array_descr_info): Likewise. gcc/jit/ChangeLog: * jit-builtins.cc (find_builtin_by_name): Use ARRAY_SIZE. (get_string_for_type_id): Likewise. * jit-recording.cc (recording::context::context): Likewise. gcc/lto/ChangeLog: * lto-common.cc (lto_resolution_read): Use ARRAY_SIZE. * lto-lang.cc (lto_init): Likewise. --- gcc/fortran/frontend-passes.cc | 4 +--- gcc/fortran/openmp.cc | 3 +-- gcc/fortran/trans-intrinsic.cc | 2 +- gcc/fortran/trans-types.cc | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 5eba634..612c12d 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -5654,9 +5654,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn, WALK_SUBEXPR (co->ext.omp_clauses->detach); for (idx = 0; idx < OMP_IF_LAST; idx++) WALK_SUBEXPR (co->ext.omp_clauses->if_exprs[idx]); - for (idx = 0; - idx < sizeof (list_types) / sizeof (list_types[0]); - idx++) + for (idx = 0; idx < ARRAY_SIZE (list_types); idx++) for (n = co->ext.omp_clauses->lists[list_types[idx]]; n; n = n->next) WALK_SUBEXPR (n->expr); diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 4d3fcc8..8643e43 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -4902,8 +4902,7 @@ gfc_match_omp_context_selector_specification (gfc_omp_declare_variant *odv) match m; const char *selector_sets[] = { "construct", "device", "implementation", "user" }; - const int selector_set_count - = sizeof (selector_sets) / sizeof (*selector_sets); + const int selector_set_count = ARRAY_SIZE (selector_sets); int i; char buf[GFC_MAX_SYMBOL_LEN + 1]; diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index 2249723..6884060 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -9784,7 +9784,7 @@ conv_intrinsic_ieee_builtin (gfc_se * se, gfc_expr * expr, enum built_in_function code, int nargs) { tree args[2]; - gcc_assert ((unsigned) nargs <= sizeof(args)/sizeof(args[0])); + gcc_assert ((unsigned) nargs <= ARRAY_SIZE (args)); conv_ieee_function_args (se, expr, args, nargs); se->expr = build_call_expr_loc_array (input_location, diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 3cdc529..3742bf3 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -3420,7 +3420,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info) } rank = GFC_TYPE_ARRAY_RANK (type); - if (rank >= (int) (sizeof (info->dimen) / sizeof (info->dimen[0]))) + if (rank >= (int) (ARRAY_SIZE (info->dimen))) return false; etype = GFC_TYPE_ARRAY_DATAPTR_TYPE (type); -- cgit v1.1 From 702bd11fa7ddfce0d24581251e979e8a6d7c0d4d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 17 May 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b4f2ff8..09c741e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-05-16 Martin Liska + + * frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE. + * openmp.cc (gfc_match_omp_context_selector_specification): Likewise. + * trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise. + * trans-types.cc (gfc_get_array_descr_info): Likewise. + 2022-05-13 Tobias Burnus * trans-openmp.cc (gfc_trans_omp_clauses): When mapping nondescriptor -- cgit v1.1 From 4f94c38a9237b728b3a3f76c169b5b47f6c45187 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 17 May 2022 11:01:04 +0200 Subject: OpenMP: Add omp_all_memory support to Fortran Fortran part to the C/C++/backend implementation r13-337-g7f78783dbedca0183d193e475262ca3c489fd365 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_namelist): Handle omp_all_memory. * openmp.cc (gfc_match_omp_variable_list, gfc_match_omp_depend_sink, gfc_match_omp_clauses, resolve_omp_clauses): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): Likewise. * resolve.cc (resolve_symbol): Reject it as symbol. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.1): Set omp_all_memory to 'Y'. * testsuite/libgomp.fortran/depend-5.f90: New test. * testsuite/libgomp.fortran/depend-6.f90: New test. * testsuite/libgomp.fortran/depend-7.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: New test. * gfortran.dg/gomp/all-memory-2.f90: New test. * gfortran.dg/gomp/all-memory-3.f90: New test. --- gcc/fortran/dump-parse-tree.cc | 2 +- gcc/fortran/openmp.cc | 79 +++++++++++++++++++++++++++++++++--------- gcc/fortran/resolve.cc | 7 ++++ gcc/fortran/trans-openmp.cc | 10 ++++-- 4 files changed, 78 insertions(+), 20 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 3635460..a329920 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1423,7 +1423,7 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) case OMP_LINEAR_UVAL: fputs ("uval(", dumpfile); break; default: break; } - fprintf (dumpfile, "%s", n->sym->name); + fprintf (dumpfile, "%s", n->sym ? n->sym->name : "omp_all_memory"); if (list_type == OMP_LIST_LINEAR && n->u.linear_op != OMP_LINEAR_DEFAULT) fputc (')', dumpfile); if (n->expr) diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 8643e43..3061e52 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -296,14 +296,17 @@ gfc_find_omp_udr (gfc_namespace *ns, const char *name, gfc_typespec *ts) } -/* Match a variable/common block list and construct a namelist from it. */ +/* Match a variable/common block list and construct a namelist from it; + if has_all_memory != NULL, *has_all_memory is set and omp_all_memory + yields a list->sym NULL entry. */ static match gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list, bool allow_common, bool *end_colon = NULL, gfc_omp_namelist ***headp = NULL, bool allow_sections = false, - bool allow_derived = false) + bool allow_derived = false, + bool *has_all_memory = NULL) { gfc_omp_namelist *head, *tail, *p; locus old_loc, cur_loc; @@ -315,7 +318,8 @@ gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list, head = tail = NULL; old_loc = gfc_current_locus; - + if (has_all_memory) + *has_all_memory = false; m = gfc_match (str); if (m != MATCH_YES) return m; @@ -323,7 +327,35 @@ gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list, for (;;) { cur_loc = gfc_current_locus; - m = gfc_match_symbol (&sym, 1); + + m = gfc_match_name (n); + if (m == MATCH_YES && strcmp (n, "omp_all_memory") == 0) + { + if (!has_all_memory) + { + gfc_error ("% at %C not permitted in this " + "clause"); + goto cleanup; + } + *has_all_memory = true; + p = gfc_get_omp_namelist (); + if (head == NULL) + head = tail = p; + else + { + tail->next = p; + tail = tail->next; + } + tail->where = cur_loc; + goto next_item; + } + if (m == MATCH_YES) + { + gfc_symtree *st; + if ((m = gfc_get_ha_sym_tree (n, &st) ? MATCH_ERROR : MATCH_YES) + == MATCH_YES) + sym = st->n.sym; + } switch (m) { case MATCH_YES: @@ -578,6 +610,12 @@ gfc_match_omp_depend_sink (gfc_omp_namelist **list) tail->sym = sym; tail->expr = NULL; tail->where = cur_loc; + if (UNLIKELY (strcmp (sym->name, "omp_all_memory") == 0)) + { + gfc_error ("% used with DEPEND kind " + "other than OUT or INOUT at %C"); + goto cleanup; + } if (gfc_match_char ('+') == MATCH_YES) { if (gfc_match_literal_constant (&tail->expr, 0) != MATCH_YES) @@ -1868,6 +1906,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, if ((mask & OMP_CLAUSE_DEPEND) && gfc_match ("depend ( ") == MATCH_YES) { + bool has_omp_all_memory; gfc_namespace *ns_iter = NULL, *ns_curr = gfc_current_ns; match m_it = gfc_match_iterator (&ns_iter, false); if (m_it == MATCH_ERROR) @@ -1920,21 +1959,27 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, if (m == MATCH_YES) m = gfc_match_omp_variable_list (" : ", &c->lists[OMP_LIST_DEPEND], - false, NULL, &head, true); + false, NULL, &head, true, + false, &has_omp_all_memory); + if (m != MATCH_YES) + goto error; gfc_current_ns = ns_curr; - if (m == MATCH_YES) + if (has_omp_all_memory && depend_op != OMP_DEPEND_INOUT + && depend_op != OMP_DEPEND_OUT) { - gfc_omp_namelist *n; - for (n = *head; n; n = n->next) - { - n->u.depend_op = depend_op; - n->u2.ns = ns_iter; - if (ns_iter) - ns_iter->refs++; - } - continue; + gfc_error ("% used with DEPEND kind " + "other than OUT or INOUT at %C"); + goto error; } - break; + gfc_omp_namelist *n; + for (n = *head; n; n = n->next) + { + n->u.depend_op = depend_op; + n->u2.ns = ns_iter; + if (ns_iter) + ns_iter->refs++; + } + continue; } if ((mask & OMP_CLAUSE_DETACH) && !openacc @@ -6490,6 +6535,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, for (list = 0; list < OMP_LIST_NUM; list++) for (n = omp_clauses->lists[list]; n; n = n->next) { + if (!n->sym) /* omp_all_memory. */ + continue; n->sym->mark = 0; n->sym->comp_mark = 0; if (n->sym->attr.flavor == FL_VARIABLE diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index c8335f9..2ebf076 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -15505,6 +15505,13 @@ resolve_symbol (gfc_symbol *sym) if (sym->attr.unlimited_polymorphic) return; + if (UNLIKELY (flag_openmp && strcmp (sym->name, "omp_all_memory") == 0)) + { + gfc_error ("%, declared at %L, may only be used in " + "the OpenMP DEPEND clause", &sym->declared_at); + return; + } + if (sym->attr.flavor == FL_UNKNOWN || (sym->attr.flavor == FL_PROCEDURE && !sym->attr.intrinsic && !sym->attr.generic && !sym->attr.external diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index eb5870c..7633aee 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -2880,14 +2880,16 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, continue; } - if (!n->sym->attr.referenced) + if (n->sym && !n->sym->attr.referenced) continue; tree node = build_omp_clause (input_location, list == OMP_LIST_DEPEND ? OMP_CLAUSE_DEPEND : OMP_CLAUSE_AFFINITY); - if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL) + if (n->sym == NULL) /* omp_all_memory */ + OMP_CLAUSE_DECL (node) = null_pointer_node; + else if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL) { tree decl = gfc_trans_omp_variable (n->sym, false); if (gfc_omp_privatize_by_reference (decl)) @@ -5531,7 +5533,9 @@ gfc_trans_omp_depobj (gfc_code *code) if (n) { tree var; - if (n->expr && n->expr->ref->u.ar.type != AR_FULL) + if (!n->sym) /* omp_all_memory. */ + var = null_pointer_node; + else if (n->expr && n->expr->ref->u.ar.type != AR_FULL) { gfc_init_se (&se, NULL); if (n->expr->ref->u.ar.type == AR_ELEMENT) -- cgit v1.1 From 3d9439b1bb76c186958d5b86f0076f8b3017b8a2 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 18 May 2022 00:16:36 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 09c741e..13d3fb0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2022-05-17 Tobias Burnus + + * dump-parse-tree.cc (show_omp_namelist): Handle omp_all_memory. + * openmp.cc (gfc_match_omp_variable_list, gfc_match_omp_depend_sink, + gfc_match_omp_clauses, resolve_omp_clauses): Likewise. + * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): + Likewise. + * resolve.cc (resolve_symbol): Reject it as symbol. + 2022-05-16 Martin Liska * frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE. -- cgit v1.1 From ba8563693fb4eb1317fcbd54883516c3873782f4 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 18 May 2022 12:04:21 +0200 Subject: OpenMP: Add Fortran support for inoutset depend-kind Fortran additions to the C/C++ + ME/libgomp commit r13-556-g2c16eb3157f86ae561468c540caf8eb326106b5f gcc/fortran/ChangeLog: * gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET. (gfc_omp_clauses): Enlarge ENUM_BITFIELD. * dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle 'inoutset' depend modifier. * openmp.cc (gfc_match_omp_clauses, gfc_match_omp_depobj): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): Likewise. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.1): Set 'inoutset' to Y. (OpenMP Context Selectors): Add missing comma. * testsuite/libgomp.fortran/depend-5.f90: Add inoutset test. * testsuite/libgomp.fortran/depend-6.f90: Likewise. * testsuite/libgomp.fortran/depend-7.f90: Likewise. * testsuite/libgomp.fortran/depend-inoutset-1.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: Add inoutset test. * gfortran.dg/gomp/all-memory-2.f90: Likewise. * gfortran.dg/gomp/depobj-1.f90: Likewise. * gfortran.dg/gomp/depobj-2.f90: Likewise. --- gcc/fortran/dump-parse-tree.cc | 2 ++ gcc/fortran/gfortran.h | 3 ++- gcc/fortran/openmp.cc | 12 ++++++++---- gcc/fortran/trans-openmp.cc | 4 ++++ 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index a329920..4e8986b 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1379,6 +1379,7 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) case OMP_DEPEND_IN: fputs ("in:", dumpfile); break; case OMP_DEPEND_OUT: fputs ("out:", dumpfile); break; case OMP_DEPEND_INOUT: fputs ("inout:", dumpfile); break; + case OMP_DEPEND_INOUTSET: fputs ("inoutset:", dumpfile); break; case OMP_DEPEND_DEPOBJ: fputs ("depobj:", dumpfile); break; case OMP_DEPEND_MUTEXINOUTSET: fputs ("mutexinoutset:", dumpfile); @@ -1898,6 +1899,7 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses) case OMP_DEPEND_IN: deptype = "IN"; break; case OMP_DEPEND_OUT: deptype = "OUT"; break; case OMP_DEPEND_INOUT: deptype = "INOUT"; break; + case OMP_DEPEND_INOUTSET: deptype = "INOUTSET"; break; case OMP_DEPEND_MUTEXINOUTSET: deptype = "MUTEXINOUTSET"; break; default: gcc_unreachable (); } diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 1bce283..5d970bc 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1271,6 +1271,7 @@ enum gfc_omp_depend_op OMP_DEPEND_IN, OMP_DEPEND_OUT, OMP_DEPEND_INOUT, + OMP_DEPEND_INOUTSET, OMP_DEPEND_MUTEXINOUTSET, OMP_DEPEND_DEPOBJ, OMP_DEPEND_SINK_FIRST, @@ -1540,7 +1541,7 @@ typedef struct gfc_omp_clauses ENUM_BITFIELD (gfc_omp_memorder) fail:3; ENUM_BITFIELD (gfc_omp_cancel_kind) cancel:3; ENUM_BITFIELD (gfc_omp_proc_bind_kind) proc_bind:3; - ENUM_BITFIELD (gfc_omp_depend_op) depobj_update:3; + ENUM_BITFIELD (gfc_omp_depend_op) depobj_update:4; ENUM_BITFIELD (gfc_omp_bind_type) bind:2; ENUM_BITFIELD (gfc_omp_at_type) at:2; ENUM_BITFIELD (gfc_omp_severity_type) severity:2; diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 3061e52..63fd4dd 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -1915,7 +1915,9 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, break; m = MATCH_YES; gfc_omp_depend_op depend_op = OMP_DEPEND_OUT; - if (gfc_match ("inout") == MATCH_YES) + if (gfc_match ("inoutset") == MATCH_YES) + depend_op = OMP_DEPEND_INOUTSET; + else if (gfc_match ("inout") == MATCH_YES) depend_op = OMP_DEPEND_INOUT; else if (gfc_match ("in") == MATCH_YES) depend_op = OMP_DEPEND_IN; @@ -3805,7 +3807,9 @@ gfc_match_omp_depobj (void) if (gfc_match ("update ( ") == MATCH_YES) { c = gfc_get_omp_clauses (); - if (gfc_match ("inout )") == MATCH_YES) + if (gfc_match ("inoutset )") == MATCH_YES) + c->depobj_update = OMP_DEPEND_INOUTSET; + else if (gfc_match ("inout )") == MATCH_YES) c->depobj_update = OMP_DEPEND_INOUT; else if (gfc_match ("in )") == MATCH_YES) c->depobj_update = OMP_DEPEND_IN; @@ -3815,8 +3819,8 @@ gfc_match_omp_depobj (void) c->depobj_update = OMP_DEPEND_MUTEXINOUTSET; else { - gfc_error ("Expected IN, OUT, INOUT, MUTEXINOUTSET followed by " - "%<)%> at %C"); + gfc_error ("Expected IN, OUT, INOUT, INOUTSET or MUTEXINOUTSET " + "followed by %<)%> at %C"); goto error; } } diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 7633aee..e1907a4 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -2937,6 +2937,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, case OMP_DEPEND_INOUT: OMP_CLAUSE_DEPEND_KIND (node) = OMP_CLAUSE_DEPEND_INOUT; break; + case OMP_DEPEND_INOUTSET: + OMP_CLAUSE_DEPEND_KIND (node) = OMP_CLAUSE_DEPEND_INOUTSET; + break; case OMP_DEPEND_MUTEXINOUTSET: OMP_CLAUSE_DEPEND_KIND (node) = OMP_CLAUSE_DEPEND_MUTEXINOUTSET; @@ -5593,6 +5596,7 @@ gfc_trans_omp_depobj (gfc_code *code) case OMP_DEPEND_IN: k = GOMP_DEPEND_IN; break; case OMP_DEPEND_OUT: k = GOMP_DEPEND_OUT; break; case OMP_DEPEND_INOUT: k = GOMP_DEPEND_INOUT; break; + case OMP_DEPEND_INOUTSET: k = GOMP_DEPEND_INOUTSET; break; case OMP_DEPEND_MUTEXINOUTSET: k = GOMP_DEPEND_MUTEXINOUTSET; break; default: gcc_unreachable (); } -- cgit v1.1 From 1cda629f96b4e982bb87343a35a6db39445d3962 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 19 May 2022 00:16:32 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 13d3fb0..1b9cb91 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-05-18 Tobias Burnus + + * gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET. + (gfc_omp_clauses): Enlarge ENUM_BITFIELD. + * dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle + 'inoutset' depend modifier. + * openmp.cc (gfc_match_omp_clauses, gfc_match_omp_depobj): Likewise. + * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): + Likewise. + 2022-05-17 Tobias Burnus * dump-parse-tree.cc (show_omp_namelist): Handle omp_all_memory. -- cgit v1.1 From 49d1a2f91325fa8cc011149e27e5093a988b3a49 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 23 May 2022 10:54:32 +0200 Subject: OpenMP: Handle descriptors in target's firstprivate [PR104949] For allocatable/pointer arrays, a firstprivate to a device not only needs to privatize the descriptor but also the actual data. This is implemented as: firstprivate(x) firstprivate(x.data) attach(x [bias: &x.data-&x) where the address of x in device memory is saved in hostaddrs[i] by libgomp and the middle end actually passes hostaddrs[i]' to attach. As side effect, has_device_addr(array_desc) had to be changed: before, it was converted to firstprivate in the front end; now it is handled in omp-low.cc as has_device_addr requires a shallow firstprivate (not touching the data pointer) while the normal firstprivate requires (now) a deep firstprivate. gcc/fortran/ChangeLog: PR fortran/104949 * f95-lang.cc (LANG_HOOKS_OMP_ARRAY_SIZE): Redefine. * trans-openmp.cc (gfc_omp_array_size): New. (gfc_trans_omp_variable_list): Never turn has_device_addr to firstprivate. * trans.h (gfc_omp_array_size): New. gcc/ChangeLog: PR fortran/104949 * langhooks-def.h (lhd_omp_array_size): New. (LANG_HOOKS_OMP_ARRAY_SIZE): Define. (LANG_HOOKS_DECLS): Add it. * langhooks.cc (lhd_omp_array_size): New. * langhooks.h (struct lang_hooks_for_decls): Add hook. * omp-low.cc (scan_sharing_clauses, lower_omp_target): Handle GOMP_MAP_FIRSTPRIVATE for array descriptors. libgomp/ChangeLog: PR fortran/104949 * target.c (gomp_map_vars_internal, copy_firstprivate_data): Support attach for GOMP_MAP_FIRSTPRIVATE. * testsuite/libgomp.fortran/target-firstprivate-1.f90: New test. * testsuite/libgomp.fortran/target-firstprivate-2.f90: New test. * testsuite/libgomp.fortran/target-firstprivate-3.f90: New test. --- gcc/fortran/f95-lang.cc | 2 ++ gcc/fortran/trans-openmp.cc | 53 ++++++++++++++++++++++++++++++++++++--------- gcc/fortran/trans.h | 1 + 3 files changed, 46 insertions(+), 10 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc index 1a895a2..e83fef3 100644 --- a/gcc/fortran/f95-lang.cc +++ b/gcc/fortran/f95-lang.cc @@ -114,6 +114,7 @@ static const struct attribute_spec gfc_attribute_table[] = #undef LANG_HOOKS_TYPE_FOR_SIZE #undef LANG_HOOKS_INIT_TS #undef LANG_HOOKS_OMP_ARRAY_DATA +#undef LANG_HOOKS_OMP_ARRAY_SIZE #undef LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR #undef LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT #undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE @@ -152,6 +153,7 @@ static const struct attribute_spec gfc_attribute_table[] = #define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size #define LANG_HOOKS_INIT_TS gfc_init_ts #define LANG_HOOKS_OMP_ARRAY_DATA gfc_omp_array_data +#define LANG_HOOKS_OMP_ARRAY_SIZE gfc_omp_array_size #define LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR gfc_omp_is_allocatable_or_ptr #define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT gfc_omp_check_optional_argument #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index e1907a4..bfd24f9 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -169,6 +169,48 @@ gfc_omp_array_data (tree decl, bool type_only) return decl; } +/* Return the byte-size of the passed array descriptor. */ + +tree +gfc_omp_array_size (tree decl, gimple_seq *pre_p) +{ + stmtblock_t block; + if (POINTER_TYPE_P (TREE_TYPE (decl))) + decl = build_fold_indirect_ref (decl); + tree type = TREE_TYPE (decl); + gcc_assert (GFC_DESCRIPTOR_TYPE_P (type)); + bool allocatable = (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE + || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER + || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT); + gfc_init_block (&block); + tree size = gfc_full_array_size (&block, decl, + GFC_TYPE_ARRAY_RANK (TREE_TYPE (decl))); + size = fold_convert (size_type_node, size); + tree elemsz = gfc_get_element_type (TREE_TYPE (decl)); + if (TREE_CODE (elemsz) == ARRAY_TYPE && TYPE_STRING_FLAG (elemsz)) + elemsz = gfc_conv_descriptor_elem_len (decl); + else + elemsz = TYPE_SIZE_UNIT (elemsz); + size = fold_build2 (MULT_EXPR, size_type_node, size, elemsz); + if (!allocatable) + gimplify_and_add (gfc_finish_block (&block), pre_p); + else + { + tree var = create_tmp_var (size_type_node); + gfc_add_expr_to_block (&block, build2 (MODIFY_EXPR, sizetype, var, size)); + tree tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, + gfc_conv_descriptor_data_get (decl), + null_pointer_node); + tmp = build3_loc (input_location, COND_EXPR, void_type_node, tmp, + gfc_finish_block (&block), + build2 (MODIFY_EXPR, sizetype, var, size_zero_node)); + gimplify_and_add (tmp, pre_p); + size = var; + } + return size; +} + + /* True if OpenMP should privatize what this DECL points to rather than the DECL itself. */ @@ -1922,16 +1964,7 @@ gfc_trans_omp_variable_list (enum omp_clause_code code, if (t != error_mark_node) { tree node; - /* For HAS_DEVICE_ADDR of an array descriptor, firstprivatize the - descriptor such that the bounds are available; its data component - is unmodified; it is handled as device address inside target. */ - if (code == OMP_CLAUSE_HAS_DEVICE_ADDR - && (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (t)) - || (POINTER_TYPE_P (TREE_TYPE (t)) - && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (t)))))) - node = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); - else - node = build_omp_clause (input_location, code); + node = build_omp_clause (input_location, code); OMP_CLAUSE_DECL (node) = t; list = gfc_trans_add_clause (node, list); diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 623acee..03d5288 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -808,6 +808,7 @@ bool gfc_get_array_descr_info (const_tree, struct array_descr_info *); bool gfc_omp_is_allocatable_or_ptr (const_tree); tree gfc_omp_check_optional_argument (tree, bool); tree gfc_omp_array_data (tree, bool); +tree gfc_omp_array_size (tree, gimple_seq *); bool gfc_omp_privatize_by_reference (const_tree); enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree); enum omp_clause_defaultmap_kind gfc_omp_predetermined_mapping (tree); -- cgit v1.1 From 168fc8bda14e2ec24c17d19630cec29fc646ed2f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 24 May 2022 00:17:03 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1b9cb91..dce150a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2022-05-23 Tobias Burnus + + PR fortran/104949 + * f95-lang.cc (LANG_HOOKS_OMP_ARRAY_SIZE): Redefine. + * trans-openmp.cc (gfc_omp_array_size): New. + (gfc_trans_omp_variable_list): Never turn has_device_addr + to firstprivate. + * trans.h (gfc_omp_array_size): New. + 2022-05-18 Tobias Burnus * gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET. -- cgit v1.1 From 4fb2b4f7ea6b80ae75d3efb6f86e7c6179080535 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 24 May 2022 10:41:43 +0200 Subject: OpenMP: Support nowait with Fortran [PR105378] Fortran part to C/C++/libgomp commit r13-724-gb43836914bdc2a37563cf31359b2c4803bfe4374 gcc/fortran/ PR c/105378 * openmp.cc (gfc_match_omp_taskwait): Accept nowait. gcc/testsuite/ PR c/105378 * gfortran.dg/gomp/taskwait-depend-nowait-1.f90: New. libgomp/ PR c/105378 * libgomp.texi (OpenMP 5.1): Set 'taskwait nowait' to 'Y'. * testsuite/libgomp.fortran/taskwait-depend-nowait-1.f90: New. --- gcc/fortran/openmp.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 63fd4dd..6172ec2 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -5701,7 +5701,8 @@ gfc_match_omp_taskwait (void) new_st.ext.omp_clauses = NULL; return MATCH_YES; } - return match_omp (EXEC_OMP_TASKWAIT, omp_mask (OMP_CLAUSE_DEPEND)); + return match_omp (EXEC_OMP_TASKWAIT, + omp_mask (OMP_CLAUSE_DEPEND) | OMP_CLAUSE_NOWAIT); } -- cgit v1.1 From 768f49a20f467648c8e006e2431d0da3eab11846 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 25 May 2022 00:17:06 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index dce150a..3cffe47 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-05-24 Tobias Burnus + + PR c/105378 + * openmp.cc (gfc_match_omp_taskwait): Accept nowait. + 2022-05-23 Tobias Burnus PR fortran/104949 -- cgit v1.1 From 8af266501795dd76d05faef498dbd3472a01b305 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 27 May 2022 13:12:45 +0200 Subject: Fortran: Fix OpenMP clause name in error message gcc/fortran/ChangeLog: * openmp.cc (gfc_check_omp_requires): Fix clause name in error. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/requires-4.f90: Update dg-error. * gfortran.dg/gomp/requires-8.f90: Update dg-error. Co-authored-by: Chung-Lin Tang --- gcc/fortran/openmp.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 6172ec2..efa62b6 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -5272,7 +5272,7 @@ gfc_check_omp_requires (gfc_namespace *ns, int ref_omp_requires) if ((ref_omp_requires & OMP_REQ_REVERSE_OFFLOAD) && !(ns->omp_requires & OMP_REQ_REVERSE_OFFLOAD)) gfc_error ("Program unit at %L has OpenMP device constructs/routines " - "but does not set !$OMP REQUIRES REVERSE_OFFSET but other " + "but does not set !$OMP REQUIRES REVERSE_OFFLOAD but other " "program units do", &ns->proc_name->declared_at); if ((ref_omp_requires & OMP_REQ_UNIFIED_ADDRESS) && !(ns->omp_requires & OMP_REQ_UNIFIED_ADDRESS)) -- cgit v1.1 From d9176e643f385c3ef3b8c28cbc0468776fd8a14f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 28 May 2022 00:16:40 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3cffe47..59c89f6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-05-27 Tobias Burnus + Chung-Lin Tang + + * openmp.cc (gfc_check_omp_requires): Fix clause name in error. + 2022-05-24 Tobias Burnus PR c/105378 -- cgit v1.1 From e3803f9cbb67efef7462589fe50d00b404356bc9 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sat, 28 May 2022 20:42:38 +0200 Subject: OpenMP/Fortran: Add support for enter clause on declare target Fortran version to C/C++ commit r13-797-g0ccba4ed8571c18c7015413441e971 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER. * gfortran.h: Add OMP_LIST_ENTER. * openmp.cc (enum omp_mask2, OMP_DECLARE_TARGET_CLAUSES): Add OMP_CLAUSE_ENTER. (gfc_match_omp_clauses, gfc_match_omp_declare_target, resolve_omp_clauses): Handle 'enter' clause. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Mark 'enter' clause as supported. * testsuite/libgomp.fortran/declare-target-1.f90: Extend to test explicit 'to' and 'enter' clause. * testsuite/libgomp.fortran/declare-target-2.f90: Update accordingly. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-target-2.f90: Add 'enter' clause test. * gfortran.dg/gomp/declare-target-4.f90: Likewise. --- gcc/fortran/dump-parse-tree.cc | 1 + gcc/fortran/gfortran.h | 1 + gcc/fortran/openmp.cc | 65 ++++++++++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 22 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 4e8986b..e3affb8 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1679,6 +1679,7 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses) case OMP_LIST_IN_REDUCTION: type = "IN_REDUCTION"; break; case OMP_LIST_TASK_REDUCTION: type = "TASK_REDUCTION"; break; case OMP_LIST_DEVICE_RESIDENT: type = "DEVICE_RESIDENT"; break; + case OMP_LIST_ENTER: type = "ENTER"; break; case OMP_LIST_LINK: type = "LINK"; break; case OMP_LIST_USE_DEVICE: type = "USE_DEVICE"; break; case OMP_LIST_CACHE: type = "CACHE"; break; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 5d970bc..0bac865 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1395,6 +1395,7 @@ enum OMP_LIST_NONTEMPORAL, OMP_LIST_ALLOCATE, OMP_LIST_HAS_DEVICE_ADDR, + OMP_LIST_ENTER, OMP_LIST_NUM /* Must be the last. */ }; diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index efa62b6..a1aa88c 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -986,6 +986,7 @@ enum omp_mask2 OMP_CLAUSE_ATTACH, OMP_CLAUSE_NOHOST, OMP_CLAUSE_HAS_DEVICE_ADDR, /* OpenMP 5.1 */ + OMP_CLAUSE_ENTER, /* OpenMP 5.2 */ /* This must come last. */ OMP_MASK2_LAST }; @@ -2101,6 +2102,16 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, continue; } break; + case 'e': + if ((mask & OMP_CLAUSE_ENTER)) + { + m = gfc_match_omp_to_link ("enter (", &c->lists[OMP_LIST_ENTER]); + if (m == MATCH_ERROR) + goto error; + if (m == MATCH_YES) + continue; + } + break; case 'f': if ((mask & OMP_CLAUSE_FAIL) && (m = gfc_match_dupl_check (c->fail == OMP_MEMORDER_UNSET, @@ -2921,8 +2932,12 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, continue; if ((mask & OMP_CLAUSE_TO) && (mask & OMP_CLAUSE_LINK)) { - if (gfc_match_omp_to_link ("to (", &c->lists[OMP_LIST_TO]) - == MATCH_YES) + /* Declare target: 'to' is an alias for 'enter'; + 'to' is deprecated since 5.2. */ + m = gfc_match_omp_to_link ("to (", &c->lists[OMP_LIST_TO]); + if (m == MATCH_ERROR) + goto error; + if (m == MATCH_YES) continue; } else if ((mask & OMP_CLAUSE_TO) @@ -3724,7 +3739,8 @@ cleanup: #define OMP_ORDERED_CLAUSES \ (omp_mask (OMP_CLAUSE_THREADS) | OMP_CLAUSE_SIMD) #define OMP_DECLARE_TARGET_CLAUSES \ - (omp_mask (OMP_CLAUSE_TO) | OMP_CLAUSE_LINK | OMP_CLAUSE_DEVICE_TYPE) + (omp_mask (OMP_CLAUSE_ENTER) | OMP_CLAUSE_LINK | OMP_CLAUSE_DEVICE_TYPE \ + | OMP_CLAUSE_TO) #define OMP_ATOMIC_CLAUSES \ (omp_mask (OMP_CLAUSE_ATOMIC) | OMP_CLAUSE_CAPTURE | OMP_CLAUSE_HINT \ | OMP_CLAUSE_MEMORDER | OMP_CLAUSE_COMPARE | OMP_CLAUSE_FAIL \ @@ -4530,7 +4546,7 @@ gfc_match_omp_declare_target (void) { c = gfc_get_omp_clauses (); gfc_current_locus = old_loc; - m = gfc_match_omp_to_link (" (", &c->lists[OMP_LIST_TO]); + m = gfc_match_omp_to_link (" (", &c->lists[OMP_LIST_ENTER]); if (m != MATCH_YES) goto syntax; if (gfc_match_omp_eos () != MATCH_YES) @@ -4544,38 +4560,40 @@ gfc_match_omp_declare_target (void) gfc_buffer_error (false); - for (list = OMP_LIST_TO; list != OMP_LIST_NUM; - list = (list == OMP_LIST_TO ? OMP_LIST_LINK : OMP_LIST_NUM)) + static const int to_enter_link_lists[] + = { OMP_LIST_TO, OMP_LIST_ENTER, OMP_LIST_LINK }; + for (size_t listn = 0; listn < ARRAY_SIZE (to_enter_link_lists) + && (list = to_enter_link_lists[listn], true); ++listn) for (n = c->lists[list]; n; n = n->next) if (n->sym) n->sym->mark = 0; else if (n->u.common->head) n->u.common->head->mark = 0; - for (list = OMP_LIST_TO; list != OMP_LIST_NUM; - list = (list == OMP_LIST_TO ? OMP_LIST_LINK : OMP_LIST_NUM)) + for (size_t listn = 0; listn < ARRAY_SIZE (to_enter_link_lists) + && (list = to_enter_link_lists[listn], true); ++listn) for (n = c->lists[list]; n; n = n->next) if (n->sym) { if (n->sym->attr.in_common) gfc_error_now ("OMP DECLARE TARGET variable at %L is an " "element of a COMMON block", &n->where); + else if (n->sym->mark) + gfc_error_now ("Variable at %L mentioned multiple times in " + "clauses of the same OMP DECLARE TARGET directive", + &n->where); else if (n->sym->attr.omp_declare_target && n->sym->attr.omp_declare_target_link && list != OMP_LIST_LINK) gfc_error_now ("OMP DECLARE TARGET variable at %L previously " - "mentioned in LINK clause and later in TO clause", - &n->where); + "mentioned in LINK clause and later in %s clause", + &n->where, list == OMP_LIST_TO ? "TO" : "ENTER"); else if (n->sym->attr.omp_declare_target && !n->sym->attr.omp_declare_target_link && list == OMP_LIST_LINK) gfc_error_now ("OMP DECLARE TARGET variable at %L previously " - "mentioned in TO clause and later in LINK clause", - &n->where); - else if (n->sym->mark) - gfc_error_now ("Variable at %L mentioned multiple times in " - "clauses of the same OMP DECLARE TARGET directive", - &n->where); + "mentioned in TO or ENTER clause and later in " + "LINK clause", &n->where); else if (gfc_add_omp_declare_target (&n->sym->attr, n->sym->name, &n->sym->declared_at)) { @@ -4598,14 +4616,14 @@ gfc_match_omp_declare_target (void) && n->u.common->omp_declare_target_link && list != OMP_LIST_LINK) gfc_error_now ("OMP DECLARE TARGET COMMON at %L previously " - "mentioned in LINK clause and later in TO clause", - &n->where); + "mentioned in LINK clause and later in %s clause", + &n->where, list == OMP_LIST_TO ? "TO" : "ENTER"); else if (n->u.common->omp_declare_target && !n->u.common->omp_declare_target_link && list == OMP_LIST_LINK) gfc_error_now ("OMP DECLARE TARGET COMMON at %L previously " - "mentioned in TO clause and later in LINK clause", - &n->where); + "mentioned in TO or ENTER clause and later in " + "LINK clause", &n->where); else if (n->u.common->head && n->u.common->head->mark) gfc_error_now ("COMMON at %L mentioned multiple times in " "clauses of the same OMP DECLARE TARGET directive", @@ -4639,7 +4657,10 @@ gfc_match_omp_declare_target (void) s->attr.omp_device_type = c->device_type; } } - if (c->device_type && !c->lists[OMP_LIST_TO] && !c->lists[OMP_LIST_LINK]) + if (c->device_type + && !c->lists[OMP_LIST_ENTER] + && !c->lists[OMP_LIST_TO] + && !c->lists[OMP_LIST_LINK]) gfc_warning_now (0, "OMP DECLARE TARGET directive at %L with only " "DEVICE_TYPE clause is ignored", &old_loc); @@ -6331,7 +6352,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, "IN_REDUCTION", "TASK_REDUCTION", "DEVICE_RESIDENT", "LINK", "USE_DEVICE", "CACHE", "IS_DEVICE_PTR", "USE_DEVICE_PTR", "USE_DEVICE_ADDR", - "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR" }; + "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR", "ENTER" }; STATIC_ASSERT (ARRAY_SIZE (clause_names) == OMP_LIST_NUM); if (omp_clauses == NULL) -- cgit v1.1 From 37b3b5dabdcdbbc0d191b050116930010dd06acc Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 29 May 2022 00:16:31 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 59c89f6..d009192 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2022-05-28 Tobias Burnus + + * dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER. + * gfortran.h: Add OMP_LIST_ENTER. + * openmp.cc (enum omp_mask2, OMP_DECLARE_TARGET_CLAUSES): Add + OMP_CLAUSE_ENTER. + (gfc_match_omp_clauses, gfc_match_omp_declare_target, + resolve_omp_clauses): Handle 'enter' clause. + 2022-05-27 Tobias Burnus Chung-Lin Tang -- cgit v1.1 From 871dbb6112e22ff92914613c332944fd19dd39a8 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 28 May 2022 22:02:20 +0200 Subject: Fortran: improve runtime error message with ALLOCATE and ERRMSG= [PR91300] ALLOCATE: generate different STAT,ERRMSG results for failures from allocation of already allocated objects or insufficient virtual memory. gcc/fortran/ChangeLog: PR fortran/91300 * libgfortran.h: Define new error code LIBERROR_NO_MEMORY. * trans-stmt.cc (gfc_trans_allocate): Generate code for setting ERRMSG depending on result of STAT result of ALLOCATE. * trans.cc (gfc_allocate_using_malloc): Use STAT value of LIBERROR_NO_MEMORY in case of failed malloc. gcc/testsuite/ChangeLog: PR fortran/91300 * gfortran.dg/allocate_alloc_opt_15.f90: New test. --- gcc/fortran/libgfortran.h | 1 + gcc/fortran/trans-stmt.cc | 33 ++++++++++++++++++++++++++++++--- gcc/fortran/trans.cc | 4 ++-- 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h index 064795e..4328447 100644 --- a/gcc/fortran/libgfortran.h +++ b/gcc/fortran/libgfortran.h @@ -133,6 +133,7 @@ typedef enum LIBERROR_CORRUPT_FILE, LIBERROR_INQUIRE_INTERNAL_UNIT, /* Must be different from STAT_STOPPED_IMAGE. */ LIBERROR_BAD_WAIT_ID, + LIBERROR_NO_MEMORY, LIBERROR_LAST /* Not a real error, the last error # + 1. */ } libgfortran_error_codes; diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 7909681..fd6d294 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -7130,7 +7130,8 @@ gfc_trans_allocate (gfc_code * code) if (code->expr1 && code->expr2) { const char *msg = "Attempt to allocate an allocated object"; - tree slen, dlen, errmsg_str; + const char *oommsg = "Insufficient virtual memory"; + tree slen, dlen, errmsg_str, oom_str, oom_loc; stmtblock_t errmsg_block; gfc_init_block (&errmsg_block); @@ -7151,8 +7152,34 @@ gfc_trans_allocate (gfc_code * code) gfc_default_character_kind); dlen = gfc_finish_block (&errmsg_block); - tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, - stat, build_int_cst (TREE_TYPE (stat), 0)); + tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, + stat, build_int_cst (TREE_TYPE (stat), + LIBERROR_ALLOCATION)); + + tmp = build3_v (COND_EXPR, tmp, + dlen, build_empty_stmt (input_location)); + + gfc_add_expr_to_block (&block, tmp); + + oom_str = gfc_create_var (pchar_type_node, "OOMMSG"); + oom_loc = gfc_build_localized_cstring_const (oommsg); + gfc_add_modify (&errmsg_block, oom_str, + gfc_build_addr_expr (pchar_type_node, oom_loc)); + + slen = build_int_cst (gfc_charlen_type_node, strlen (oommsg)); + dlen = gfc_get_expr_charlen (code->expr2); + slen = fold_build2_loc (input_location, MIN_EXPR, + TREE_TYPE (slen), dlen, slen); + + gfc_trans_string_copy (&errmsg_block, dlen, errmsg, + code->expr2->ts.kind, + slen, oom_str, + gfc_default_character_kind); + dlen = gfc_finish_block (&errmsg_block); + + tmp = fold_build2_loc (input_location, EQ_EXPR, logical_type_node, + stat, build_int_cst (TREE_TYPE (stat), + LIBERROR_NO_MEMORY)); tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location)); diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index f0a5dfb..912a206 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -772,7 +772,7 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size) if (newmem == NULL) { if (stat) - *stat = LIBERROR_ALLOCATION; + *stat = LIBERROR_NO_MEMORY; else runtime_error ("Allocation would exceed memory limit"); } @@ -807,7 +807,7 @@ gfc_allocate_using_malloc (stmtblock_t * block, tree pointer, if (status != NULL_TREE) { tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type, status, - build_int_cst (status_type, LIBERROR_ALLOCATION)); + build_int_cst (status_type, LIBERROR_NO_MEMORY)); gfc_add_expr_to_block (&on_error, tmp); } else -- cgit v1.1 From 0f4df800b15437df1e00f198f86edc7163f1fc94 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 31 May 2022 00:16:32 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d009192..93eea4d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2022-05-30 Harald Anlauf + + PR fortran/91300 + * libgfortran.h: Define new error code LIBERROR_NO_MEMORY. + * trans-stmt.cc (gfc_trans_allocate): Generate code for setting + ERRMSG depending on result of STAT result of ALLOCATE. + * trans.cc (gfc_allocate_using_malloc): Use STAT value of + LIBERROR_NO_MEMORY in case of failed malloc. + 2022-05-28 Tobias Burnus * dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER. -- cgit v1.1 From a8b5d63503b8cf49de32d241218057409f8731ac Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 27 May 2022 12:15:36 -0400 Subject: build: TAGS and .cc transition A few globs missed in the .c -> .cc transition. Some targets were looking at both *.c and *.cc, but there are no longer any .c files to scan. gcc/ChangeLog: * Makefile.in (TAGS): Look at libcpp/*.cc. gcc/c/ChangeLog: * Make-lang.in (c.tags): Look at *.cc. gcc/cp/ChangeLog: * Make-lang.in (c++.tags): Just look at *.cc. gcc/d/ChangeLog: * Make-lang.in (d.tags): Just look at *.cc. gcc/fortran/ChangeLog: * Make-lang.in (fortran.tags): Look at *.cc. gcc/go/ChangeLog: * Make-lang.in (go.tags): Look at *.cc. gcc/objc/ChangeLog: * Make-lang.in (objc.tags): Look at *.cc. gcc/objcp/ChangeLog: * Make-lang.in (obj-c++.tags): Look at *.cc. --- gcc/fortran/Make-lang.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in index a558fc8..1cb47cb 100644 --- a/gcc/fortran/Make-lang.in +++ b/gcc/fortran/Make-lang.in @@ -113,7 +113,7 @@ fortran.srcinfo: doc/gfortran.info -cp -p $^ $(srcdir)/fortran fortran.tags: force - cd $(srcdir)/fortran; $(ETAGS) -o TAGS.sub *.c *.h; \ + cd $(srcdir)/fortran; $(ETAGS) -o TAGS.sub *.cc *.h; \ $(ETAGS) --include TAGS.sub --include ../TAGS.sub fortran.info: doc/gfortran.info doc/gfc-internals.info -- cgit v1.1 From 820ead4519c266c83b4e3d11484a66d6691bc441 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 1 Jun 2022 00:16:34 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 93eea4d..ec7c48e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2022-05-31 Jason Merrill + + * Make-lang.in (fortran.tags): Look at *.cc. + 2022-05-30 Harald Anlauf PR fortran/91300 -- cgit v1.1 From 6cf276ddf22066af780335cd0072d2c27aabe468 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 2 Jun 2022 15:40:22 -0400 Subject: diagnostics: add SARIF output format This patch adds support to gcc's diagnostic subsystem for emitting diagnostics in SARIF, aka the Static Analysis Results Interchange Format: https://sarifweb.azurewebsites.net/ by extending -fdiagnostics-format= to add two new options: -fdiagnostics-format=sarif-stderr and: -fdiagnostics-format=sarif-file The patch targets SARIF v2.1.0 This is a JSON-based format suited for capturing the results of static analysis tools (like GCC's -fanalyzer), but it can also be used for plain GCC warnings and errors. SARIF supports per-event metadata in diagnostic paths such as ["acquire", "resource"] and ["release", "lock"] (specifically, the threadFlowLocation "kinds" property: SARIF v2.1.0 section 3.38.8), so the patch extends GCC"s diagnostic_event subclass with a "struct meaning" with similar purpose. The patch implements this for -fanalyzer so that the various state-machine-based warnings set these in the SARIF output. The heart of the implementation is in the new file diagnostic-format-sarif.cc. Much of the rest of the patch is interface classes, isolating the diagnostic subsystem (which has no knowledge of e.g. tree or langhook) from the "client" code in the compiler proper cc1 etc). The patch adds a langhook for specifying the SARIF v2.1.0 "artifact.sourceLanguage" property, based on the list in SARIF v2.1.0 Appendix J. The patch adds automated DejaGnu tests to our testsuite via new scan-sarif-file and scan-sarif-file-not directives (although these merely use regexps, rather than attempting to use a proper JSON parser). I've tested the patch by hand using the validator at: https://sarifweb.azurewebsites.net/Validation and the react-based viewer at: https://microsoft.github.io/sarif-web-component/ which successfully shows most of the information (although not paths, and not CWE IDs), and I've fixed all validation errors I've seen (though bugs no doubt remain). I've also tested the generated SARIF using the VS Code extension linked to from the SARIF website; I'm a novice with VS Code, but it seems to be able to handle my generated SARIF files (e.g. showing the data in the SARIF tab, and showing squiggly underlines under issues, and when I click on them, it visualizes the events in the path inline within the source window). Has anyone written an Emacs mode for SARIF files? (pretty please) gcc/ChangeLog: * Makefile.in (OBJS): Add tree-diagnostic-client-data-hooks.o and tree-logical-location.o. (OBJS-libcommon): Add diagnostic-format-sarif.o; reorder. (CFLAGS-tree-diagnostic-client-data-hooks.o): Add TARGET_NAME. * common.opt (fdiagnostics-format=): Add sarif-stderr and sarif-file. (sarif-stderr, sarif-file): New enum values. * diagnostic-client-data-hooks.h: New file. * diagnostic-format-sarif.cc: New file. * diagnostic-path.h (enum diagnostic_event::verb): New enum. (enum diagnostic_event::noun): New enum. (enum diagnostic_event::property): New enum. (struct diagnostic_event::meaning): New struct. (diagnostic_event::get_logical_location): New vfunc. (diagnostic_event::get_meaning): New vfunc. (simple_diagnostic_event::get_logical_location): New vfunc impl. (simple_diagnostic_event::get_meaning): New vfunc impl. * diagnostic.cc: Include "diagnostic-client-data-hooks.h". (diagnostic_initialize): Initialize m_client_data_hooks. (diagnostic_finish): Clean up m_client_data_hooks. (diagnostic_event::meaning::dump_to_pp): New. (diagnostic_event::meaning::maybe_get_verb_str): New. (diagnostic_event::meaning::maybe_get_noun_str): New. (diagnostic_event::meaning::maybe_get_property_str): New. (get_cwe_url): Make non-static. (diagnostic_output_format_init): Handle DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. * diagnostic.h (enum diagnostics_output_format): Add DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. (class diagnostic_client_data_hooks): New forward decl. (class logical_location): New forward decl. (diagnostic_context::m_client_data_hooks): New field. (diagnostic_output_format_init_sarif_stderr): New decl. (diagnostic_output_format_init_sarif_file): New decl. (get_cwe_url): New decl. * doc/invoke.texi (-fdiagnostics-format=): Add sarif-stderr and sarif-file. * doc/sourcebuild.texi (Scan a particular file): Add scan-sarif-file and scan-sarif-file-not. * langhooks-def.h (lhd_get_sarif_source_language): New decl. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): New macro. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE. * langhooks.cc (lhd_get_sarif_source_language): New. * langhooks.h (lang_hooks::get_sarif_source_language): New field. * logical-location.h: New file. * plugin.cc (struct for_each_plugin_closure): New. (for_each_plugin_cb): New. (for_each_plugin): New. * plugin.h (for_each_plugin): New decl. * tree-diagnostic-client-data-hooks.cc: New file. * tree-diagnostic.cc: Include "diagnostic-client-data-hooks.h". (tree_diagnostics_defaults): Populate m_client_data_hooks. * tree-logical-location.cc: New file. * tree-logical-location.h: New file. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/analyzer/ChangeLog: * checker-path.cc (checker_event::get_meaning): New. (function_entry_event::get_meaning): New. (state_change_event::get_desc): Add dump of meaning of the event to the -fanalyzer-verbose-state-changes output. (state_change_event::get_meaning): New. (cfg_edge_event::get_meaning): New. (call_event::get_meaning): New. (return_event::get_meaning): New. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New. * checker-path.h: Include "tree-logical-location.h". (checker_event::checker_event): Construct m_logical_loc. (checker_event::get_logical_location): New. (checker_event::get_meaning): New decl. (checker_event::m_logical_loc): New. (function_entry_event::get_meaning): New decl. (state_change_event::get_meaning): New decl. (cfg_edge_event::get_meaning): New decl. (call_event::get_meaning): New decl. (return_event::get_meaning): New decl. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New decl. * pending-diagnostic.h: Include "diagnostic-path.h". (pending_diagnostic::get_meaning_for_state_change): New vfunc. * sm-file.cc (file_diagnostic::get_meaning_for_state_change): New vfunc impl. * sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change): Likewise. * sm-sensitive.cc (exposure_through_output_file::get_meaning_for_state_change): Likewise. * sm-taint.cc (taint_diagnostic::get_meaning_for_state_change): Likewise. * varargs.cc (va_list_sm_diagnostic::get_meaning_for_state_change): Likewise. gcc/c/ChangeLog: * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (c_get_sarif_source_language): New. * c-tree.h (c_get_sarif_source_language): New decl. gcc/cp/ChangeLog: * cp-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (cp_get_sarif_source_language): New. gcc/d/ChangeLog: * d-lang.cc (d_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/fortran/ChangeLog: * f95-lang.cc (gfc_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/go/ChangeLog: * go-lang.cc (go_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/objc/ChangeLog: * objc-act.h (objc_get_sarif_source_language): New decl. * objc-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (objc_get_sarif_source_language): New. gcc/testsuite/ChangeLog: * c-c++-common/diagnostic-format-sarif-file-1.c: New test. * c-c++-common/diagnostic-format-sarif-file-2.c: New test. * c-c++-common/diagnostic-format-sarif-file-3.c: New test. * c-c++-common/diagnostic-format-sarif-file-4.c: New test. * gcc.dg/analyzer/file-meaning-1.c: New test. * gcc.dg/analyzer/malloc-meaning-1.c: New test. * gcc.dg/analyzer/malloc-sarif-1.c: New test. * gcc.dg/plugin/analyzer_gil_plugin.c (gil_diagnostic::get_meaning_for_state_change): New vfunc impl. * gcc.dg/plugin/diagnostic-test-paths-5.c: New test. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-paths-5.c to tests for diagnostic_plugin_test_paths.c. * lib/gcc-dg.exp: Load scansarif.exp. * lib/scansarif.exp: New test. libatomic/ChangeLog: * testsuite/lib/libatomic.exp: Add load_gcc_lib of scansarif.exp. libgomp/ChangeLog: * testsuite/lib/libgomp.exp: Add load_gcc_lib of scansarif.exp. libitm/ChangeLog: * testsuite/lib/libitm.exp: Add load_gcc_lib of scansarif.exp. libphobos/ChangeLog: * testsuite/lib/libphobos-dg.exp: Add load_gcc_lib of scansarif.exp. Signed-off-by: David Malcolm --- gcc/fortran/f95-lang.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc index e83fef3..319cf8f 100644 --- a/gcc/fortran/f95-lang.cc +++ b/gcc/fortran/f95-lang.cc @@ -100,6 +100,15 @@ static const struct attribute_spec gfc_attribute_table[] = { NULL, 0, 0, false, false, false, false, NULL, NULL } }; +/* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property, + based on the list in SARIF v2.1.0 Appendix J. */ + +static const char * +gfc_get_sarif_source_language (const char *) +{ + return "fortran"; +} + #undef LANG_HOOKS_NAME #undef LANG_HOOKS_INIT #undef LANG_HOOKS_FINISH @@ -138,6 +147,7 @@ static const struct attribute_spec gfc_attribute_table[] = #undef LANG_HOOKS_BUILTIN_FUNCTION #undef LANG_HOOKS_GET_ARRAY_DESCR_INFO #undef LANG_HOOKS_ATTRIBUTE_TABLE +#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE /* Define lang hooks. */ #define LANG_HOOKS_NAME "GNU Fortran" @@ -177,6 +187,7 @@ static const struct attribute_spec gfc_attribute_table[] = #define LANG_HOOKS_BUILTIN_FUNCTION gfc_builtin_function #define LANG_HOOKS_GET_ARRAY_DESCR_INFO gfc_get_array_descr_info #define LANG_HOOKS_ATTRIBUTE_TABLE gfc_attribute_table +#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE gfc_get_sarif_source_language struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; -- cgit v1.1 From b168441c8a6b7cb6b6623694eb9e1cc87a3d51af Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 3 Jun 2022 00:16:40 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ec7c48e..d584790 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-06-02 David Malcolm + + * f95-lang.cc (gfc_get_sarif_source_language): New. + (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. + 2022-05-31 Jason Merrill * Make-lang.in (fortran.tags): Look at *.cc. -- cgit v1.1 From ff35a75473d28205e52ecbcf9e6b5107b8b5ab90 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 3 Jun 2022 15:52:22 +0200 Subject: OpenMP/Fortran: Add support for firstprivate and allocate clauses on scope construct Fortran commit to C/C++/backend commit r13-862-gf38b20d68fade5a922b9f68c4c3841e653d1b83c gcc/fortran/ChangeLog: * openmp.cc (OMP_SCOPE_CLAUSES): Add firstprivate and allocate. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Mark scope w/ firstprivate/allocate as Y. * testsuite/libgomp.fortran/scope-2.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/scope-5.f90: New test. * gfortran.dg/gomp/scope-6.f90: New test. --- gcc/fortran/openmp.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index a1aa88c..d12cec4 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -3682,7 +3682,8 @@ cleanup: | OMP_CLAUSE_PRIVATE | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_REDUCTION) #define OMP_SCOPE_CLAUSES \ - (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_REDUCTION) + (omp_mask (OMP_CLAUSE_PRIVATE) |OMP_CLAUSE_FIRSTPRIVATE \ + | OMP_CLAUSE_REDUCTION | OMP_CLAUSE_ALLOCATE) #define OMP_SECTIONS_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_FIRSTPRIVATE \ | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_REDUCTION | OMP_CLAUSE_ALLOCATE) -- cgit v1.1 From 58b67140de7685de25b2f5775b5735f9c491b058 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 4 Jun 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d584790..fd1edc8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2022-06-03 Tobias Burnus + + * openmp.cc (OMP_SCOPE_CLAUSES): Add firstprivate and allocate. + 2022-06-02 David Malcolm * f95-lang.cc (gfc_get_sarif_source_language): New. -- cgit v1.1 From 03b71406323ddc065b1d7837d8b43b17e4b048b5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 7 Jun 2022 10:05:08 +0200 Subject: openmp: Add support for OpenMP 5.2 linear clause syntax for C/C++ The syntax for linear clause changed in 5.2, the original syntax which is still valid is: linear (var1, var2) linear (var3, var4 : step1) The 4.5 syntax with modifiers like: linear (val (var5, var6)) linear (val (var7, var8) : step2) is still supported in 5.2, but is deprecated there. Instead, one can use a new syntax: linear (var9, var10 : val) linear (var11, var12 : step (step3), val) As val, ref, uval or step (someexpr) can be valid expressions (and especially in C++ can be const / constexpr / consteval), the spec says that when the whole step expression is val (or ref or uval) or step ( ... ) then it is the new modifier syntax, one can use + 0 or 0 + or 1 * or * 1 or ()s to say it is the old step expression. Also, 5.2 now allows val modifier to be specified even outside of declare simd (but not the other modifiers). I've implemented this for the new modifier syntax only, the old one keeps the old restriction (which is why OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag has been introduced). 2022-06-07 Jakub Jelinek gcc/ * tree.h (OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER): Define. * tree-pretty-print.cc (dump_omp_clause) : Adjust clause printing style depending on OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER. gcc/c/ * c-parser.cc (c_parser_omp_clause_linear): Parse OpenMP 5.2 style linear clause modifiers. Set OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag on the clauses when old style modifiers are used. * c-typeck.cc (c_finish_omp_clauses): Only reject linear clause with val modifier on simd or for if the old style modifiers are used. gcc/cp/ * parser.cc (cp_parser_omp_clause_linear): Parse OpenMP 5.2 style linear clause modifiers. Set OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag on the clauses when old style modifiers are used. * semantics.cc (finish_omp_clauses): Only reject linear clause with val modifier on simd or for if the old style modifiers are used. gcc/fortran/ * trans-openmp.cc (gfc_trans_omp_clauses): Set OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER on OMP_CLAUSE_LINEAR clauses unconditionally for now. gcc/testsuite/ * c-c++-common/gomp/linear-2.c: New test. * c-c++-common/gomp/linear-3.c: New test. * g++.dg/gomp/linear-3.C: New test. * g++.dg/gomp/linear-4.C: New test. * g++.dg/gomp/linear-5.C: New test. --- gcc/fortran/trans-openmp.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index bfd24f9..c6a584d 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -2769,6 +2769,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, gcc_unreachable (); } OMP_CLAUSE_LINEAR_KIND (node) = kind; + OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (node) = 1; if (last_step_expr && last_step == NULL_TREE) { if (!declare_simd) -- cgit v1.1 From 445ba599cb4e9a766526d30216863e3e01586557 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 8 Jun 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fd1edc8..7544847 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-06-07 Jakub Jelinek + + * trans-openmp.cc (gfc_trans_omp_clauses): Set + OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER on OMP_CLAUSE_LINEAR + clauses unconditionally for now. + 2022-06-03 Tobias Burnus * openmp.cc (OMP_SCOPE_CLAUSES): Add firstprivate and allocate. -- cgit v1.1 From 5e5deac508e3025e2d2c36212aa52d52001b893d Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 8 Jun 2022 10:06:57 +0200 Subject: OpenMP: Fortran - fix ancestor's requires reverse_offload check gcc/fortran/ * openmp.cc (gfc_match_omp_clauses): Check also parent namespace for 'requires reverse_offload'. gcc/testsuite/ * gfortran.dg/gomp/target-device-ancestor-5.f90: New test. --- gcc/fortran/openmp.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index d12cec4..aeb8a43 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -2014,8 +2014,15 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, } else if (gfc_match ("ancestor : ") == MATCH_YES) { + bool has_requires = false; c->ancestor = true; - if (!(gfc_current_ns->omp_requires & OMP_REQ_REVERSE_OFFLOAD)) + for (gfc_namespace *ns = gfc_current_ns; ns; ns = ns->parent) + if (ns->omp_requires & OMP_REQ_REVERSE_OFFLOAD) + { + has_requires = true; + break; + } + if (!has_requires) { gfc_error ("% device modifier not " "preceded by % directive " -- cgit v1.1 From 02b4e2de3204e74ce06d2d46bc8ee30ac93ce9fb Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 9 Jun 2022 00:16:26 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7544847..27d445a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-06-08 Tobias Burnus + + * openmp.cc (gfc_match_omp_clauses): Check also parent namespace + for 'requires reverse_offload'. + 2022-06-07 Jakub Jelinek * trans-openmp.cc (gfc_trans_omp_clauses): Set -- cgit v1.1 From 856a9b8fc2b457963898c539f0db92a1baa0bf27 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 15 Jun 2022 22:20:09 +0200 Subject: Fortran: check POS and LEN arguments simplifying bit intrinsics [PR105986] gcc/fortran/ChangeLog: PR fortran/105986 * simplify.cc (gfc_simplify_btest): Add check for POS argument. (gfc_simplify_ibclr): Add check for POS argument. (gfc_simplify_ibits): Add check for POS and LEN arguments. (gfc_simplify_ibset): Add check for POS argument. gcc/testsuite/ChangeLog: PR fortran/105986 * gfortran.dg/check_bits_3.f90: New test. --- gcc/fortran/simplify.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 233cc42..c8f2ef9 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -1644,6 +1644,9 @@ gfc_simplify_btest (gfc_expr *e, gfc_expr *bit) if (e->expr_type != EXPR_CONSTANT || bit->expr_type != EXPR_CONSTANT) return NULL; + if (!gfc_check_bitfcn (e, bit)) + return &gfc_bad_expr; + if (gfc_extract_int (bit, &b) || b < 0) return gfc_get_logical_expr (gfc_default_logical_kind, &e->where, false); @@ -3353,6 +3356,9 @@ gfc_simplify_ibclr (gfc_expr *x, gfc_expr *y) if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT) return NULL; + if (!gfc_check_bitfcn (x, y)) + return &gfc_bad_expr; + gfc_extract_int (y, &pos); k = gfc_validate_kind (x->ts.type, x->ts.kind, false); @@ -3384,6 +3390,9 @@ gfc_simplify_ibits (gfc_expr *x, gfc_expr *y, gfc_expr *z) || z->expr_type != EXPR_CONSTANT) return NULL; + if (!gfc_check_ibits (x, y, z)) + return &gfc_bad_expr; + gfc_extract_int (y, &pos); gfc_extract_int (z, &len); @@ -3438,6 +3447,9 @@ gfc_simplify_ibset (gfc_expr *x, gfc_expr *y) if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT) return NULL; + if (!gfc_check_bitfcn (x, y)) + return &gfc_bad_expr; + gfc_extract_int (y, &pos); k = gfc_validate_kind (x->ts.type, x->ts.kind, false); -- cgit v1.1 From 4390e7bfbc641a52c6192b448768dafdf4565527 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 19 Jun 2022 00:16:23 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 27d445a..b668944 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-06-18 Harald Anlauf + + PR fortran/105986 + * simplify.cc (gfc_simplify_btest): Add check for POS argument. + (gfc_simplify_ibclr): Add check for POS argument. + (gfc_simplify_ibits): Add check for POS and LEN arguments. + (gfc_simplify_ibset): Add check for POS argument. + 2022-06-08 Tobias Burnus * openmp.cc (gfc_match_omp_clauses): Check also parent namespace -- cgit v1.1 From f21f17f95c0237f4f987a5fa9f1fa9c7e0db3c40 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 24 Jun 2022 22:21:39 +0200 Subject: Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813] gcc/fortran/ChangeLog: PR fortran/105813 * check.cc (gfc_check_unpack): Try to simplify MASK argument to UNPACK so that checking of the VECTOR argument can work when MASK is a variable. gcc/testsuite/ChangeLog: PR fortran/105813 * gfortran.dg/unpack_vector_1.f90: New test. --- gcc/fortran/check.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 0c2cb50..91d87a1 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -6353,6 +6353,8 @@ gfc_check_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field) if (!same_type_check (vector, 0, field, 2)) return false; + gfc_simplify_expr (mask, 0); + if (mask->expr_type == EXPR_ARRAY && gfc_array_size (vector, &vector_size)) { -- cgit v1.1 From 84c2131d2c596ddf90500b3f0ad4aa43abe650f2 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 25 Jun 2022 00:16:23 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b668944..f89e088 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-06-24 Harald Anlauf + + PR fortran/105813 + * check.cc (gfc_check_unpack): Try to simplify MASK argument to + UNPACK so that checking of the VECTOR argument can work when MASK + is a variable. + 2022-06-18 Harald Anlauf PR fortran/105986 -- cgit v1.1 From a312407bd715647f7c11b67e0a52effc94d0f15d Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 20 Jun 2022 20:59:55 +0200 Subject: Fortran: handle explicit-shape specs with constant bounds [PR105954] gcc/fortran/ChangeLog: PR fortran/105954 * decl.cc (variable_decl): Adjust upper bounds for explicit-shape specs with constant bound expressions to ensure non-negative extents. gcc/testsuite/ChangeLog: PR fortran/105954 * gfortran.dg/pr105954.f90: New test. --- gcc/fortran/decl.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index bd586e7..26ff54d 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -2775,6 +2775,18 @@ variable_decl (int elem) else gfc_free_expr (n); } + /* For an explicit-shape spec with constant bounds, ensure + that the effective upper bound is not lower than the + respective lower bound minus one. Otherwise adjust it so + that the extent is trivially derived to be zero. */ + if (as->lower[i]->expr_type == EXPR_CONSTANT + && as->upper[i]->expr_type == EXPR_CONSTANT + && as->lower[i]->ts.type == BT_INTEGER + && as->upper[i]->ts.type == BT_INTEGER + && mpz_cmp (as->upper[i]->value.integer, + as->lower[i]->value.integer) < 0) + mpz_sub_ui (as->upper[i]->value.integer, + as->lower[i]->value.integer, 1); } } } -- cgit v1.1 From ff35dbc02092fbcd3d814fcd9fe8e871c3f741fd Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 21 Jun 2022 23:20:18 +0200 Subject: Fortran: fix simplification of INDEX(str1,str2) [PR105691] gcc/fortran/ChangeLog: PR fortran/105691 * simplify.cc (gfc_simplify_index): Replace old simplification code by the equivalent of the runtime library implementation. Use HOST_WIDE_INT instead of int for string index, length variables. gcc/testsuite/ChangeLog: PR fortran/105691 * gfortran.dg/index_6.f90: New test. --- gcc/fortran/simplify.cc | 131 +++++++++++------------------------------------- 1 file changed, 29 insertions(+), 102 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index c8f2ef9..e8e3ec6 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -3515,17 +3515,15 @@ gfc_expr * gfc_simplify_index (gfc_expr *x, gfc_expr *y, gfc_expr *b, gfc_expr *kind) { gfc_expr *result; - int back, len, lensub; - int i, j, k, count, index = 0, start; + bool back; + HOST_WIDE_INT len, lensub, start, last, i, index = 0; + int k, delta; if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT || ( b != NULL && b->expr_type != EXPR_CONSTANT)) return NULL; - if (b != NULL && b->value.logical != 0) - back = 1; - else - back = 0; + back = (b != NULL && b->value.logical != 0); k = get_kind (BT_INTEGER, kind, "INDEX", gfc_default_integer_kind); if (k == -1) @@ -3542,111 +3540,40 @@ gfc_simplify_index (gfc_expr *x, gfc_expr *y, gfc_expr *b, gfc_expr *kind) return result; } - if (back == 0) + if (lensub == 0) { - if (lensub == 0) - { - mpz_set_si (result->value.integer, 1); - return result; - } - else if (lensub == 1) - { - for (i = 0; i < len; i++) - { - for (j = 0; j < lensub; j++) - { - if (y->value.character.string[j] - == x->value.character.string[i]) - { - index = i + 1; - goto done; - } - } - } - } + if (back) + index = len + 1; else - { - for (i = 0; i < len; i++) - { - for (j = 0; j < lensub; j++) - { - if (y->value.character.string[j] - == x->value.character.string[i]) - { - start = i; - count = 0; - - for (k = 0; k < lensub; k++) - { - if (y->value.character.string[k] - == x->value.character.string[k + start]) - count++; - } - - if (count == lensub) - { - index = start + 1; - goto done; - } - } - } - } - } + index = 1; + goto done; + } + if (!back) + { + last = len + 1 - lensub; + start = 0; + delta = 1; } else { - if (lensub == 0) - { - mpz_set_si (result->value.integer, len + 1); - return result; - } - else if (lensub == 1) + last = -1; + start = len - lensub; + delta = -1; + } + + for (; start != last; start += delta) + { + for (i = 0; i < lensub; i++) { - for (i = 0; i < len; i++) - { - for (j = 0; j < lensub; j++) - { - if (y->value.character.string[j] - == x->value.character.string[len - i]) - { - index = len - i + 1; - goto done; - } - } - } + if (x->value.character.string[start + i] + != y->value.character.string[i]) + break; } - else + if (i == lensub) { - for (i = 0; i < len; i++) - { - for (j = 0; j < lensub; j++) - { - if (y->value.character.string[j] - == x->value.character.string[len - i]) - { - start = len - i; - if (start <= len - lensub) - { - count = 0; - for (k = 0; k < lensub; k++) - if (y->value.character.string[k] - == x->value.character.string[k + start]) - count++; - - if (count == lensub) - { - index = start + 1; - goto done; - } - } - else - { - continue; - } - } - } - } + index = start + 1; + goto done; } } -- cgit v1.1 From b2b72757b229fe97cc5320a14a6e61008bc56882 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 27 Jun 2022 00:16:20 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f89e088..b9ea237 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,17 @@ +2022-06-26 Harald Anlauf + + PR fortran/105691 + * simplify.cc (gfc_simplify_index): Replace old simplification + code by the equivalent of the runtime library implementation. Use + HOST_WIDE_INT instead of int for string index, length variables. + +2022-06-26 Harald Anlauf + + PR fortran/105954 + * decl.cc (variable_decl): Adjust upper bounds for explicit-shape + specs with constant bound expressions to ensure non-negative + extents. + 2022-06-24 Harald Anlauf PR fortran/105813 -- cgit v1.1 From 133d0d422ebd18dbd215cfa5394aff9f938e7060 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 28 Jun 2022 13:05:28 +0200 Subject: fortran, libgfortran: Avoid using libquadmath for glibc 2.26+ As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86 (both -m32/-m64), powerpc64le, ia64 and mips support for *f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow us to avoid libquadmath for Fortran purposes on these architectures, replace *q math/complex APIs, strtof128 instead of strtoflt128 and, while strfromf128 unfortunately isn't a perfect replacement to quadmath_snprintf, it can be made to work. The advantage of this is that when configured against such glibcs (2.26 is now almost 5 years old), we can avoid linking against an extra shared library and the math support in glibc is maintained better than libquadmath. We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs instead of *q) and library change. The above mentioned problem with strfromf128 is that the strfrom* functions are severely restricted versions of snprintf. In libgfortran, we handle !isfinite differently and just use snprintf/quadmath_snprintf for %+-#.*{L,Q}{f,e} printing. strfrom* doesn't allow +, -, # modifiers and it only supports .34 or similar precision, not .* . The L/Q etc. letters are omitted. The + is there to force + sign at the start if it is positive. Workaround in the patch is to add the + at the start manually for !signbit (val). The - (left alignment instead of right) I don't understand why we need it, when minimum field width isn't specified (for strfrom* can't be specified), no padding is ever added anywhere I believe. The # is to force adding . - workaround is to search for first . or e or '\0' character, if it is '\0', just append ., if it is e, insert . before e and memmove the rest (which is just a few bytes, e, +/- and at most a few digits) one byte later. The .* case is handled by creating the format string for strfrom* by snprintf into a temporary buffer. As requested, this patch also switches from using __float128 type in libgfortran to _Float128 which is equivalent on all arches that support __float128. The change is done in a backwards compatible change, when GCC is configured against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against -lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any libquadmath APIs either. User programs and libraries when being linked by gfortran driver are linked against -lgfortran and -lquadmath, but the latter only in the --as-needed linker mode, which means it needs to be around during linking and will be linked in if there are any calls to math/complex functions with real(kind=16) or complex(kind=16) in compilation units compiled by older versions of gcc, but if either user code doesn't call those math/complex functions for the largest supported kind, or the code is recompiled by gcc with this change in, libquadmath won't be linked in. 2022-06-28 Jakub Jelinek gcc/fortran/ * gfortran.h (gfc_real_info): Add use_iec_60559 bitfield. * trans-types.h (gfc_real16_use_iec_60559): Declare. * trans-types.cc (gfc_real16_use_iec_60559): Define. (gfc_init_kinds): When building powerpc64le-linux libgfortran on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and use_iec_60559. (gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559 on glibc 2.26 or later. * trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust comment. Handle gfc_real16_use_iec_60559. (gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559. libgfortran/ * configure.ac: Check for strtof128 and strfromf128. Check for math and complex *f128 functions. Set have_iec_60559_libc_support to yes if *f128 support is around, for --enable-libquadmath-support default to "default" rather than yes if have_iec_60559_libc_support is yes. * acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test _Float128/_Complex _Float128 rather than __float128 and _Complex float __attribute__((mode(TC))). If libquadmath support is defaulted and have_iec_60559_libc_support is yes, define and subst USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional. * Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra mk-kinds-h.sh argument. * mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use _Float128/_Complex _Float128 types instead of __float128 and _Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes, use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559. * kinds-override.h: Use _Float128/_Complex _Float128 types instead of __float128 and _Complex float __attribute__((mode(TC))), if USE_IEC_60559 is defined, use f128 suffixes instead of q and define GFC_REAL_17_USE_IEC_60559. * libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is defined. (GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define for GFC_REAL_16_USE_IEC_60559 differently. * caf/single.c (convert_type): Use _Float128/_Complex _Float128 instead of __float128 and _Complex float __attribute__((mode(TC))). For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use _Complex long double instead of long double. * ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use _Float128 instead of __float128. (__issignalingf128): Change argument type to _Float128. (issignaling): Use _Float128 instead of __float128 in _Generic. * intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128 in a comment. Fix a comment typo, logn double -> long double. * intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP): Use different definitions if GFC_REAL_16_USE_IEC_60559. (_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro. (_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559. * intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128 instead of __float128 in a comment. Fix a comment typo, logn double -> long double. * intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle GFC_REAL_16_USE_IEC_60559. * intrinsics/pack_generic.c (pack): Use _Float128 instead of __float128 in a comment. Fix a comment typo, logn double -> long double. * intrinsics/unpack_generic.c (unpack1, unpack0): Likewise. * runtime/in_pack_generic.c (internal_pack): Likewise. * runtime/in_unpack_generic.c (internal_unpack): Likewise. * io/read.c (convert_real, convert_infnan): Handle GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559. * io/transfer128.c (tmp1, tmp2): Don't define if libquadmath isn't needed. * io/write_float.def (gfor_strfromf128): New function. (DTOA2Q, FDTOA2Q): Define differently if GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559. * m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559. * config.h.in: Regenerated. * configure: Regenerated. * Makefile.in: Regenerated. * generated/bessel_r16.c: Regenerated. * generated/bessel_r17.c: Regenerated. * generated/norm2_r16.c: Regenerated. * generated/norm2_r17.c: Regenerated. --- gcc/fortran/gfortran.h | 3 +++ gcc/fortran/trans-intrinsic.cc | 15 ++++++++++----- gcc/fortran/trans-types.cc | 12 ++++++++++++ gcc/fortran/trans-types.h | 4 ++++ 4 files changed, 29 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 0bac865..463d969 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2665,6 +2665,9 @@ typedef struct unsigned int c_double : 1; unsigned int c_long_double : 1; unsigned int c_float128 : 1; + /* True if for _Float128 C2X IEC 60559 *f128 APIs should be used + instead of libquadmath *q APIs. */ + unsigned int use_iec_60559 : 1; } gfc_real_info; diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index 6884060..9d91278 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -692,7 +692,7 @@ gfc_build_intrinsic_lib_fndecls (void) { /* If we have soft-float types, we create the decls for their C99-like library functions. For now, we only handle _Float128 - q-suffixed functions. */ + q-suffixed or IEC 60559 f128-suffixed functions. */ tree type, complex_type, func_1, func_2, func_cabs, func_frexp; tree func_iround, func_lround, func_llround, func_scalbn, func_cpow; @@ -739,7 +739,10 @@ gfc_build_intrinsic_lib_fndecls (void) builtin_decl_for_float_type(). The others are all constructed by gfc_get_intrinsic_lib_fndecl(). */ #define OTHER_BUILTIN(ID, NAME, TYPE, CONST) \ - quad_decls[BUILT_IN_ ## ID] = define_quad_builtin (NAME "q", func_ ## TYPE, CONST); + quad_decls[BUILT_IN_ ## ID] \ + = define_quad_builtin (gfc_real16_use_iec_60559 \ + ? NAME "f128" : NAME "q", func_ ## TYPE, \ + CONST); #include "mathbuiltins.def" @@ -751,8 +754,9 @@ gfc_build_intrinsic_lib_fndecls (void) /* There is one built-in we defined manually, because it gets called with builtin_decl_for_precision() or builtin_decl_for_float_type() even though it is not an OTHER_BUILTIN: it is SQRT. */ - quad_decls[BUILT_IN_SQRT] = define_quad_builtin ("sqrtq", func_1, true); - + quad_decls[BUILT_IN_SQRT] + = define_quad_builtin (gfc_real16_use_iec_60559 + ? "sqrtf128" : "sqrtq", func_1, true); } /* Add GCC builtin functions. */ @@ -875,7 +879,8 @@ gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr) ts->type == BT_COMPLEX ? "c" : "", m->name, "l"); else if (gfc_real_kinds[n].c_float128) snprintf (name, sizeof (name), "%s%s%s", - ts->type == BT_COMPLEX ? "c" : "", m->name, "q"); + ts->type == BT_COMPLEX ? "c" : "", m->name, + gfc_real_kinds[n].use_iec_60559 ? "f128" : "q"); else gcc_unreachable (); } diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 3742bf3..0ea7c74 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -72,6 +72,7 @@ tree gfc_float128_type_node = NULL_TREE; tree gfc_complex_float128_type_node = NULL_TREE; bool gfc_real16_is_float128 = false; +bool gfc_real16_use_iec_60559 = false; static GTY(()) tree gfc_desc_dim_type; static GTY(()) tree gfc_max_array_element_size; @@ -522,6 +523,11 @@ gfc_init_kinds (void) && (TARGET_GLIBC_MAJOR < 2 || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR < 32))) { + if (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 26) + { + gfc_real16_use_iec_60559 = true; + gfc_real_kinds[i].use_iec_60559 = 1; + } gfc_real16_is_float128 = true; gfc_real_kinds[i].c_float128 = 1; } @@ -878,6 +884,12 @@ gfc_build_real_type (gfc_real_info *info) /* TODO: see PR101835. */ info->c_float128 = 1; gfc_real16_is_float128 = true; + if (TARGET_GLIBC_MAJOR > 2 + || (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 26)) + { + info->use_iec_60559 = 1; + gfc_real16_use_iec_60559 = true; + } } if (TYPE_PRECISION (float_type_node) == mode_precision) diff --git a/gcc/fortran/trans-types.h b/gcc/fortran/trans-types.h index 09a51e6..6a360de 100644 --- a/gcc/fortran/trans-types.h +++ b/gcc/fortran/trans-types.h @@ -58,6 +58,10 @@ extern GTY(()) tree gfc_charlen_type_node; and _Float128. */ extern bool gfc_real16_is_float128; +/* True if IEC 60559 *f128 APIs should be used for _Float128 rather than + libquadmath *q APIs. */ +extern bool gfc_real16_use_iec_60559; + enum gfc_packed { PACKED_NO = 0, PACKED_PARTIAL, -- cgit v1.1 From fb29fdea9cc36f4abeb8566968b2c1bd9054c7af Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 29 Jun 2022 00:17:00 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b9ea237..79b3754d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,17 @@ +2022-06-28 Jakub Jelinek + + * gfortran.h (gfc_real_info): Add use_iec_60559 bitfield. + * trans-types.h (gfc_real16_use_iec_60559): Declare. + * trans-types.cc (gfc_real16_use_iec_60559): Define. + (gfc_init_kinds): When building powerpc64le-linux libgfortran + on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and + use_iec_60559. + (gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559 + on glibc 2.26 or later. + * trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust + comment. Handle gfc_real16_use_iec_60559. + (gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559. + 2022-06-26 Harald Anlauf PR fortran/105691 -- cgit v1.1 From b8f284d3673004dffae714b56ed663467c2a52a7 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 28 Jun 2022 22:29:28 +0200 Subject: Fortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121] gcc/fortran/ChangeLog: PR fortran/106121 * simplify.cc (gfc_simplify_extends_type_of): Do not attempt to simplify when one of the arguments is a CLASS variable that was not properly declared. gcc/testsuite/ChangeLog: PR fortran/106121 * gfortran.dg/extends_type_of_4.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/simplify.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index e8e3ec6..ab59fbc 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -3096,6 +3096,10 @@ gfc_simplify_extends_type_of (gfc_expr *a, gfc_expr *mold) if (UNLIMITED_POLY (a) || UNLIMITED_POLY (mold)) return NULL; + if ((a->ts.type == BT_CLASS && !gfc_expr_attr (a).class_ok) + || (mold->ts.type == BT_CLASS && !gfc_expr_attr (mold).class_ok)) + return NULL; + /* Return .false. if the dynamic type can never be an extension. */ if ((a->ts.type == BT_CLASS && mold->ts.type == BT_CLASS && !gfc_type_is_extension_of -- cgit v1.1 From ce600bc4643fd046301bd0b6f959546ae459875b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 30 Jun 2022 00:16:46 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 79b3754d..f349c85 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-06-29 Harald Anlauf + Steven G. Kargl + + PR fortran/106121 + * simplify.cc (gfc_simplify_extends_type_of): Do not attempt to + simplify when one of the arguments is a CLASS variable that was + not properly declared. + 2022-06-28 Jakub Jelinek * gfortran.h (gfc_real_info): Add use_iec_60559 bitfield. -- cgit v1.1 From 4c233cabbe388a6b8957c1507e129090e9267ceb Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 29 Jun 2022 21:36:17 +0200 Subject: Fortran: error recovery on invalid CLASS(), PARAMETER declarations [PR105243] gcc/fortran/ChangeLog: PR fortran/103137 PR fortran/103138 PR fortran/103693 PR fortran/105243 * decl.cc (gfc_match_data_decl): Reject CLASS entity declaration when it is given the PARAMETER attribute. gcc/testsuite/ChangeLog: PR fortran/103137 PR fortran/103138 PR fortran/103693 PR fortran/105243 * gfortran.dg/class_58.f90: Fix test. * gfortran.dg/class_73.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/decl.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 26ff54d..339f8b1 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -6262,6 +6262,14 @@ gfc_match_data_decl (void) goto cleanup; } + /* F2018:C708. */ + if (current_ts.type == BT_CLASS && current_attr.flavor == FL_PARAMETER) + { + gfc_error ("CLASS entity at %C cannot have the PARAMETER attribute"); + m = MATCH_ERROR; + goto cleanup; + } + if (current_ts.type == BT_CLASS && current_ts.u.derived->attr.unlimited_polymorphic) goto ok; -- cgit v1.1 From 976196b3332d4f56248e7a1401e5e373501598e4 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 1 Jul 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f349c85..7eac936 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-06-30 Harald Anlauf + Steven G. Kargl + + PR fortran/103137 + PR fortran/103138 + PR fortran/103693 + PR fortran/105243 + * decl.cc (gfc_match_data_decl): Reject CLASS entity declaration + when it is given the PARAMETER attribute. + 2022-06-29 Harald Anlauf Steven G. Kargl -- cgit v1.1 From 9a668532fb19e7c57aa595a26ce3f0d95f9cbb1b Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 1 Jul 2022 17:52:03 +0200 Subject: OpenMP: Handle tofrom with target enter/exit data In 5.2, a map clause can be map-entering or map-exiting, either containing 'tofrom'. The main reason for this is permit 'map(x)' with 'omp target enter/exit data', avoiding to specify 'to:/from:' explicitly. (OpenMP defaults to 'tofrom'.) gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Accept tofrom map-type modifier but use 'to' / 'from' internally. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data): Accept tofrom map-type modifier but use 'to' / 'from' internally. gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_namelist): For the map-type, also handle the always modifer and release/delete. * openmp.cc (resolve_omp_clauses): Accept tofrom map-type modifier for target enter/exit data, but use 'to' / 'from' internally. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Mark target enter/exit data with fromto as implemented. gcc/testsuite/ChangeLog: * c-c++-common/gomp/target-data-2.c: New test. * c-c++-common/gomp/target-data-3.c: New test. * gfortran.dg/gomp/target-data-1.f90: New test. * gfortran.dg/gomp/target-data-2.f90: New test. --- gcc/fortran/dump-parse-tree.cc | 5 +++++ gcc/fortran/openmp.cc | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index e3affb8..85c0b98 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1414,6 +1414,11 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) case OMP_MAP_TO: fputs ("to:", dumpfile); break; case OMP_MAP_FROM: fputs ("from:", dumpfile); break; case OMP_MAP_TOFROM: fputs ("tofrom:", dumpfile); break; + case OMP_MAP_ALWAYS_TO: fputs ("always,to:", dumpfile); break; + case OMP_MAP_ALWAYS_FROM: fputs ("always,from:", dumpfile); break; + case OMP_MAP_ALWAYS_TOFROM: fputs ("always,tofrom:", dumpfile); break; + case OMP_MAP_DELETE: fputs ("delete:", dumpfile); break; + case OMP_MAP_RELEASE: fputs ("release:", dumpfile); break; default: break; } else if (list_type == OMP_LIST_LINEAR) diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index aeb8a43..93e40f2 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7153,10 +7153,16 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, case OMP_MAP_ALWAYS_TO: case OMP_MAP_ALLOC: break; + case OMP_MAP_TOFROM: + n->u.map_op = OMP_MAP_TO; + break; + case OMP_MAP_ALWAYS_TOFROM: + n->u.map_op = OMP_MAP_ALWAYS_TO; + break; default: gfc_error ("TARGET ENTER DATA with map-type other " - "than TO, or ALLOC on MAP clause at %L", - &n->where); + "than TO, TOFROM or ALLOC on MAP clause " + "at %L", &n->where); break; } break; @@ -7168,10 +7174,16 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, case OMP_MAP_RELEASE: case OMP_MAP_DELETE: break; + case OMP_MAP_TOFROM: + n->u.map_op = OMP_MAP_FROM; + break; + case OMP_MAP_ALWAYS_TOFROM: + n->u.map_op = OMP_MAP_ALWAYS_FROM; + break; default: gfc_error ("TARGET EXIT DATA with map-type other " - "than FROM, RELEASE, or DELETE on MAP " - "clause at %L", &n->where); + "than FROM, TOFROM, RELEASE, or DELETE on " + "MAP clause at %L", &n->where); break; } break; -- cgit v1.1 From ed974488991256c50f151ccfb271e198072dfc4d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 2 Jul 2022 00:16:26 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7eac936..ea9354c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-07-01 Tobias Burnus + + * dump-parse-tree.cc (show_omp_namelist): For the map-type, + also handle the always modifer and release/delete. + * openmp.cc (resolve_omp_clauses): Accept tofrom + map-type modifier for target enter/exit data, + but use 'to' / 'from' internally. + 2022-06-30 Harald Anlauf Steven G. Kargl -- cgit v1.1 From 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 4 Jul 2022 13:51:02 +0200 Subject: OpenMP: Move omp requires checks to libgomp Handle reverse_offload, unified_address, and unified_shared_memory requirements in libgomp by saving them alongside the offload table. When the device lto1 runs, it extracts the data for mkoffload. The latter than passes the value on to GOMP_offload_register_ver. lto1 (either the host one, with -flto [+ ENABLE_OFFLOADING], or in the offload-device lto1) also does the the consistency check is done, erroring out when the 'omp requires' clause use is inconsistent. For all in-principle supported devices, if a requirement cannot be fulfilled, the device is excluded from the (supported) devices list. Currently, none of those requirements are marked as supported for any of the non-host devices. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_target_data, c_parser_omp_target_update, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Set OMP_REQUIRES_TARGET_USED. (c_parser_omp_requires): Remove sorry. gcc/ChangeLog: * config/gcn/mkoffload.cc (process_asm): Write '#include '. (process_obj): Pass omp_requires_mask to GOMP_offload_register_ver. (main): Ask lto1 to obtain omp_requires_mask and pass it on. * config/nvptx/mkoffload.cc (process, main): Likewise. * lto-cgraph.cc (omp_requires_to_name): New. (input_offload_tables): Save omp_requires_mask. (output_offload_tables): Read it, check for consistency, save value for mkoffload. * omp-low.cc (lower_omp_target): Force output_offloadtables call for OMP_REQUIRES_TARGET_USED. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_target_data, cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data, cp_parser_omp_target_update): Set OMP_REQUIRES_TARGET_USED. (cp_parser_omp_requires): Remove sorry. gcc/fortran/ChangeLog: * openmp.cc (gfc_match_omp_requires): Remove sorry. * parse.cc (decode_omp_directive): Don't regard 'declare target' as target usage for 'omp requires'; add more flags to omp_requires_mask. include/ChangeLog: * gomp-constants.h (GOMP_VERSION): Bump to 2. (GOMP_REQUIRES_UNIFIED_ADDRESS, GOMP_REQUIRES_UNIFIED_SHARED_MEMORY, GOMP_REQUIRES_REVERSE_OFFLOAD, GOMP_REQUIRES_TARGET_USED): New defines. libgomp/ChangeLog: * libgomp-plugin.h (GOMP_OFFLOAD_get_num_devices): Add omp_requires_mask arg. * plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Likewise; return -1 when device available but omp_requires_mask != 0. * plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices): Likewise. * oacc-host.c (host_get_num_devices, host_openacc_get_property): Update call. * oacc-init.c (resolve_device, acc_init_1, acc_shutdown_1, goacc_attach_host_thread_to_device, acc_get_num_devices, acc_set_device_num, get_property_any): Likewise. * target.c (omp_requires_mask): New global var. (gomp_requires_to_name): New. (GOMP_offload_register_ver): Handle passed omp_requires_mask. (gomp_target_init): Handle omp_requires_mask. * libgomp.texi (OpenMP 5.0): Update requires impl. status. (OpenMP 5.1): Add a missed item. (OpenMP 5.2): Mark linear-clause change as supported in C/C++. * testsuite/libgomp.c-c++-common/requires-1-aux.c: New test. * testsuite/libgomp.c-c++-common/requires-1.c: New test. * testsuite/libgomp.c-c++-common/requires-2-aux.c: New test. * testsuite/libgomp.c-c++-common/requires-2.c: New test. * testsuite/libgomp.c-c++-common/requires-3-aux.c: New test. * testsuite/libgomp.c-c++-common/requires-3.c: New test. * testsuite/libgomp.c-c++-common/requires-4-aux.c: New test. * testsuite/libgomp.c-c++-common/requires-4.c: New test. * testsuite/libgomp.c-c++-common/requires-5-aux.c: New test. * testsuite/libgomp.c-c++-common/requires-5.c: New test. * testsuite/libgomp.c-c++-common/requires-6.c: New test. * testsuite/libgomp.c-c++-common/requires-7-aux.c: New test. * testsuite/libgomp.c-c++-common/requires-7.c: New test. * testsuite/libgomp.fortran/requires-1-aux.f90: New test. * testsuite/libgomp.fortran/requires-1.f90: New test. liboffloadmic/ChangeLog: * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_num_devices): Return -1 when device available but omp_requires_mask != 0. gcc/testsuite/ChangeLog: * c-c++-common/gomp/requires-4.c: Update dg-*. * c-c++-common/gomp/reverse-offload-1.c: Likewise. * c-c++-common/gomp/target-device-ancestor-2.c: Likewise. * c-c++-common/gomp/target-device-ancestor-3.c: Likewise. * c-c++-common/gomp/target-device-ancestor-4.c: Likewise. * c-c++-common/gomp/target-device-ancestor-5.c: Likewise. * gfortran.dg/gomp/target-device-ancestor-3.f90: Likewise. * gfortran.dg/gomp/target-device-ancestor-4.f90: Likewise. * gfortran.dg/gomp/target-device-ancestor-5.f90: Likewise. * gfortran.dg/gomp/target-device-ancestor-2.f90: Likewise. Move post-FE checks to ... * gfortran.dg/gomp/target-device-ancestor-2a.f90: ... this new file. * gfortran.dg/gomp/requires-8.f90: Update as we don't regard 'declare target' for the 'requires' usage requirement. Co-authored-by: Chung-Lin Tang Co-authored-by: Thomas Schwinge --- gcc/fortran/openmp.cc | 4 ---- gcc/fortran/parse.cc | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 93e40f2..51b429a 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -5488,10 +5488,6 @@ gfc_match_omp_requires (void) else goto error; - if (requires_clause & ~(OMP_REQ_ATOMIC_MEM_ORDER_MASK - | OMP_REQ_DYNAMIC_ALLOCATORS)) - gfc_error_now ("Sorry, %qs clause at %L on REQUIRES directive is not " - "yet supported", clause, &old_loc); if (!gfc_omp_requires_add_clause (requires_clause, clause, &old_loc, NULL)) goto error; requires_clauses |= requires_clause; diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 7356d1b..0b4c596 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -1168,7 +1168,8 @@ decode_omp_directive (void) } switch (ret) { - case ST_OMP_DECLARE_TARGET: + /* Set omp_target_seen; exclude ST_OMP_DECLARE_TARGET. + FIXME: Get clarification, cf. OpenMP Spec Issue #3240. */ case ST_OMP_TARGET: case ST_OMP_TARGET_DATA: case ST_OMP_TARGET_ENTER_DATA: @@ -6879,11 +6880,14 @@ done: /* Fixup for external procedures and resolve 'omp requires'. */ int omp_requires; + bool omp_target_seen; omp_requires = 0; + omp_target_seen = false; for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns; gfc_current_ns = gfc_current_ns->sibling) { omp_requires |= gfc_current_ns->omp_requires; + omp_target_seen |= gfc_current_ns->omp_target_seen; gfc_check_externals (gfc_current_ns); } for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns; @@ -6908,6 +6912,22 @@ done: break; } + if (omp_target_seen) + omp_requires_mask = (enum omp_requires) (omp_requires_mask + | OMP_REQUIRES_TARGET_USED); + if (omp_requires & OMP_REQ_REVERSE_OFFLOAD) + omp_requires_mask = (enum omp_requires) (omp_requires_mask + | OMP_REQUIRES_REVERSE_OFFLOAD); + if (omp_requires & OMP_REQ_UNIFIED_ADDRESS) + omp_requires_mask = (enum omp_requires) (omp_requires_mask + | OMP_REQUIRES_UNIFIED_ADDRESS); + if (omp_requires & OMP_REQ_UNIFIED_SHARED_MEMORY) + omp_requires_mask + = (enum omp_requires) (omp_requires_mask + | OMP_REQUIRES_UNIFIED_SHARED_MEMORY); + if (omp_requires & OMP_REQ_DYNAMIC_ALLOCATORS) + omp_requires_mask = (enum omp_requires) (omp_requires_mask + | OMP_REQUIRES_DYNAMIC_ALLOCATORS); /* Do the parse tree dump. */ gfc_current_ns = flag_dump_fortran_original ? gfc_global_ns_list : NULL; -- cgit v1.1 From c3297044f0055880dd23ffbf641aa3a5860197e1 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 4 Jul 2022 21:50:23 +0200 Subject: OpenMP/Fortran: Add support for OpenMP 5.2 linear clause syntax Fortran part to C/C++ commit r13-1002-g03b71406323ddc065b1d7837d8b43b17e4b048b5 gcc/fortran/ChangeLog: * gfortran.h (gfc_omp_namelist): Update by creating 'linear' struct, move 'linear_op' as 'op' to id and add 'old_modifier' to it. * dump-parse-tree.cc (show_omp_namelist): Update accordingly. * module.cc (mio_omp_declare_simd): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses): Likewise. * openmp.cc (resolve_omp_clauses): Likewise; accept new-style 'val' modifier with do/simd. (gfc_match_omp_clauses): Handle OpenMP 5.2 linear clause syntax. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Mark linear-clause change as 'Y'. gcc/testsuite/ChangeLog: * c-c++-common/gomp/linear-4.c: New test. * gfortran.dg/gomp/linear-2.f90: New test. * gfortran.dg/gomp/linear-3.f90: New test. * gfortran.dg/gomp/linear-4.f90: New test. * gfortran.dg/gomp/linear-5.f90: New test. * gfortran.dg/gomp/linear-6.f90: New test. * gfortran.dg/gomp/linear-7.f90: New test. * gfortran.dg/gomp/linear-8.f90: New test. Co-authored-by: Jakub Jelinek --- gcc/fortran/dump-parse-tree.cc | 6 +- gcc/fortran/gfortran.h | 6 +- gcc/fortran/module.cc | 6 +- gcc/fortran/openmp.cc | 163 ++++++++++++++++++++++++++++++++++++----- gcc/fortran/trans-openmp.cc | 5 +- 5 files changed, 157 insertions(+), 29 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 85c0b98..5352008 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -1421,8 +1421,8 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) case OMP_MAP_RELEASE: fputs ("release:", dumpfile); break; default: break; } - else if (list_type == OMP_LIST_LINEAR) - switch (n->u.linear_op) + else if (list_type == OMP_LIST_LINEAR && n->u.linear.old_modifier) + switch (n->u.linear.op) { case OMP_LINEAR_REF: fputs ("ref(", dumpfile); break; case OMP_LINEAR_VAL: fputs ("val(", dumpfile); break; @@ -1430,7 +1430,7 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n) default: break; } fprintf (dumpfile, "%s", n->sym ? n->sym->name : "omp_all_memory"); - if (list_type == OMP_LIST_LINEAR && n->u.linear_op != OMP_LINEAR_DEFAULT) + if (list_type == OMP_LIST_LINEAR && n->u.linear.op != OMP_LINEAR_DEFAULT) fputc (')', dumpfile); if (n->expr) { diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 463d969..696aadd 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1345,7 +1345,11 @@ typedef struct gfc_omp_namelist gfc_omp_reduction_op reduction_op; gfc_omp_depend_op depend_op; gfc_omp_map_op map_op; - gfc_omp_linear_op linear_op; + struct + { + ENUM_BITFIELD (gfc_omp_linear_op) op:4; + bool old_modifier; + } linear; struct gfc_common_head *common; bool lastprivate_conditional; } u; diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 85aa153..5ddabdc 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -4383,10 +4383,10 @@ mio_omp_declare_simd (gfc_namespace *ns, gfc_omp_declare_simd **odsp) } for (n = ods->clauses->lists[OMP_LIST_LINEAR]; n; n = n->next) { - if (n->u.linear_op == OMP_LINEAR_DEFAULT) + if (n->u.linear.op == OMP_LINEAR_DEFAULT) mio_name (4, omp_declare_simd_clauses); else - mio_name (32 + n->u.linear_op, omp_declare_simd_clauses); + mio_name (32 + n->u.linear.op, omp_declare_simd_clauses); mio_symbol_ref (&n->sym); mio_expr (&n->expr); } @@ -4438,7 +4438,7 @@ mio_omp_declare_simd (gfc_namespace *ns, gfc_omp_declare_simd **odsp) case 34: case 35: *ptrs[1] = n = gfc_get_omp_namelist (); - n->u.linear_op = (enum gfc_omp_linear_op) (t - 32); + n->u.linear.op = (enum gfc_omp_linear_op) (t - 32); t = 4; goto finish_namelist; } diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 51b429a..bd4ff25 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -2324,6 +2324,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, if ((mask & OMP_CLAUSE_LINEAR) && gfc_match ("linear (") == MATCH_YES) { + bool old_linear_modifier = false; gfc_omp_linear_op linear_op = OMP_LINEAR_DEFAULT; gfc_expr *step = NULL; @@ -2331,17 +2332,26 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, &c->lists[OMP_LIST_LINEAR], false, NULL, &head) == MATCH_YES) - linear_op = OMP_LINEAR_REF; + { + linear_op = OMP_LINEAR_REF; + old_linear_modifier = true; + } else if (gfc_match_omp_variable_list (" val (", &c->lists[OMP_LIST_LINEAR], false, NULL, &head) == MATCH_YES) - linear_op = OMP_LINEAR_VAL; + { + linear_op = OMP_LINEAR_VAL; + old_linear_modifier = true; + } else if (gfc_match_omp_variable_list (" uval (", &c->lists[OMP_LIST_LINEAR], false, NULL, &head) == MATCH_YES) - linear_op = OMP_LINEAR_UVAL; + { + linear_op = OMP_LINEAR_UVAL; + old_linear_modifier = true; + } else if (gfc_match_omp_variable_list ("", &c->lists[OMP_LIST_LINEAR], false, &end_colon, &head) @@ -2364,14 +2374,114 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, break; } } - if (end_colon && gfc_match (" %e )", &step) != MATCH_YES) + gfc_gobble_whitespace (); + if (old_linear_modifier && end_colon) { - gfc_free_omp_namelist (*head, false); - gfc_current_locus = old_loc; - *head = NULL; - break; + if (gfc_match (" %e )", &step) != MATCH_YES) + { + gfc_free_omp_namelist (*head, false); + gfc_current_locus = old_loc; + *head = NULL; + goto error; + } } - else if (!end_colon) + else if (end_colon) + { + bool has_error = false; + bool has_modifiers = false; + bool has_step = false; + bool duplicate_step = false; + bool duplicate_mod = false; + while (true) + { + old_loc = gfc_current_locus; + bool close_paren = gfc_match ("val )") == MATCH_YES; + if (close_paren || gfc_match ("val , ") == MATCH_YES) + { + if (linear_op != OMP_LINEAR_DEFAULT) + { + duplicate_mod = true; + break; + } + linear_op = OMP_LINEAR_VAL; + has_modifiers = true; + if (close_paren) + break; + continue; + } + close_paren = gfc_match ("uval )") == MATCH_YES; + if (close_paren || gfc_match ("uval , ") == MATCH_YES) + { + if (linear_op != OMP_LINEAR_DEFAULT) + { + duplicate_mod = true; + break; + } + linear_op = OMP_LINEAR_UVAL; + has_modifiers = true; + if (close_paren) + break; + continue; + } + close_paren = gfc_match ("ref )") == MATCH_YES; + if (close_paren || gfc_match ("ref , ") == MATCH_YES) + { + if (linear_op != OMP_LINEAR_DEFAULT) + { + duplicate_mod = true; + break; + } + linear_op = OMP_LINEAR_REF; + has_modifiers = true; + if (close_paren) + break; + continue; + } + close_paren = (gfc_match ("step ( %e ) )", &step) + == MATCH_YES); + if (close_paren + || gfc_match ("step ( %e ) , ", &step) == MATCH_YES) + { + if (has_step) + { + duplicate_step = true; + break; + } + has_modifiers = has_step = true; + if (close_paren) + break; + continue; + } + if (!has_modifiers + && gfc_match ("%e )", &step) == MATCH_YES) + { + if ((step->expr_type == EXPR_FUNCTION + || step->expr_type == EXPR_VARIABLE) + && strcmp (step->symtree->name, "step") == 0) + { + gfc_current_locus = old_loc; + gfc_match ("step ("); + has_error = true; + } + break; + } + has_error = true; + break; + } + if (duplicate_mod || duplicate_step) + { + gfc_error ("Multiple %qs modifiers specified at %C", + duplicate_mod ? "linear" : "step"); + has_error = true; + } + if (has_error) + { + gfc_free_omp_namelist (*head, false); + *head = NULL; + goto error; + } + } + else { step = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind, @@ -2379,9 +2489,12 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, mpz_set_si (step->value.integer, 1); } (*head)->expr = step; - if (linear_op != OMP_LINEAR_DEFAULT) + if (linear_op != OMP_LINEAR_DEFAULT || old_linear_modifier) for (gfc_omp_namelist *n = *head; n; n = n->next) - n->u.linear_op = linear_op; + { + n->u.linear.op = linear_op; + n->u.linear.old_modifier = old_linear_modifier; + } continue; } if ((mask & OMP_CLAUSE_LINK) @@ -7439,28 +7552,38 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, break; case OMP_LIST_LINEAR: if (code - && n->u.linear_op != OMP_LINEAR_DEFAULT - && n->u.linear_op != linear_op) + && n->u.linear.op != OMP_LINEAR_DEFAULT + && n->u.linear.op != linear_op) { - gfc_error ("LINEAR clause modifier used on DO or SIMD" - " construct at %L", &n->where); - linear_op = n->u.linear_op; + if (n->u.linear.old_modifier) + { + gfc_error ("LINEAR clause modifier used on DO or " + "SIMD construct at %L", &n->where); + linear_op = n->u.linear.op; + } + else if (n->u.linear.op != OMP_LINEAR_VAL) + { + gfc_error ("LINEAR clause modifier other than VAL " + "used on DO or SIMD construct at %L", + &n->where); + linear_op = n->u.linear.op; + } } else if (omp_clauses->orderedc) gfc_error ("LINEAR clause specified together with " "ORDERED clause with argument at %L", &n->where); - else if (n->u.linear_op != OMP_LINEAR_REF + else if (n->u.linear.op != OMP_LINEAR_REF && n->sym->ts.type != BT_INTEGER) gfc_error ("LINEAR variable %qs must be INTEGER " "at %L", n->sym->name, &n->where); - else if ((n->u.linear_op == OMP_LINEAR_REF - || n->u.linear_op == OMP_LINEAR_UVAL) + else if ((n->u.linear.op == OMP_LINEAR_REF + || n->u.linear.op == OMP_LINEAR_UVAL) && n->sym->attr.value) gfc_error ("LINEAR dummy argument %qs with VALUE " "attribute with %s modifier at %L", n->sym->name, - n->u.linear_op == OMP_LINEAR_REF + n->u.linear.op == OMP_LINEAR_REF ? "REF" : "UVAL", &n->where); else if (n->expr) { diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index c6a584d..de27ed5 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -2751,7 +2751,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, OMP_CLAUSE_LINEAR); OMP_CLAUSE_DECL (node) = t; omp_clause_linear_kind kind; - switch (n->u.linear_op) + switch (n->u.linear.op) { case OMP_LINEAR_DEFAULT: kind = OMP_CLAUSE_LINEAR_DEFAULT; @@ -2769,7 +2769,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, gcc_unreachable (); } OMP_CLAUSE_LINEAR_KIND (node) = kind; - OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (node) = 1; + OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (node) + = n->u.linear.old_modifier; if (last_step_expr && last_step == NULL_TREE) { if (!declare_simd) -- cgit v1.1 From 8467574d8daac47e0cf5b694f6c012aad8d630a6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 5 Jul 2022 00:16:36 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ea9354c..9bde368 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,24 @@ +2022-07-04 Tobias Burnus + Jakub Jelinek + + * gfortran.h (gfc_omp_namelist): Update by creating 'linear' struct, + move 'linear_op' as 'op' to id and add 'old_modifier' to it. + * dump-parse-tree.cc (show_omp_namelist): Update accordingly. + * module.cc (mio_omp_declare_simd): Likewise. + * trans-openmp.cc (gfc_trans_omp_clauses): Likewise. + * openmp.cc (resolve_omp_clauses): Likewise; accept new-style + 'val' modifier with do/simd. + (gfc_match_omp_clauses): Handle OpenMP 5.2 linear clause syntax. + +2022-07-04 Tobias Burnus + Chung-Lin Tang + Thomas Schwinge + + * openmp.cc (gfc_match_omp_requires): Remove sorry. + * parse.cc (decode_omp_directive): Don't regard 'declare target' + as target usage for 'omp requires'; add more flags to + omp_requires_mask. + 2022-07-01 Tobias Burnus * dump-parse-tree.cc (show_omp_namelist): For the map-type, -- cgit v1.1 From 6e9d5dfc2911e3acc6039ebfe3837e7ba4be197f Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 5 Jul 2022 22:20:05 +0200 Subject: Fortran: error recovery simplifying PACK with invalid arguments [PR106049] gcc/fortran/ChangeLog: PR fortran/106049 * simplify.cc (is_constant_array_expr): A non-zero-sized constant array shall have a non-empty constructor. When the constructor is empty or missing, treat as non-constant. gcc/testsuite/ChangeLog: PR fortran/106049 * gfortran.dg/pack_simplify_1.f90: New test. --- gcc/fortran/simplify.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index ab59fbc..fb72599 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -233,6 +233,18 @@ is_constant_array_expr (gfc_expr *e) if (e->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e)) return false; + /* A non-zero-sized constant array shall have a non-empty constructor. */ + if (e->rank > 0 && e->shape != NULL && e->value.constructor == NULL) + { + mpz_init_set_ui (size, 1); + for (int j = 0; j < e->rank; j++) + mpz_mul (size, size, e->shape[j]); + bool not_size0 = (mpz_cmp_si (size, 0) != 0); + mpz_clear (size); + if (not_size0) + return false; + } + for (c = gfc_constructor_first (e->value.constructor); c; c = gfc_constructor_next (c)) if (c->expr->expr_type != EXPR_CONSTANT -- cgit v1.1 From 43997608a0887341160d50f83ad2d0159b387aae Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 13 Jul 2022 00:16:33 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9bde368..f13ce09 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-07-12 Harald Anlauf + + PR fortran/106049 + * simplify.cc (is_constant_array_expr): A non-zero-sized constant + array shall have a non-empty constructor. When the constructor is + empty or missing, treat as non-constant. + 2022-07-04 Tobias Burnus Jakub Jelinek -- cgit v1.1 From 748f8a8b145dde59c7b63aa68b5a59515b7efc49 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 14 Jul 2022 22:24:55 +0200 Subject: Fortran: error recovery for bad initializers of implied-shape arrays [PR106209] gcc/fortran/ChangeLog: PR fortran/106209 * decl.cc (add_init_expr_to_sym): Handle bad initializers for implied-shape arrays. gcc/testsuite/ChangeLog: PR fortran/106209 * gfortran.dg/pr106209.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/decl.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 339f8b1..b640051 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -2129,10 +2129,21 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) /* The shape may be NULL for EXPR_ARRAY, set it. */ if (init->shape == NULL) { - gcc_assert (init->expr_type == EXPR_ARRAY); + if (init->expr_type != EXPR_ARRAY) + { + gfc_error ("Bad shape of initializer at %L", &init->where); + return false; + } + init->shape = gfc_get_shape (1); if (!gfc_array_size (init, &init->shape[0])) - gfc_internal_error ("gfc_array_size failed"); + { + gfc_error ("Cannot determine shape of initializer at %L", + &init->where); + free (init->shape); + init->shape = NULL; + return false; + } } for (dim = 0; dim < sym->as->rank; ++dim) -- cgit v1.1 From e0e07bc7624776f9369cf0c73e2a3cf42cd2ce97 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 15 Jul 2022 00:16:22 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f13ce09..f02b65f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2022-07-14 Harald Anlauf + Steven G. Kargl + + PR fortran/106209 + * decl.cc (add_init_expr_to_sym): Handle bad initializers for + implied-shape arrays. + 2022-07-12 Harald Anlauf PR fortran/106049 -- cgit v1.1 From 517fb1a78102df43f052c6934c27dd51d786aff7 Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Fri, 15 Jul 2022 22:07:15 +0200 Subject: Fortran: do not generate conflicting results under -ff2c [PR104313] gcc/fortran/ChangeLog: PR fortran/104313 * trans-decl.cc (gfc_generate_return): Do not generate conflicting fake results for functions with no result variable under -ff2c. gcc/testsuite/ChangeLog: PR fortran/104313 * gfortran.dg/pr104313.f: New test. --- gcc/fortran/trans-decl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 6493cc2..908a4c6 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -6474,7 +6474,7 @@ gfc_generate_return (void) NULL_TREE, and a 'return' is generated without a variable. The following generates a 'return __result_XXX' where XXX is the function name. */ - if (sym == sym->result && sym->attr.function) + if (sym == sym->result && sym->attr.function && !flag_f2c) { result = gfc_get_fake_result_decl (sym, 0); result = fold_build2_loc (input_location, MODIFY_EXPR, -- cgit v1.1 From bdc7b765f8728cbb769fe1eeef773eda15578aee Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 16 Jul 2022 00:16:30 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f02b65f..cfe1e6d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-07-15 Steve Kargl + + PR fortran/104313 + * trans-decl.cc (gfc_generate_return): Do not generate conflicting + fake results for functions with no result variable under -ff2c. + 2022-07-14 Harald Anlauf Steven G. Kargl -- cgit v1.1 From f838d15641d256e21ffc126c3277b290ed743928 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 18 Jul 2022 22:34:53 +0200 Subject: Fortran: error recovery on invalid array reference of non-array [PR103590] gcc/fortran/ChangeLog: PR fortran/103590 * resolve.cc (find_array_spec): Change function result to bool to enable error recovery. Generate error message for invalid array reference of non-array entity instead of an internal error. (gfc_resolve_ref): Use function result from find_array_spec for error recovery. gcc/testsuite/ChangeLog: PR fortran/103590 * gfortran.dg/associate_54.f90: Adjust. * gfortran.dg/associate_59.f90: New test. --- gcc/fortran/resolve.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 2ebf076..ca11475 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -4976,7 +4976,7 @@ gfc_resolve_dim_arg (gfc_expr *dim) static void resolve_assoc_var (gfc_symbol* sym, bool resolve_target); -static void +static bool find_array_spec (gfc_expr *e) { gfc_array_spec *as; @@ -5004,7 +5004,11 @@ find_array_spec (gfc_expr *e) { case REF_ARRAY: if (as == NULL) - gfc_internal_error ("find_array_spec(): Missing spec"); + { + gfc_error ("Invalid array reference of a non-array entity at %L", + &ref->u.ar.where); + return false; + } ref->u.ar.as = as; as = NULL; @@ -5028,6 +5032,8 @@ find_array_spec (gfc_expr *e) if (as != NULL) gfc_internal_error ("find_array_spec(): unused as(2)"); + + return true; } @@ -5346,7 +5352,8 @@ gfc_resolve_ref (gfc_expr *expr) for (ref = expr->ref; ref; ref = ref->next) if (ref->type == REF_ARRAY && ref->u.ar.as == NULL) { - find_array_spec (expr); + if (!find_array_spec (expr)) + return false; break; } -- cgit v1.1 From 7c0c10db24f5c7f8c30810699fb0aff3c900d41a Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 20 Jul 2022 00:16:34 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index cfe1e6d..9296258 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2022-07-19 Harald Anlauf + + PR fortran/103590 + * resolve.cc (find_array_spec): Change function result to bool to + enable error recovery. Generate error message for invalid array + reference of non-array entity instead of an internal error. + (gfc_resolve_ref): Use function result from find_array_spec for + error recovery. + 2022-07-15 Steve Kargl PR fortran/104313 -- cgit v1.1 From 26bbe78f77f73bb66af1ac13d0deec888a3c6510 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 20 Jul 2022 20:40:23 +0200 Subject: Fortran: fix parsing of omp task affinity iterator clause [PR101330] gcc/fortran/ChangeLog: PR fortran/101330 * openmp.cc (gfc_match_iterator): Remove left-over code from development that could lead to a crash on invalid input. gcc/testsuite/ChangeLog: PR fortran/101330 * gfortran.dg/gomp/affinity-clause-7.f90: New test. --- gcc/fortran/openmp.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index bd4ff25..df9cdf4 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -1181,7 +1181,6 @@ gfc_match_iterator (gfc_namespace **ns, bool permit_var) } if (':' == gfc_peek_ascii_char ()) { - step = gfc_get_expr (); if (gfc_match (": %e ", &step) != MATCH_YES) { gfc_free_expr (begin); -- cgit v1.1 From e7dfd8744502d6588483ec63ab7f81c2f5940267 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 21 Jul 2022 00:16:34 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9296258..1109cd2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-07-20 Harald Anlauf + + PR fortran/101330 + * openmp.cc (gfc_match_iterator): Remove left-over code from + development that could lead to a crash on invalid input. + 2022-07-19 Harald Anlauf PR fortran/103590 -- cgit v1.1 From 24eae97625e9423e7344f6d7eb6bc2435a62fffd Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 21 Jul 2022 16:11:23 +0200 Subject: docs: remove trailing dots for 2 Fortran fns gcc/fortran/ChangeLog: * intrinsic.texi: Remove trailing dots for 2 Fortran fns. --- gcc/fortran/intrinsic.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index e3cd827..55f53fc 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -316,7 +316,7 @@ Some basic guidelines for editing this document: * @code{TRANSFER}: TRANSFER, Transfer bit patterns * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two * @code{TRIM}: TRIM, Remove trailing blank characters of a string -* @code{TTYNAM}: TTYNAM, Get the name of a terminal device. +* @code{TTYNAM}: TTYNAM, Get the name of a terminal device * @code{UBOUND}: UBOUND, Upper dimension bounds of an array * @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array * @code{UMASK}: UMASK, Set the file creation mask @@ -8750,7 +8750,7 @@ END PROGRAM @node ISATTY -@section @code{ISATTY} --- Whether a unit is a terminal device. +@section @code{ISATTY} --- Whether a unit is a terminal device @fnindex ISATTY @cindex system, terminal @@ -14613,7 +14613,7 @@ END PROGRAM @node TTYNAM -@section @code{TTYNAM} --- Get the name of a terminal device. +@section @code{TTYNAM} --- Get the name of a terminal device @fnindex TTYNAM @cindex system, terminal -- cgit v1.1 From bbb9c03005cdab2275ef0c6448310ae9273a2ed5 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 22 Jul 2022 00:16:33 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1109cd2..2404d85 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2022-07-21 Martin Liska + + * intrinsic.texi: Remove trailing dots for 2 Fortran fns. + 2022-07-20 Harald Anlauf PR fortran/101330 -- cgit v1.1 From 600956c81c784f4a0cc9d10f6e03e01847afd961 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 25 Jul 2022 22:29:50 +0200 Subject: Fortran: error recovery from calculation of storage size of a symbol [PR103504] gcc/fortran/ChangeLog: PR fortran/103504 * interface.cc (get_sym_storage_size): Array bounds and character length can only be of integer type. gcc/testsuite/ChangeLog: PR fortran/103504 * gfortran.dg/pr103504.f90: New test. --- gcc/fortran/interface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 7ed6e13..71eec78 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -2792,7 +2792,8 @@ get_sym_storage_size (gfc_symbol *sym) if (sym->ts.type == BT_CHARACTER) { if (sym->ts.u.cl && sym->ts.u.cl->length - && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT) + && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT + && sym->ts.u.cl->length->ts.type == BT_INTEGER) strlen = mpz_get_ui (sym->ts.u.cl->length->value.integer); else return 0; @@ -2809,7 +2810,9 @@ get_sym_storage_size (gfc_symbol *sym) for (i = 0; i < sym->as->rank; i++) { if (sym->as->upper[i]->expr_type != EXPR_CONSTANT - || sym->as->lower[i]->expr_type != EXPR_CONSTANT) + || sym->as->lower[i]->expr_type != EXPR_CONSTANT + || sym->as->upper[i]->ts.type != BT_INTEGER + || sym->as->lower[i]->ts.type != BT_INTEGER) return 0; elements *= mpz_get_si (sym->as->upper[i]->value.integer) -- cgit v1.1 From fd96c4b51a733f72fa567a96c253fb3ddf11bd2a Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 27 Jul 2022 00:16:58 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2404d85..acd60ff 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-07-26 Harald Anlauf + + PR fortran/103504 + * interface.cc (get_sym_storage_size): Array bounds and character + length can only be of integer type. + 2022-07-21 Martin Liska * intrinsic.texi: Remove trailing dots for 2 Fortran fns. -- cgit v1.1 From a6afbe5e9528e9ec3f0426d9791bd28e6e584d82 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 29 Jul 2022 12:36:07 +0200 Subject: OpenMP/Fortran: Permit assumed-size arrays in uniform clause gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays in uniform clause. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-simd-3.f90: New test. --- gcc/fortran/openmp.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index df9cdf4..a7eb6c3 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7386,7 +7386,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, || code->op == EXEC_OACC_PARALLEL || code->op == EXEC_OACC_SERIAL)) check_array_not_assumed (n->sym, n->where, name); - else if (n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) + else if (list != OMP_LIST_UNIFORM + && n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) gfc_error ("Assumed size array %qs in %s clause at %L", n->sym->name, name, &n->where); if (n->sym->attr.in_namelist && !is_reduction) -- cgit v1.1 From b2bf04739fb4170d24a3a83327fdf2b5d1a88520 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 30 Jul 2022 00:16:30 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index acd60ff..0473563 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-07-29 Tobias Burnus + + * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays + in uniform clause. + 2022-07-26 Harald Anlauf PR fortran/103504 -- cgit v1.1 From 0110cfd5449bae3a772f45ea2e4c5dab5b7a8ccd Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 27 Jul 2022 21:34:22 +0200 Subject: Fortran: fix invalid rank error in ASSOCIATED when rank is remapped [PR77652] gcc/fortran/ChangeLog: PR fortran/77652 * check.cc (gfc_check_associated): Make the rank check of POINTER vs. TARGET match the allowed forms of pointer assignment for the selected Fortran standard. gcc/testsuite/ChangeLog: PR fortran/77652 * gfortran.dg/associated_target_9a.f90: New test. * gfortran.dg/associated_target_9b.f90: New test. --- gcc/fortran/check.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 91d87a1..1da0b3c 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -1502,8 +1502,27 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *target) t = false; /* F2018 C838 explicitly allows an assumed-rank variable as the first argument of intrinsic inquiry functions. */ - if (pointer->rank != -1 && !rank_check (target, 0, pointer->rank)) - t = false; + if (pointer->rank != -1 && pointer->rank != target->rank) + { + if (pointer->rank == 0 || target->rank == 0) + { + /* There exists no valid pointer assignment using bounds + remapping for scalar => array or array => scalar. */ + if (!rank_check (target, 0, pointer->rank)) + t = false; + } + else if (target->rank != 1) + { + if (!gfc_notify_std (GFC_STD_F2008, "Rank remapping target is not " + "rank 1 at %L", &target->where)) + t = false; + } + else if ((gfc_option.allow_std & GFC_STD_F2003) == 0) + { + if (!rank_check (target, 0, pointer->rank)) + t = false; + } + } if (target->rank > 0 && target->ref) { for (i = 0; i < target->rank; i++) -- cgit v1.1 From d325e7048c85e13f12ea79aebf9623eddc7ffcaf Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 28 Jul 2022 22:07:02 +0200 Subject: Fortran: detect blanks within literal constants in free-form mode [PR92805] gcc/fortran/ChangeLog: PR fortran/92805 * match.cc (gfc_match_small_literal_int): Make gobbling of leading whitespace optional. (gfc_match_name): Likewise. (gfc_match_char): Likewise. * match.h (gfc_match_small_literal_int): Adjust prototype. (gfc_match_name): Likewise. (gfc_match_char): Likewise. * primary.cc (match_kind_param): Match small literal int or name without gobbling whitespace. (get_kind): Do not skip over blanks. (match_string_constant): Likewise. gcc/testsuite/ChangeLog: PR fortran/92805 * gfortran.dg/literal_constants.f: New test. * gfortran.dg/literal_constants.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/match.cc | 24 +++++++++++++++--------- gcc/fortran/match.h | 6 +++--- gcc/fortran/primary.cc | 14 +++----------- 3 files changed, 21 insertions(+), 23 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 1aa3053..8b8b6e7 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -454,10 +454,11 @@ gfc_match_eos (void) /* Match a literal integer on the input, setting the value on MATCH_YES. Literal ints occur in kind-parameters as well as old-style character length specifications. If cnt is non-NULL it - will be set to the number of digits. */ + will be set to the number of digits. + When gobble_ws is false, do not skip over leading blanks. */ match -gfc_match_small_literal_int (int *value, int *cnt) +gfc_match_small_literal_int (int *value, int *cnt, bool gobble_ws) { locus old_loc; char c; @@ -466,7 +467,8 @@ gfc_match_small_literal_int (int *value, int *cnt) old_loc = gfc_current_locus; *value = -1; - gfc_gobble_whitespace (); + if (gobble_ws) + gfc_gobble_whitespace (); c = gfc_next_ascii_char (); if (cnt) *cnt = 0; @@ -608,17 +610,19 @@ gfc_match_label (void) /* See if the current input looks like a name of some sort. Modifies the passed buffer which must be GFC_MAX_SYMBOL_LEN+1 bytes long. Note that options.cc restricts max_identifier_length to not more - than GFC_MAX_SYMBOL_LEN. */ + than GFC_MAX_SYMBOL_LEN. + When gobble_ws is false, do not skip over leading blanks. */ match -gfc_match_name (char *buffer) +gfc_match_name (char *buffer, bool gobble_ws) { locus old_loc; int i; char c; old_loc = gfc_current_locus; - gfc_gobble_whitespace (); + if (gobble_ws) + gfc_gobble_whitespace (); c = gfc_next_ascii_char (); if (!(ISALPHA (c) || (c == '_' && flag_allow_leading_underscore))) @@ -1053,15 +1057,17 @@ cleanup: /* Tries to match the next non-whitespace character on the input. - This subroutine does not return MATCH_ERROR. */ + This subroutine does not return MATCH_ERROR. + When gobble_ws is false, do not skip over leading blanks. */ match -gfc_match_char (char c) +gfc_match_char (char c, bool gobble_ws) { locus where; where = gfc_current_locus; - gfc_gobble_whitespace (); + if (gobble_ws) + gfc_gobble_whitespace (); if (gfc_next_ascii_char () == c) return MATCH_YES; diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h index 495c93e..1f53e0c 100644 --- a/gcc/fortran/match.h +++ b/gcc/fortran/match.h @@ -45,14 +45,14 @@ extern gfc_access gfc_typebound_default_access; match gfc_match_special_char (gfc_char_t *); match gfc_match_space (void); match gfc_match_eos (void); -match gfc_match_small_literal_int (int *, int *); +match gfc_match_small_literal_int (int *, int *, bool = true); match gfc_match_st_label (gfc_st_label **); match gfc_match_small_int (int *); -match gfc_match_name (char *); +match gfc_match_name (char *, bool = true); match gfc_match_symbol (gfc_symbol **, int); match gfc_match_sym_tree (gfc_symtree **, int); match gfc_match_intrinsic_op (gfc_intrinsic_op *); -match gfc_match_char (char); +match gfc_match_char (char, bool = true); match gfc_match (const char *, ...); match gfc_match_iterator (gfc_iterator *, int); match gfc_match_parens (void); diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 3f01f67..19f2e78 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -45,11 +45,11 @@ match_kind_param (int *kind, int *is_iso_c) *is_iso_c = 0; - m = gfc_match_small_literal_int (kind, NULL); + m = gfc_match_small_literal_int (kind, NULL, false); if (m != MATCH_NO) return m; - m = gfc_match_name (name); + m = gfc_match_name (name, false); if (m != MATCH_YES) return m; @@ -95,7 +95,7 @@ get_kind (int *is_iso_c) *is_iso_c = 0; - if (gfc_match_char ('_') != MATCH_YES) + if (gfc_match_char ('_', false) != MATCH_YES) return -2; m = match_kind_param (&kind, is_iso_c); @@ -1074,17 +1074,9 @@ match_string_constant (gfc_expr **result) c = gfc_next_char (); } - if (c == ' ') - { - gfc_gobble_whitespace (); - c = gfc_next_char (); - } - if (c != '_') goto no_match; - gfc_gobble_whitespace (); - c = gfc_next_char (); if (c != '\'' && c != '"') goto no_match; -- cgit v1.1 From 4a7274ddc4970c1ad011343ed285d6219dffa396 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 1 Aug 2022 00:16:31 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0473563..74968c9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,26 @@ +2022-07-31 Harald Anlauf + Steven G. Kargl + + PR fortran/92805 + * match.cc (gfc_match_small_literal_int): Make gobbling of leading + whitespace optional. + (gfc_match_name): Likewise. + (gfc_match_char): Likewise. + * match.h (gfc_match_small_literal_int): Adjust prototype. + (gfc_match_name): Likewise. + (gfc_match_char): Likewise. + * primary.cc (match_kind_param): Match small literal int or name + without gobbling whitespace. + (get_kind): Do not skip over blanks. + (match_string_constant): Likewise. + +2022-07-31 Harald Anlauf + + PR fortran/77652 + * check.cc (gfc_check_associated): Make the rank check of POINTER + vs. TARGET match the allowed forms of pointer assignment for the + selected Fortran standard. + 2022-07-29 Tobias Burnus * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays -- cgit v1.1 From 1c596391e150a6b0c55960c1c1cf1da76ea78230 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 16 Aug 2022 10:04:36 +0200 Subject: docs: fix link destination gcc/fortran/ChangeLog: * gfortran.texi: Fix link destination to a valid URL. --- gcc/fortran/gfortran.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index d34e0b5..59d673b 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -246,7 +246,7 @@ including OpenMP and OpenACC support for parallel programming. The GNU Fortran compiler passes the @uref{http://www.fortran-2000.com/ArnaudRecipes/fcvs21_f95.html, NIST Fortran 77 Test Suite}, and produces acceptable results on the -@uref{https://www.netlib.org/lapack/faq.html#1.21, LAPACK Test Suite}. +@uref{https://www.netlib.org/lapack/faq.html, LAPACK Test Suite}. It also provides respectable performance on the @uref{https://polyhedron.com/?page_id=175, Polyhedron Fortran compiler benchmarks} and the @@ -441,7 +441,7 @@ found in the following sections of the documentation. Additionally, the GNU Fortran compilers supports the OpenMP specification (version 4.5 and partial support of the features of the 5.0 version, -@url{https://openmp.org/@/openmp-specifications/}). +@url{https://openmp.org/@/specifications/}). There also is support for the OpenACC specification (targeting version 2.6, @uref{https://www.openacc.org/}). See @uref{https://gcc.gnu.org/wiki/OpenACC} for more information. @@ -1806,7 +1806,7 @@ It consists of a set of compiler directives, library routines, and environment variables that influence run-time behavior. GNU Fortran strives to be compatible to the -@uref{https://openmp.org/wp/openmp-specifications/, +@uref{https://openmp.org/specifications/, OpenMP Application Program Interface v4.5}. To enable the processing of the OpenMP directive @code{!$omp} in -- cgit v1.1 From 47a61e65148c6f1c237638144eb72ed5afd86387 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 17 Aug 2022 00:17:17 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 74968c9..cd7be0f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2022-08-16 Martin Liska + + * gfortran.texi: Fix link destination to a valid URL. + 2022-07-31 Harald Anlauf Steven G. Kargl -- cgit v1.1 From 1513512ec7d0751cba30c9c8804f2be462acfb9b Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 17 Aug 2022 16:19:58 +0200 Subject: Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566] gcc/fortran/ChangeLog: PR fortran/106566 * openmp.cc (gfc_match_omp_clauses): Fix setting linear-step value to 1 when not specified. (gfc_match_omp_declare_simd): Accept module procedures. gcc/testsuite/ChangeLog: PR fortran/106566 * gfortran.dg/gomp/declare-simd-4.f90: New test. * gfortran.dg/gomp/declare-simd-5.f90: New test. * gfortran.dg/gomp/declare-simd-6.f90: New test. --- gcc/fortran/openmp.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index a7eb6c3..5949077 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -2480,7 +2480,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, goto error; } } - else + if (step == NULL) { step = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind, @@ -4213,9 +4213,13 @@ gfc_match_omp_declare_simd (void) gfc_omp_declare_simd *ods; bool needs_space = false; - switch (gfc_match (" ( %s ) ", &proc_name)) + switch (gfc_match (" ( ")) { - case MATCH_YES: break; + case MATCH_YES: + if (gfc_match_symbol (&proc_name, /* host assoc = */ true) != MATCH_YES + || gfc_match (" ) ") != MATCH_YES) + return MATCH_ERROR; + break; case MATCH_NO: proc_name = NULL; needs_space = true; break; case MATCH_ERROR: return MATCH_ERROR; } -- cgit v1.1 From 745be54bd6634fe63d6be83615e264c83d2ae9f9 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 17 Aug 2022 17:00:33 +0200 Subject: fortran: Add -static-libquadmath support [PR46539] The following patch is a revival of the https://gcc.gnu.org/legacy-ml/gcc-patches/2014-10/msg00771.html patch. While trunk configured against recent glibc and with linker --as-needed support doesn't really need to link against -lquadmath anymore, there are still other targets where libquadmath is still in use. As has been discussed, making -static-libgfortran imply statically linking both libgfortran and libquadmath is undesirable because of the significant licensing differences between the 2 libraries. Compared to the 2014 patch, this one doesn't handle -lquadmath addition in the driver, which to me looks incorrect, libgfortran configure determines where in libgfortran.spec -lquadmath should be present if at all and with what it should be wrapped, but analyzes gfortran -### -static-libgfortran stderr and based on that figures out what gcc/configure.ac determined. 2022-08-17 Francois-Xavier Coudert Jakub Jelinek PR fortran/46539 gcc/ * common.opt (static-libquadmath): New option. * gcc.cc (driver_handle_option): Always accept -static-libquadmath. * config/darwin.h (LINK_SPEC): Handle -static-libquadmath. gcc/fortran/ * lang.opt (static-libquadmath): New option. * invoke.texi (-static-libquadmath): Document it. * options.cc (gfc_handle_option): Error out if -static-libquadmath is passed but we do not support it. libgfortran/ * acinclude.m4 (LIBQUADSPEC): From $FC -static-libgfortran -### output determine -Bstatic/-Bdynamic, -bstatic/-bdynamic, -aarchive_shared/-adefault linker support or Darwin remapping of -lgfortran to libgfortran.a%s and use that around or instead of -lquadmath in LIBQUADSPEC. * configure: Regenerated. Co-Authored-By: Francois-Xavier Coudert --- gcc/fortran/invoke.texi | 16 +++++++++++++++- gcc/fortran/lang.opt | 4 ++++ gcc/fortran/options.cc | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index c0932f6..4d1e0d6 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -170,7 +170,7 @@ and warnings}. @item Link Options @xref{Link Options,,Options for influencing the linking step}. -@gccoptlist{-static-libgfortran} +@gccoptlist{-static-libgfortran -static-libquadmath} @item Runtime Options @xref{Runtime Options,,Options for influencing runtime behavior}. @@ -1425,6 +1425,20 @@ configured, this option has no effect. @end table +@table @gcctabopt +@item -static-libquadmath +@opindex @code{static-libquadmath} +On systems that provide @file{libquadmath} as a shared and a static +library, this option forces the use of the static version. If no +shared version of @file{libquadmath} was built when the compiler was +configured, this option has no effect. + +Please note that the @file{libquadmath} runtime library is licensed under the +GNU Lesser General Public License (LGPL), and linking it statically introduces +requirements when redistributing the resulting binaries. +@end table + + @node Runtime Options @section Influencing runtime behavior @cindex options, runtime diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index cf39712..e8cd735 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -863,6 +863,10 @@ static-libgfortran Fortran Statically link the GNU Fortran helper library (libgfortran). +static-libquadmath +Fortran +Statically link the GCC Quad-Precision Math Library (libquadmath). + std=f2003 Fortran Conform to the ISO Fortran 2003 standard. diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index d0fa634..38249d6 100644 --- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -692,6 +692,13 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, #endif break; + case OPT_static_libquadmath: +#ifndef HAVE_LD_STATIC_DYNAMIC + gfc_fatal_error ("%<-static-libquadmath%> is not supported in this " + "configuration"); +#endif + break; + case OPT_fintrinsic_modules_path: case OPT_fintrinsic_modules_path_: -- cgit v1.1 From 0342f034adc677aa93e9a4587eb0b1e9dff9eab7 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 18 Aug 2022 00:16:43 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index cd7be0f..678059b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,19 @@ +2022-08-17 Francois-Xavier Coudert + Jakub Jelinek + + PR fortran/46539 + * lang.opt (static-libquadmath): New option. + * invoke.texi (-static-libquadmath): Document it. + * options.cc (gfc_handle_option): Error out if -static-libquadmath + is passed but we do not support it. + +2022-08-17 Tobias Burnus + + PR fortran/106566 + * openmp.cc (gfc_match_omp_clauses): Fix setting linear-step value + to 1 when not specified. + (gfc_match_omp_declare_simd): Accept module procedures. + 2022-08-16 Martin Liska * gfortran.texi: Fix link destination to a valid URL. -- cgit v1.1 From ca170ed9f8a086ca7e1eec841882b6bed9ec1a3a Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 18 Aug 2022 21:24:29 +0200 Subject: Revert "Fortran: fix invalid rank error in ASSOCIATED when rank is remapped [PR77652]" This reverts commit 0110cfd5449bae3a772f45ea2e4c5dab5b7a8ccd. --- gcc/fortran/check.cc | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 1da0b3c..91d87a1 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -1502,27 +1502,8 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *target) t = false; /* F2018 C838 explicitly allows an assumed-rank variable as the first argument of intrinsic inquiry functions. */ - if (pointer->rank != -1 && pointer->rank != target->rank) - { - if (pointer->rank == 0 || target->rank == 0) - { - /* There exists no valid pointer assignment using bounds - remapping for scalar => array or array => scalar. */ - if (!rank_check (target, 0, pointer->rank)) - t = false; - } - else if (target->rank != 1) - { - if (!gfc_notify_std (GFC_STD_F2008, "Rank remapping target is not " - "rank 1 at %L", &target->where)) - t = false; - } - else if ((gfc_option.allow_std & GFC_STD_F2003) == 0) - { - if (!rank_check (target, 0, pointer->rank)) - t = false; - } - } + if (pointer->rank != -1 && !rank_check (target, 0, pointer->rank)) + t = false; if (target->rank > 0 && target->ref) { for (i = 0; i < target->rank; i++) -- cgit v1.1 From 30afe5e7638cb4233692978365e4ceb4f8d2dc84 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 19 Aug 2022 00:16:27 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 678059b..a46ee462 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2022-08-18 Harald Anlauf + + Revert: + 2022-07-31 Harald Anlauf + + PR fortran/77652 + * check.cc (gfc_check_associated): Make the rank check of POINTER + vs. TARGET match the allowed forms of pointer assignment for the + selected Fortran standard. + 2022-08-17 Francois-Xavier Coudert Jakub Jelinek -- cgit v1.1 From dd899c7de36d19ddf18e3bfab4a0c150096e2368 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 20 Aug 2022 21:20:04 +0200 Subject: fortran: Drop -static-lib{gfortran,quadmath} from f951 [PR46539] As discussed earlier, all other -static-lib* options are Driver only, these 2 are Driver in common.opt and Fortran in lang.opt. The spec files never pass the -static-lib* options down to any compiler (f951 etc.), so the 2 errors below are reported only when one runs ./f951 -static-libgfortran by hand. The following patch just removes f951 support of these options, the gfortran driver behavior remains as before. For other -static-lib* option (and even these because it is never passed to f951) we never error if we can't support those options, and e.g. Darwin is actually able to handle those options through other means. 2022-08-20 Jakub Jelinek PR fortran/46539 * lang.opt (static-libgfortran, static-libquadmath): Change Fortran to Driver. * options.cc (gfc_handle_option): Don't handle OPT_static_libgfortran nor OPT_static_libquadmath here. --- gcc/fortran/lang.opt | 4 ++-- gcc/fortran/options.cc | 14 -------------- 2 files changed, 2 insertions(+), 16 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index e8cd735..b18a6d3 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -860,11 +860,11 @@ Fortran Joined Separate ; Documented in common.opt static-libgfortran -Fortran +Driver Statically link the GNU Fortran helper library (libgfortran). static-libquadmath -Fortran +Driver Statically link the GCC Quad-Precision Math Library (libquadmath). std=f2003 diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index 38249d6..08afb78 100644 --- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -685,20 +685,6 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, gfc_option.source_form = FORM_FREE; break; - case OPT_static_libgfortran: -#ifndef HAVE_LD_STATIC_DYNAMIC - gfc_fatal_error ("%<-static-libgfortran%> is not supported in this " - "configuration"); -#endif - break; - - case OPT_static_libquadmath: -#ifndef HAVE_LD_STATIC_DYNAMIC - gfc_fatal_error ("%<-static-libquadmath%> is not supported in this " - "configuration"); -#endif - break; - case OPT_fintrinsic_modules_path: case OPT_fintrinsic_modules_path_: -- cgit v1.1 From d6a39c25c05c6ed5df8ce49eda719d17e40e29bb Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 21 Aug 2022 00:16:33 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a46ee462..3aec1db 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-08-20 Jakub Jelinek + + PR fortran/46539 + * lang.opt (static-libgfortran, static-libquadmath): Change Fortran + to Driver. + * options.cc (gfc_handle_option): Don't handle OPT_static_libgfortran + nor OPT_static_libquadmath here. + 2022-08-18 Harald Anlauf Revert: -- cgit v1.1 From 7e51df048ae849115e12bf12702bdf1b65893be7 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 20 Aug 2022 20:36:28 +0200 Subject: Fortran: fix simplification of intrinsics IBCLR and IBSET [PR106557] gcc/fortran/ChangeLog: PR fortran/106557 * simplify.cc (gfc_simplify_ibclr): Ensure consistent results of the simplification by dropping a redundant memory representation of argument x. (gfc_simplify_ibset): Likewise. gcc/testsuite/ChangeLog: PR fortran/106557 * gfortran.dg/pr106557.f90: New test. --- gcc/fortran/simplify.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index fb72599..f992c31 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -3380,6 +3380,13 @@ gfc_simplify_ibclr (gfc_expr *x, gfc_expr *y) k = gfc_validate_kind (x->ts.type, x->ts.kind, false); result = gfc_copy_expr (x); + /* Drop any separate memory representation of x to avoid potential + inconsistencies in result. */ + if (result->representation.string) + { + free (result->representation.string); + result->representation.string = NULL; + } convert_mpz_to_unsigned (result->value.integer, gfc_integer_kinds[k].bit_size); @@ -3471,6 +3478,13 @@ gfc_simplify_ibset (gfc_expr *x, gfc_expr *y) k = gfc_validate_kind (x->ts.type, x->ts.kind, false); result = gfc_copy_expr (x); + /* Drop any separate memory representation of x to avoid potential + inconsistencies in result. */ + if (result->representation.string) + { + free (result->representation.string); + result->representation.string = NULL; + } convert_mpz_to_unsigned (result->value.integer, gfc_integer_kinds[k].bit_size); -- cgit v1.1 From 3b2e3fa39dd2b606566f47006d015f9c447dcc7d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 23 Aug 2022 00:16:29 +0000 Subject: Daily bump. --- gcc/fortran/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3aec1db..1352a54 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2022-08-22 Harald Anlauf + + PR fortran/106557 + * simplify.cc (gfc_simplify_ibclr): Ensure consistent results of + the simplification by dropping a redundant memory representation + of argument x. + (gfc_simplify_ibset): Likewise. + 2022-08-20 Jakub Jelinek PR fortran/46539 -- cgit v1.1