Re: [patch, Fortran] Make REAL(KIND=16) detection more robust
Hi FX, I’m not opposed, but I’d really like to get this into the current branch. It is a much less invasive change than the power-ieee128 work. The only case I changed is the case where there is a kind 16, and there is a long double, but the long double is neither kind 10 neither kind 16. I don’t think there is such a platform currently (otherwise it wouldn’t have worked). I did a bootstrap and test on POWER, and it did not cause any regressions. So, OK for trunk. Thanks for the patch! Regards Thomas
[PATCH] OpenMP front-end: allow requires dynamic_allocators
Hi all, This patch removes the "sorry" message for the OpenMP "requires dynamic_allocators" feature in C, C++ and Fortran. The clause is supposed to state that the user code will not work without the omp_alloc/omp_free and omp_init_allocator/omp_destroy_allocator and these things *are* present, so there should be no problem allowing it. I can't see any reason for our implementation to *do* anything with this statement -- it's fine for the allocators to work the same with or without it. I think this patch ought to be fine for GCC 12, but if not it can wait until stage 1 opens. I shall backport this to OG11 shortly. OK? AndrewOpenMP: allow requires dynamic_allocators There's no need to reject the dynamic_allocators requires directive because we actually do support the feature, and it doesn't have to actually "do" anything. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_requires): Don't "sorry" dynamic_allocators. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_requires): Don't "sorry" dynamic_allocators. gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_requires): Don't "sorry" dynamic_allocators. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/requires-8.f90: Reinstate dynamic allocators requirement. diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index d7e5f051ac0..808a73f1038 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -22581,7 +22581,7 @@ c_parser_omp_requires (c_parser *parser) c_parser_skip_to_pragma_eol (parser, false); return; } - if (p) + if (p && this_req != OMP_REQUIRES_DYNAMIC_ALLOCATORS) sorry_at (cloc, "%qs clause on % directive not " "supported yet", p); if (p) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c2564e51e41..d55c9675c4e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -46421,7 +46421,7 @@ cp_parser_omp_requires (cp_parser *parser, cp_token *pragma_tok) cp_parser_skip_to_pragma_eol (parser, pragma_tok); return false; } - if (p) + if (p && this_req != OMP_REQUIRES_DYNAMIC_ALLOCATORS) sorry_at (cloc, "%qs clause on % directive not " "supported yet", p); if (p) diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 2036bc1349f..f47a44f7539 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5373,7 +5373,8 @@ gfc_match_omp_requires (void) else goto error; - if (requires_clause & ~OMP_REQ_ATOMIC_MEM_ORDER_MASK) + 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)) diff --git a/gcc/testsuite/gfortran.dg/gomp/requires-8.f90 b/gcc/testsuite/gfortran.dg/gomp/requires-8.f90 index 3c32ae9860e..eadfcaf8609 100644 --- a/gcc/testsuite/gfortran.dg/gomp/requires-8.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/requires-8.f90 @@ -4,7 +4,7 @@ contains subroutine foo interface subroutine bar2 - !$!omp requires dynamic_allocators + !$omp requires dynamic_allocators end subroutine end interface !$omp target
[PATCH] PR fortran/103776 - ICE in gfc_compare_string, at fortran/arith.c:1118
Dear all, we need to check that expressions in CASE selectors are scalar, and reject them early if they aren't. Testcase by Gerhard. The fix is obvious and sort of a follow-up to the fix for PR103591. Regtested on x86_64-pc-linux-gnu. Will commit as obvious within 48h unless there are objections or other comments. Thanks, Harald From 70385de214fe4de289c56e7f4e06a4b252414379 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 20 Dec 2021 22:01:05 +0100 Subject: [PATCH] Fortran: CASE selector expressions must be scalar gcc/fortran/ChangeLog: PR fortran/103776 * match.c (match_case_selector): Reject expressions in CASE selector which are not scalar. gcc/testsuite/ChangeLog: PR fortran/103776 * gfortran.dg/select_10.f90: New test. --- gcc/fortran/match.c | 13 + gcc/testsuite/gfortran.dg/select_10.f90 | 25 + 2 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/select_10.f90 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 52bc5af7542..617fb35c9cd 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -6088,6 +6088,19 @@ match_case_selector (gfc_case **cp) } } + if (c->low && c->low->rank != 0) +{ + gfc_error ("Expression in CASE selector at %L must be scalar", + &c->low->where); + goto cleanup; +} + if (c->high && c->high->rank != 0) +{ + gfc_error ("Expression in CASE selector at %L must be scalar", + &c->high->where); + goto cleanup; +} + *cp = c; return MATCH_YES; diff --git a/gcc/testsuite/gfortran.dg/select_10.f90 b/gcc/testsuite/gfortran.dg/select_10.f90 new file mode 100644 index 000..2d9b0170ce9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_10.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! PR fortran/103776 - ICE in gfc_compare_string +! Contributed by G.Steinmetz + +program p + integer :: n + select case (n) + case ([1])! { dg-error "must be scalar" } + end select + select case (n) + case (:[2]) ! { dg-error "must be scalar" } + end select + select case (n) + case (['1']) ! { dg-error "must be scalar" } + end select + select case (n) + case (['1']:2)! { dg-error "must be scalar" } + end select + select case (n) + case(['1']:['2']) ! { dg-error "must be scalar" } + end select + select case (n) + case(1:['2']) ! { dg-error "must be scalar" } + end select +end -- 2.26.2
[PATCH] PR fortran/103778 - [10/11/12 Regression] ICE: Invalid expression in gfc_element_size
Dear all, again found by Gerhard: using a BOZ literal constant in situations where an interoperable object is expected can lead to an ICE. But obviously a BOZ in not interoperable. Obvious patch, regtested on x86_64-pc-linux-gnu. Will commit within 48h unless there are objections or better suggestions. Thanks, Harald From 2e6c83fbddda3215faf111263ebfc754bc07096c Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 20 Dec 2021 22:12:33 +0100 Subject: [PATCH] Fortran: BOZ literal constants are not interoperable gcc/fortran/ChangeLog: PR fortran/103778 * check.c (is_c_interoperable): A BOZ literal constant is not interoperable. gcc/testsuite/ChangeLog: PR fortran/103778 * gfortran.dg/illegal_boz_arg_3.f90: New test. --- gcc/fortran/check.c | 6 ++ gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 | 7 +++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 625473c90d1..b4db9337e9f 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -5185,6 +5185,12 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr) return false; } + if (expr->ts.type == BT_BOZ) +{ + *msg = "BOZ literal constant"; + return false; +} + if (expr->ts.type == BT_CLASS) { *msg = "Expression is polymorphic"; diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 new file mode 100644 index 000..59fefa90971 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_3.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/103778 + +program p + use iso_c_binding, only : c_sizeof + integer, parameter :: a = c_sizeof(z'1') ! { dg-error "cannot appear" } +end -- 2.26.2
[PATCH] PR fortran/103777 - ICE in gfc_simplify_maskl, at fortran/simplify.c:4918
Dear all, we need to check the arguments of the elemental MASKL and MASKR intrinsics also before simplifying. Testcase by Gerhard. The fix is almost obvious, but I'm happy to get feedback in case there is something I overlooked. (There is already a check on scalar arguments to MASKL/MASKR, which however misses the case of array arguments.) Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From b58a44bc861ee3d1e67e3b7c949a301b6290c05c Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 20 Dec 2021 22:59:53 +0100 Subject: [PATCH] Fortran: check arguments of MASKL/MASKR intrinsics before simplification gcc/fortran/ChangeLog: PR fortran/103777 * simplify.c (gfc_simplify_maskr): Check validity of argument 'I' before simplifying. (gfc_simplify_maskl): Likewise. gcc/testsuite/ChangeLog: PR fortran/103777 * gfortran.dg/masklr_3.f90: New test. --- gcc/fortran/simplify.c | 6 ++ gcc/testsuite/gfortran.dg/masklr_3.f90 | 14 ++ 2 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/masklr_3.f90 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 90067b6bbe6..b6f636d4ff1 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4878,6 +4878,9 @@ gfc_simplify_maskr (gfc_expr *i, gfc_expr *kind_arg) bool fail = gfc_extract_int (i, &arg); gcc_assert (!fail); + if (!gfc_check_mask (i, kind_arg)) +return &gfc_bad_expr; + result = gfc_get_constant_expr (BT_INTEGER, kind, &i->where); /* MASKR(n) = 2^n - 1 */ @@ -4909,6 +4912,9 @@ gfc_simplify_maskl (gfc_expr *i, gfc_expr *kind_arg) bool fail = gfc_extract_int (i, &arg); gcc_assert (!fail); + if (!gfc_check_mask (i, kind_arg)) +return &gfc_bad_expr; + result = gfc_get_constant_expr (BT_INTEGER, kind, &i->where); /* MASKL(n) = 2^bit_size - 2^(bit_size - n) */ diff --git a/gcc/testsuite/gfortran.dg/masklr_3.f90 b/gcc/testsuite/gfortran.dg/masklr_3.f90 new file mode 100644 index 000..eb689f0f408 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/masklr_3.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/103777 - ICE in gfc_simplify_maskl +! Contributed by G.Steinmetz + +program p + print *, maskl([999]) ! { dg-error "must be less than or equal" } + print *, maskr([999]) ! { dg-error "must be less than or equal" } + print *, maskl([-999]) ! { dg-error "must be nonnegative" } + print *, maskr([-999]) ! { dg-error "must be nonnegative" } + print *, maskl([32],kind=4) + print *, maskl([33],kind=4) ! { dg-error "must be less than or equal" } + print *, maskl([64],kind=8) + print *, maskl([65],kind=8) ! { dg-error "must be less than or equal" } +end -- 2.26.2