From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fortran: diagnose and reject duplicate CONTIGUOUS attribute [PR108025]
Date: Thu, 8 Dec 2022 22:59:42 +0100 [thread overview]
Message-ID: <trinity-c8f6193c-a103-49ca-a08b-64c2de66ad54-1670536782690@3c-app-gmx-bap18> (raw)
[-- Attachment #1: Type: text/plain, Size: 309 bytes --]
Dear all,
a fairly obvious, or rather trivial fix that appeared while
analyzing another pr and that can be treated independently:
reject duplicate CONTIGUOUS attributes.
(Intel and NAG reject this, Cray warns that this is non-standard.)
Regtested on x86_64-pc-linux-gnu. OK for mainline?
Thanks,
Harald
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr108025.diff --]
[-- Type: text/x-patch, Size: 1642 bytes --]
From 3a9f6d5a8ee490adf9a18f93feaf86542642be7d Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Thu, 8 Dec 2022 22:50:45 +0100
Subject: [PATCH] Fortran: diagnose and reject duplicate CONTIGUOUS attribute
[PR108025]
gcc/fortran/ChangeLog:
PR fortran/108025
* symbol.cc (gfc_add_contiguous): Diagnose and reject duplicate
CONTIGUOUS attribute.
gcc/testsuite/ChangeLog:
PR fortran/108025
* gfortran.dg/contiguous_12.f90: New test.
---
gcc/fortran/symbol.cc | 6 ++++++
gcc/testsuite/gfortran.dg/contiguous_12.f90 | 7 +++++++
2 files changed, 13 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/contiguous_12.f90
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 49fb37864bd..e704e7ac2bd 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -1108,6 +1108,12 @@ gfc_add_contiguous (symbol_attribute *attr, const char *name, locus *where)
if (check_used (attr, name, where))
return false;
+ if (attr->contiguous)
+ {
+ duplicate_attr ("CONTIGUOUS", where);
+ return false;
+ }
+
attr->contiguous = 1;
return gfc_check_conflict (attr, name, where);
}
diff --git a/gcc/testsuite/gfortran.dg/contiguous_12.f90 b/gcc/testsuite/gfortran.dg/contiguous_12.f90
new file mode 100644
index 00000000000..9c477a7a06a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/contiguous_12.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/108025
+
+subroutine foo (x)
+ real, contiguous :: x(:)
+ contiguous :: x ! { dg-error "Duplicate CONTIGUOUS attribute" }
+end
--
2.35.3
next reply other threads:[~2022-12-08 21:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 21:59 Harald Anlauf [this message]
2022-12-08 22:13 ` Steve Kargl
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=trinity-c8f6193c-a103-49ca-a08b-64c2de66ad54-1670536782690@3c-app-gmx-bap18 \
--to=anlauf@gmx.de \
--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).