From: Cesar Philippidis <cesar@codesourcery.com>
To: Fortran List <fortran@gcc.gnu.org>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [patch,wip] warn on noncontiguous pointers
Date: Wed, 26 Sep 2018 18:51:00 -0000 [thread overview]
Message-ID: <e4cd4bcc-50c9-fe96-2cee-3aced4e5b15f@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
As of GCC 8, gfortran now errors when a pointer with a contiguous
attribute is set to point to a target without a contiguous attribute. I
think this is overly strict, and should probably be demoted to a
pedantic warning as I've done in the attached patch.
I ran into this issue while I was tuning GCC for lsdalton. Specifically,
CMake generates (not exactly because I reduced it) the following test
case for ScaTeLib to determine if that library can be enabled:
program test
implicit none
real,pointer :: fptr1(:)
real,pointer,contiguous :: fptr3(:,:,:)
allocate(fptr1(12))
call random_number(fptr1)
!Test pointer reshape II
fptr3(1:2,1:2,1:2) => fptr1(4:)
end program
Note how fptr1 doesn't have a contiguous attribute. Does anyone have
thoughts on this? Maybe the ScaTeLib code needs to be updated.
Thanks,
Cesar
[-- Attachment #2: 0001-Fortran-Disable-Assignment-to-contiguous-pointer-fro.patch --]
[-- Type: text/x-patch, Size: 1195 bytes --]
Disable "Assignment to contiguous pointer from non-contiguous target" error
2018-XX-YY Cesar Philippidis <cesar@codesourcery.com>
gcc/fortran/
* expr.c (gfc_check_pointer_assign): Demote "Assignment to
contiguous pointer from non-contiguous target" to a warning.
---
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 3315bb840af..74caa4f2d59 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3957,13 +3957,13 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue)
}
}
- /* Error for assignments of contiguous pointers to targets which is not
+ /* Warn for assignments of contiguous pointers to targets which is not
contiguous. Be lenient in the definition of what counts as
contiguous. */
if (lhs_attr.contiguous && !gfc_is_simply_contiguous (rvalue, false, true))
- gfc_error ("Assignment to contiguous pointer from non-contiguous "
- "target at %L", &rvalue->where);
+ gfc_warning (OPT_Wpedantic, "Assignment to contiguous pointer from "
+ "non-contiguous target at %L", &rvalue->where);
/* Warn if it is the LHS pointer may lives longer than the RHS target. */
if (warn_target_lifetime
--
2.17.1
next reply other threads:[~2018-09-26 18:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-26 18:51 Cesar Philippidis [this message]
2018-09-26 20:49 ` Thomas Koenig
2018-09-26 20:55 ` Cesar Philippidis
2018-09-27 8:00 Bader, Reinhold
2018-09-27 17:23 ` Thomas Koenig
2018-09-28 5:12 ` AW: " Bader, Reinhold
2018-09-30 18:12 ` Thomas Koenig
2018-10-01 13:36 ` Cesar Philippidis
2018-10-03 21:16 ` Cesar Philippidis
2018-10-05 6:14 ` Thomas Koenig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e4cd4bcc-50c9-fe96-2cee-3aced4e5b15f@codesourcery.com \
--to=cesar@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).