public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4568] Fortran: diagnose and reject duplicate CONTIGUOUS attribute [PR108025]
@ 2022-12-08 22:15 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-12-08 22:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3a9f6d5a8ee490adf9a18f93feaf86542642be7d

commit r13-4568-g3a9f6d5a8ee490adf9a18f93feaf86542642be7d
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Dec 8 22:50:45 2022 +0100

    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.

Diff:
---
 gcc/fortran/symbol.cc                       | 6 ++++++
 gcc/testsuite/gfortran.dg/contiguous_12.f90 | 7 +++++++
 2 files changed, 13 insertions(+)

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-08 22:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 22:15 [gcc r13-4568] Fortran: diagnose and reject duplicate CONTIGUOUS attribute [PR108025] Harald Anlauf

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).