From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by sourceware.org (Postfix) with ESMTPS id C4DED385BF92; Wed, 1 Apr 2020 20:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C4DED385BF92 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id 031K4hdk055216 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 1 Apr 2020 13:04:43 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id 031K4hZx055215; Wed, 1 Apr 2020 13:04:43 -0700 (PDT) (envelope-from sgk) Date: Wed, 1 Apr 2020 13:04:43 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] deferred-shape vs assumed-shape Message-ID: <20200401200443.GA55208@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2020 20:04:51 -0000 See https://stackoverflow.com/questions/60972134/whats-wrong-with-the-following-fortran-code-gfortran-dtio-dummy-argument-at Is A(:) a deferred-shape array or an assumed-shape array? The answer of course depends on context. This patch fixes the issue found at the above URL. Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (revision 280157) +++ gcc/fortran/interface.c (working copy) @@ -4916,10 +4916,15 @@ check_dtio_arg_TKR_intent (gfc_symbol *fsym, bool type || ((type != BT_CLASS) && fsym->attr.dimension))) gfc_error ("DTIO dummy argument at %L must be a scalar", &fsym->declared_at); - else if (rank == 1 - && (fsym->as == NULL || fsym->as->type != AS_ASSUMED_SHAPE)) - gfc_error ("DTIO dummy argument at %L must be an " - "ASSUMED SHAPE ARRAY", &fsym->declared_at); + else if (rank == 1) + { + if (fsym->as == NULL + || !(fsym->as->type == AS_ASSUMED_SHAPE + || (fsym->as->type == AS_DEFERRED && fsym->attr.dummy + && !fsym->attr.allocatable && !fsym->attr.pointer))) + gfc_error ("DTIO dummy argument at %L must be an " + "ASSUMED-SHAPE ARRAY", &fsym->declared_at); + } if (type == BT_CHARACTER && fsym->ts.u.cl->length != NULL) gfc_error ("DTIO character argument at %L must have assumed length", -- Steve