Fortran: diagnose and reject duplicate CONTIGUOUS attribute [PR108025]
Checks
Commit Message
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
Comments
On Thu, Dec 08, 2022 at 10:59:42PM +0100, Harald Anlauf via Fortran wrote:
> 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?
Yes, thanks for the patch.
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
@@ -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);
}
new file mode 100644
@@ -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