diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2023-02-06 08:41:27 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2023-02-06 08:41:27 +0100 |
commit | d4309091390bebf46c7e56cba35bd88ad7d8b9ef (patch) | |
tree | cddfb0e95b83380516e233fe39dd3dcefe6180cd /gcc | |
parent | 07cea1a91b417731fd1b63f4a68377aaaecc7cbe (diff) | |
parent | cbebc0a753d404a064f8e306374627573ef2deb6 (diff) | |
download | gcc-d4309091390bebf46c7e56cba35bd88ad7d8b9ef.zip gcc-d4309091390bebf46c7e56cba35bd88ad7d8b9ef.tar.gz gcc-d4309091390bebf46c7e56cba35bd88ad7d8b9ef.tar.bz2 |
Merge branch 'releases/gcc-12' into devel/omp/gcc-12
Merge up to r12-9109-gcbebc0a753d404a064f8e306374627573ef2deb6 (6th Feb 2023)
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/DATESTAMP | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/semantics.cc | 15 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 40 | ||||
-rw-r--r-- | gcc/fortran/check.cc | 2 | ||||
-rw-r--r-- | gcc/fortran/expr.cc | 6 | ||||
-rw-r--r-- | gcc/fortran/match.cc | 10 | ||||
-rw-r--r-- | gcc/fortran/resolve.cc | 29 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 41 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/call9.C | 26 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/common_27.f90 | 14 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/minmaxloc_1.f90 | 32 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr108527.f90 | 10 |
13 files changed, 214 insertions, 22 deletions
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 05457af..285087c 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20230202 +20230206 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d4c7582..92634fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2023-02-03 Patrick Palka <ppalka@redhat.com> + + Backported from master: + 2023-02-03 Patrick Palka <ppalka@redhat.com> + + PR c++/107461 + * semantics.cc (finish_call_expr): Strip ADDR_EXPR from + the selected callee during overload set pruning. + 2023-02-01 Marek Polacek <polacek@redhat.com> Backported from master: diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index ce17aae..f589e51 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -2920,13 +2920,18 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, if (TREE_CODE (result) == CALL_EXPR && really_overloaded_fn (orig_fn)) { - orig_fn = CALL_EXPR_FN (result); - if (TREE_CODE (orig_fn) == COMPONENT_REF) + tree sel_fn = CALL_EXPR_FN (result); + if (TREE_CODE (sel_fn) == COMPONENT_REF) { /* The non-dependent result of build_new_method_call. */ - orig_fn = TREE_OPERAND (orig_fn, 1); - gcc_assert (BASELINK_P (orig_fn)); - } + sel_fn = TREE_OPERAND (sel_fn, 1); + gcc_assert (BASELINK_P (sel_fn)); + } + else if (TREE_CODE (sel_fn) == ADDR_EXPR) + /* Our original callee wasn't wrapped in an ADDR_EXPR, + so strip this ADDR_EXPR added by build_over_call. */ + sel_fn = TREE_OPERAND (sel_fn, 0); + orig_fn = sel_fn; } result = build_call_vec (TREE_TYPE (result), orig_fn, orig_args); diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 85060d5..28686e5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,43 @@ +2023-02-05 Mikael Morin <mikael@gcc.gnu.org> + + Backported from master: + 2023-01-29 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/108450 + * check.cc (gfc_check_minloc_maxloc): Explicitly set argument name. + (gfc_check_findloc): Ditto. + +2023-02-05 Harald Anlauf <anlauf@gmx.de> + + Backported from master: + 2023-02-01 Harald Anlauf <anlauf@gmx.de> + + PR fortran/108609 + * expr.cc (find_array_section): Add check to prevent interpreting an + mpz non-integer constant as an integer. + +2023-02-05 Harald Anlauf <anlauf@gmx.de> + + Backported from master: + 2023-01-28 Harald Anlauf <anlauf@gmx.de> + Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/108527 + * resolve.cc (compare_bound_int): Expression to compare must be of + type INTEGER. + (compare_bound_mpz_t): Likewise. + (check_dimension): Fix comment on checks applied to array section + and clean up associated logic. + +2023-02-02 Harald Anlauf <anlauf@gmx.de> + + Backported from master: + 2023-01-28 Harald Anlauf <anlauf@gmx.de> + + PR fortran/108453 + * match.cc (gfc_match_common): A USE associated name shall not appear + in a COMMON block (F2018:C8121). + 2023-01-30 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 91d87a1..ca7cef6 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -3888,6 +3888,7 @@ gfc_check_minloc_maxloc (gfc_actual_arglist *ap) { b = gfc_get_logical_expr (gfc_logical_4_kind, NULL, 0); ap->next->next->next->next->expr = b; + ap->next->next->next->next->name = gfc_get_string ("back"); } if (m == NULL && d != NULL && d->ts.type == BT_LOGICAL @@ -3969,6 +3970,7 @@ gfc_check_findloc (gfc_actual_arglist *ap) { b = gfc_get_logical_expr (gfc_logical_4_kind, NULL, 0); ap->next->next->next->next->next->expr = b; + ap->next->next->next->next->next->name = gfc_get_string ("back"); } if (m == NULL && d != NULL && d->ts.type == BT_LOGICAL diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index ab54d43..15d41d0 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1552,7 +1552,11 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) lower = ref->u.ar.as->lower[d]; upper = ref->u.ar.as->upper[d]; - if (!lower || !upper) + if (!lower || !upper + || lower->expr_type != EXPR_CONSTANT + || upper->expr_type != EXPR_CONSTANT + || lower->ts.type != BT_INTEGER + || upper->ts.type != BT_INTEGER) { t = false; goto cleanup; diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 9bca21f..7c938fb 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -5339,6 +5339,16 @@ gfc_match_common (void) goto cleanup; } + /* F2018:R874: common-block-object is variable-name [ (array-spec) ] + F2018:C8121: A variable-name shall not be a name made accessible + by use association. */ + if (sym->attr.use_assoc) + { + gfc_error ("Symbol %qs at %C is USE associated from module %qs " + "and cannot occur in COMMON", sym->name, sym->module); + goto cleanup; + } + /* Deal with an optional array specification after the symbol name. */ m = gfc_match_array_spec (&as, true, true); diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 0eb5fa0..9b6bea9 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -4577,12 +4577,11 @@ compare_bound_int (gfc_expr *a, int b) { int i; - if (a == NULL || a->expr_type != EXPR_CONSTANT) + if (a == NULL + || a->expr_type != EXPR_CONSTANT + || a->ts.type != BT_INTEGER) return CMP_UNKNOWN; - if (a->ts.type != BT_INTEGER) - gfc_internal_error ("compare_bound_int(): Bad expression"); - i = mpz_cmp_si (a->value.integer, b); if (i < 0) @@ -4600,12 +4599,11 @@ compare_bound_mpz_t (gfc_expr *a, mpz_t b) { int i; - if (a == NULL || a->expr_type != EXPR_CONSTANT) + if (a == NULL + || a->expr_type != EXPR_CONSTANT + || a->ts.type != BT_INTEGER) return CMP_UNKNOWN; - if (a->ts.type != BT_INTEGER) - gfc_internal_error ("compare_bound_int(): Bad expression"); - i = mpz_cmp (a->value.integer, b); if (i < 0) @@ -4735,23 +4733,24 @@ check_dimension (int i, gfc_array_ref *ar, gfc_array_spec *as) #define AR_END (ar->end[i] ? ar->end[i] : as->upper[i]) compare_result comp_start_end = compare_bound (AR_START, AR_END); + compare_result comp_stride_zero = compare_bound_int (ar->stride[i], 0); /* Check for zero stride, which is not allowed. */ - if (compare_bound_int (ar->stride[i], 0) == CMP_EQ) + if (comp_stride_zero == CMP_EQ) { gfc_error ("Illegal stride of zero at %L", &ar->c_where[i]); return false; } - /* if start == len || (stride > 0 && start < len) - || (stride < 0 && start > len), + /* if start == end || (stride > 0 && start < end) + || (stride < 0 && start > end), then the array section contains at least one element. In this case, there is an out-of-bounds access if (start < lower || start > upper). */ - if (compare_bound (AR_START, AR_END) == CMP_EQ - || ((compare_bound_int (ar->stride[i], 0) == CMP_GT - || ar->stride[i] == NULL) && comp_start_end == CMP_LT) - || (compare_bound_int (ar->stride[i], 0) == CMP_LT + if (comp_start_end == CMP_EQ + || ((comp_stride_zero == CMP_GT || ar->stride[i] == NULL) + && comp_start_end == CMP_LT) + || (comp_stride_zero == CMP_LT && comp_start_end == CMP_GT)) { if (compare_bound (AR_START, as->lower[i]) == CMP_LT) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7395d52..60ccc0c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,44 @@ +2023-02-05 Mikael Morin <mikael@gcc.gnu.org> + + Backported from master: + 2023-01-29 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/108450 + * gfortran.dg/gomp/minmaxloc_1.f90: New test. + +2023-02-05 Harald Anlauf <anlauf@gmx.de> + + Backported from master: + 2023-02-01 Harald Anlauf <anlauf@gmx.de> + + PR fortran/108609 + * gfortran.dg/pr108527.f90: Adjust test pattern. + +2023-02-05 Harald Anlauf <anlauf@gmx.de> + + Backported from master: + 2023-01-28 Harald Anlauf <anlauf@gmx.de> + Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/108527 + * gfortran.dg/pr108527.f90: New test. + +2023-02-03 Patrick Palka <ppalka@redhat.com> + + Backported from master: + 2023-02-03 Patrick Palka <ppalka@redhat.com> + + PR c++/107461 + * g++.dg/template/call9.C: New test. + +2023-02-02 Harald Anlauf <anlauf@gmx.de> + + Backported from master: + 2023-01-28 Harald Anlauf <anlauf@gmx.de> + + PR fortran/108453 + * gfortran.dg/common_27.f90: New test. + 2023-02-01 Marek Polacek <polacek@redhat.com> Backported from master: diff --git a/gcc/testsuite/g++.dg/template/call9.C b/gcc/testsuite/g++.dg/template/call9.C new file mode 100644 index 0000000..6bdfd93 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/call9.C @@ -0,0 +1,26 @@ +// PR c++/107461 +// { dg-do compile { target c++11 } } + +template<class T> +constexpr T min(T t0, T t1) { + return t0 < t1 ? t0 : t1; +} + +template<int MAX> +struct Matrix; + +template<int MAXOP, int other_MAXOP> +Matrix<min(MAXOP, other_MAXOP)> +operator+(Matrix<MAXOP> const& lhs, Matrix<other_MAXOP> const& rhs); // #1 + +template<int MAX> +struct Matrix { + template<int MAXOP, int other_MAXOP> + friend Matrix<min(MAXOP, other_MAXOP)> + operator+(Matrix<MAXOP> const& lhs, Matrix<other_MAXOP> const& rhs); // #2 +}; + +int main() { + Matrix<1> a; + a+a; +} diff --git a/gcc/testsuite/gfortran.dg/common_27.f90 b/gcc/testsuite/gfortran.dg/common_27.f90 new file mode 100644 index 0000000..dcde5de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_27.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/108453 - a use associated variable cannot occur in COMMON +! Contributed by G.Steinmetz + +module m + type t + end type + real :: r +end +program p + use m, only: t, r + common t ! { dg-error "USE associated from module" } + common /cm/ r ! { dg-error "USE associated from module" } +end diff --git a/gcc/testsuite/gfortran.dg/gomp/minmaxloc_1.f90 b/gcc/testsuite/gfortran.dg/gomp/minmaxloc_1.f90 new file mode 100644 index 0000000..b3691f7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/minmaxloc_1.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! +! PR fortran/108450 +! This program used to cause an ICE because of the double resolution +! of the maxloc expression and the addition of a hidden unnamed argument +! during the first resolution. +! +! Original testcase from G. Steinmetz + +subroutine s1 + integer :: a(8) = 0 + integer :: l + integer :: n + !$omp atomic + n = maxloc(a, mask=l) ! { dg-error ".mask. argument of .maxloc. intrinsic at .1. must be LOGICAL" } +end + +subroutine s2 + integer :: a(8) = 0 + integer :: l + integer :: n + !$omp atomic + n = minloc(a, mask=l) ! { dg-error ".mask. argument of .minloc. intrinsic at .1. must be LOGICAL" } +end + +subroutine s3 + integer :: a(8) = 0 + integer :: l + integer :: n + !$omp atomic + n = findloc(a, 3, mask=l) ! { dg-error ".mask. argument of .findloc. intrinsic at .1. must be LOGICAL" } +end diff --git a/gcc/testsuite/gfortran.dg/pr108527.f90 b/gcc/testsuite/gfortran.dg/pr108527.f90 new file mode 100644 index 0000000..8045148 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr108527.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/108527 - ICE in compare_bound_int +! Contributed by G.Steinmetz + +program p + integer, parameter :: a((2.)) = [4,8] ! { dg-error "must be of INTEGER type" } + integer(a(1:1)) :: b ! { dg-error "Unclassifiable statement" } +end + +! { dg-prune-output "Parameter array" } |