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.
This commit is contained in:
Harald Anlauf 2022-12-08 22:50:45 +01:00
parent 7410032a77
commit 3a9f6d5a8e
2 changed files with 13 additions and 0 deletions

View 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);
}

View file

@ -0,0 +1,7 @@
! { dg-do compile }
! PR fortran/108025
subroutine foo (x)
real, contiguous :: x(:)
contiguous :: x ! { dg-error "Duplicate CONTIGUOUS attribute" }
end