From patchwork Tue Apr 7 23:07:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry D X-Patchwork-Id: 132782 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id DBB834BA2E08 for ; Tue, 7 Apr 2026 23:08:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBB834BA2E08 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=fA5MGytJ X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by sourceware.org (Postfix) with ESMTPS id 9AC914BA2E07 for ; Tue, 7 Apr 2026 23:07:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AC914BA2E07 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9AC914BA2E07 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775603253; cv=none; b=JSVdJbedAqZuF2S4ZdqS2vfwPdULVjOAerQxO/8eWbih+3WIqNoVfwqHu1eiQFFRkUhHnN/N2HWJZOWI48Pi4xr7CDmSltwPmf/3TVbCJl33DP4867mZ83q9IaRLZ/IbcaL5m8GfUY5NSil5HEu7bhgY07yRjMxa0F8vwGs5Dwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775603253; c=relaxed/simple; bh=IakgwjiwvZA2xGWF3pVc0RPzGDzWz7h5yUmsGPAYd28=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=AcrkpChlyZkSDYGlcWUz0ItL+c5s48fDvAa7cG9QQxr+7DNEwvOXF+M/RGSQriWY1ckEqEdkDpeZwe2o4lS+t8jwVQth40v6TTsMwTJTOgNcNlEUcnhyuW7uWGEa206SGK0HHuayyzJw3Q9sYz1uhg+1aYfytvD6kkgdm4Z6km8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AC914BA2E07 Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82cd70febc7so4160096b3a.2 for ; Tue, 07 Apr 2026 16:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775603252; x=1776208052; darn=gcc.gnu.org; h=autocrypt:subject:from:cc:to:content-language:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=+fsYmsuYz3GyNOVqXbzxvnKlhnEs0pdA5ZSQtEf+AjM=; b=fA5MGytJAmrN2T2Im2Dib1H+j/tos32zjpOHByuAskdncojaLKv0OGQO7XZpXtR/Zx yoZcq8taNcxC5O8/Z0Gv9JeF6ihrTRHfou89a6Q/Md+xYq43nwLaq9CPNl7rddCg04y6 +R1twtdQq6KMK/Ig4nBc2Lh+KErOoDxCvvoutClGvwymTWFjIVjZCnUGRyVGmg23bcpa EYmumNNjwHZxkZPOUQFzPyeBy4PTk0X9NFinTAcBq3107CCKLMIvcXGLbib8E1L6Rbg7 CvRJXfQFKibaKw8rehvqbA8c+7WtO6JtF3l/WRF/EUyx1xjLQWxb2gM7jhKXuQIoWCgl kQHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775603252; x=1776208052; h=autocrypt:subject:from:cc:to:content-language:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+fsYmsuYz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YS2fGYwkV/QlijftAoRucCqS5ugCg= X-Received: by 2002:a05:6a00:2393:b0:827:447f:7dbd with SMTP id d2e1a72fcca58-82d0dba1332mr18822204b3a.46.1775603252408; Tue, 07 Apr 2026 16:07:32 -0700 (PDT) Received: from [10.168.168.66] ([50.37.179.80]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b589b8sm18402922b3a.24.2026.04.07.16.07.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Apr 2026 16:07:31 -0700 (PDT) Message-ID: Date: Tue, 7 Apr 2026 16:07:30 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gfortran , gcc-patches Cc: Paul Richard Thomas , Christopher Albert From: Jerry D Subject: [PATCH,fortran] Fix Bug 96986 - [13/14/15/16 Regression] Explicit interface required: volatile argument for ENTRY Autocrypt: addr=jvdelisle2@gmail.com; keydata= xjMEY5TlkxYJKwYBBAHaRw8BAQdAyrkRDhmJhSTTlV/50gJLlvliU6/Lm5C9ViKV8T9y1GnN HkplcnJ5IEQgPGp2ZGVsaXNsZTJAZ21haWwuY29tPsKJBBMWCAAxFiEEOFR0TS0390uh8dRV uWXAJaWpwWoFAmOU5ZMCGwMECwkIBwUVCAkKCwUWAgMBAAAKCRC5ZcAlpanBalsJAP4wdCiH 2Of9oZv1QWgZ/AVdbWFM3Fv47/WZQHOXfoZ9HgD6AkXrKeJ+6usST7PEaDJjptaViT1fLiYY V/6XaOKSsgLOOARjlOWTEgorBgEEAZdVAQUBAQdAdA7PczYnl07vnOT9oP/wvvMDd4HP09Zl g3LzwXQJWT8DAQgHwngEGBYIACAWIQQ4VHRNLTf3S6Hx1FW5ZcAlpanBagUCY5TlkwIbDAAK CRC5ZcAlpanBasF/AQCa5WjlsVpLsEiggZyT18MOJNAdeRd7wkGDUrwedHrvawD/cE1H+/Ms L1ZwvQiLfGdx8crigQqWTQyos4kH8Wx82wc= X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org The attached patch avoids a bogus error given on valid code. Regression tested on x86_64. I plan to commit this one sometime tomorrow. Regards, Jerry --- Author: Christopher Albert Date: Sun Mar 29 21:52:37 2026 +0200 fortran: Fix false explicit-interface-required for ENTRY with volatile [PR96986] When resolving a call to an ENTRY procedure, the entry lookup that replaces the master procedure's def_sym with the specific entry symbol was inside the 'resolved != -1' block. During recursive resolution the namespace is marked resolved == -1, so the lookup was skipped and the explicit interface check used the master procedure's combined formal argument list instead of the entry's own formals. Move the entry lookup after the resolution block so it runs regardless of the namespace resolution state. PR fortran/96986 gcc/fortran/ChangeLog: * resolve.cc (resolve_global_procedure): Move entry symbol lookup outside the resolved != -1 block. gcc/testsuite/ChangeLog: * gfortran.dg/pr96986.f90: New test. Signed-off-by: Christopher Albert commit 7d0ee2cfe3f46f272fd2c4632c6ff85f66235399 Author: Christopher Albert Date: Sun Mar 29 21:52:37 2026 +0200 fortran: Fix false explicit-interface-required for ENTRY with volatile [PR96986] When resolving a call to an ENTRY procedure, the entry lookup that replaces the master procedure's def_sym with the specific entry symbol was inside the 'resolved != -1' block. During recursive resolution the namespace is marked resolved == -1, so the lookup was skipped and the explicit interface check used the master procedure's combined formal argument list instead of the entry's own formals. Move the entry lookup after the resolution block so it runs regardless of the namespace resolution state. PR fortran/96986 gcc/fortran/ChangeLog: * resolve.cc (resolve_global_procedure): Move entry symbol lookup outside the resolved != -1 block. gcc/testsuite/ChangeLog: * gfortran.dg/pr96986.f90: New test. Signed-off-by: Christopher Albert diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 9152e7f7146..eac6e81c233 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -2787,17 +2787,22 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, int sub) /* This can happen if a binding name has been specified. */ if (gsym->binding_label && gsym->sym_name != def_sym->name) gfc_find_symbol (gsym->sym_name, gsym->ns, 0, &def_sym); + } - if (def_sym->attr.entry_master || def_sym->attr.entry) - { - gfc_entry_list *entry; - for (entry = gsym->ns->entries; entry; entry = entry->next) - if (strcmp (entry->sym->name, sym->name) == 0) - { - def_sym = entry->sym; - break; - } - } + /* Look up the specific entry symbol so that interface checks use + the entry's own formal argument list, not the entry master's. + This must run even when resolved == -1 (recursive resolution in + progress), because def_sym starts as the namespace proc_name + which is the entry master with the combined formals. */ + if (def_sym->attr.entry_master || def_sym->attr.entry) + { + gfc_entry_list *entry; + for (entry = gsym->ns->entries; entry; entry = entry->next) + if (strcmp (entry->sym->name, sym->name) == 0) + { + def_sym = entry->sym; + break; + } } if (sym->attr.function && !gfc_compare_types (&sym->ts, &def_sym->ts)) diff --git a/gcc/testsuite/gfortran.dg/pr96986.f90 b/gcc/testsuite/gfortran.dg/pr96986.f90 new file mode 100644 index 00000000000..56ee6717a9a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr96986.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! +! PR fortran/96986 +! Calling an ENTRY with no volatile arguments incorrectly required an +! explicit interface because the volatile attribute from a sibling ENTRY +! was checked against the master procedure's combined formal list. + +subroutine volatile_test () + implicit none + integer, volatile :: va + + entry fun_a() + return + + entry fun_b(va) + call fun_c() + return +end subroutine volatile_test + +subroutine fun_c () + implicit none + call fun_a() ! Must not require explicit interface + return +end subroutine fun_c