From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id 2F7FA3858C83; Mon, 27 Mar 2023 18:43:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F7FA3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679942604; bh=ScqCK9tj/ITcrwxeEShBXvr/z3bqEYPfpoKPDule9OA=; h=From:To:Subject:Date:From; b=vkGYgues6eCY3kmYdjTlcbvyLZLvl1XACRkwBJJRei3kHJl9L2nd0VLjep2GHPP46 Db4/RosDHPnXjdlj4dvJSkntG26j1TP6vV8nKStkZSK4ZhOkYCEg817f+YPLvV/hE3 SfZaO2OE+5i1SgDeZ0gBM9DPJcAa6teSA7K8InAM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9321] Fortran: diagnose and reject duplicate CONTIGUOUS attribute [PR108025] X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 82ec75a726b3f8f874dacb0cb342c9bbd1233cc0 X-Git-Newrev: 4b56945b1ae497580b542abb6d7ca41b6444c219 Message-Id: <20230327184324.2F7FA3858C83@sourceware.org> Date: Mon, 27 Mar 2023 18:43:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4b56945b1ae497580b542abb6d7ca41b6444c219 commit r12-9321-g4b56945b1ae497580b542abb6d7ca41b6444c219 Author: Harald Anlauf 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. (cherry picked from commit 3a9f6d5a8ee490adf9a18f93feaf86542642be7d) 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 b092813a5c0..5d49ca4fd98 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