]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: diagnose and reject duplicate CONTIGUOUS attribute [PR108025]
authorHarald Anlauf <anlauf@gmx.de>
Thu, 8 Dec 2022 21:50:45 +0000 (22:50 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 8 Dec 2022 21:50:45 +0000 (22:50 +0100)
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
gcc/testsuite/gfortran.dg/contiguous_12.f90 [new file with mode: 0644]

index 49fb37864bd7a2af563b30af656ee5b92a3a5d62..e704e7ac2bd6d3b8a44c327de8855e53cbd772c4 100644 (file)
@@ -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 (file)
index 0000000..9c477a7
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/108025
+
+subroutine foo (x)
+  real, contiguous :: x(:)
+  contiguous       :: x    ! { dg-error "Duplicate CONTIGUOUS attribute" }
+end