From patchwork Thu Nov 26 21:25:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1406902 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=Kge+39qG; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ChrR20Rzlz9s1l for ; Fri, 27 Nov 2020 08:26:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EA143972416; Thu, 26 Nov 2020 21:25:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id 4460B3851C20; Thu, 26 Nov 2020 21:25:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4460B3851C20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=anlauf@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606425953; bh=PHjiedj7YM4sDYICVqAmCGKnXmIv96fSotnwTUgLP9Y=; h=X-UI-Sender-Class:From:To:Subject:Date; b=Kge+39qGgfiwiX2EnLGPol0VoyzhIKq9I3HSsEnCS05RJA5V7Dd5bo6SkVy/xshfy mnEskOUv22JAE8u00d90ThL90MURrRjw6w2mhtd5lh1EFGa4F6U9BVBiKjv/qj8v25 dTpIQLiWyGjYlGJ/Z0Sb39p0mHMLbYmhLMXAGTH4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.80.84] ([93.207.80.84]) by web-mail.gmx.net (3c-app-gmx-bs61.server.lan [172.19.170.145]) (via HTTP); Thu, 26 Nov 2020 22:25:53 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH fortran/95342] - [9/10/11 Regression] ICE in gfc_match_subroutine, at fortran/decl.c:7913 Date: Thu, 26 Nov 2020 22:25:53 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:05VsgL6nfgom6B79GsBa3Uqb80fnQBBJJhUd/hslfTmxRU/R8Eutz9mTQGLZvq0NuioH4 jMD3hbAPF5YElMFMRAyJNtHIxxMBCBd202Q7ZgWwfF/oiZ5nlydY64ue4pCwOqhw46eW8pIJX3fh usFFTJIbnME2uIr8b/v2rrk2LkKuiL+bgM4ZjilVxmqzZW3xg3QkEfzMRr1dGt2YzqiNoc7gDNkw bk3+NtDFZfFLHP7ObsMctc34WHjEr3OKj65jhR1N7WK2trsGuMJVIy+ceiruocxsZNIbjAp36YDj 2M= X-UI-Out-Filterresults: notjunk:1;V03:K0:ff4ClEHXePc=:a5lTBFxjTrynU6RHQv0QMN nw3/pwB92XfKw8bEX+r7IJv759tT5L/SpcYNTCVWaaDRuqFOByc66KVATeMkPtSjG3hjtJlrs VF4EURAZRL5gLfSxH2i/7tX9Qn5mEwtkrbUSE0DJsPcBB2txCAtOdNFuIX0neikYZZ4NeUOCu yzHB5om5E/cqpdMIMlHEG68LU7QZHeMzdjccM4c2ZQ3OoTxD7BUn+XvxBXzEmF/GZy5NMBikx cYoM8T7mUFWhoX2y3JDs50uBPj9IINI9ueitkgI5mt614ryAhC2D8lPSV9rkjqDiXmanNIn9+ on9hLCvoqgSWSAyHemZU0H2osbeg23YnKsASohTzHZR2G8dy8pBofOL0OQ4kNuO690eV+f3cB h5M49ShXtPfArr2FR6WoU2cRMqBpsnVlswMngdXEqviagTPk/+ZdSrSe+85ikj6VRKd+pOBDW 22IrooMbnXT0rnGHZbyhuR7gYJt6zTuoHB3rDiGy5E7CNPMWljSMgTVku83op5xcuCkB6+wMv 9zB1vzkDRznk2d+p4/o9EACK3JKVAuFEiyjoAWQeUENilAMv/JakqX6WuG2snU9Gjutmqz48h NnHeoK0BF7xfg= X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Dear all, two almost obvious, trivial issues issues with NULL pointer dereferences. Steve found the locations, but his solution changes the error messages as compared to 7/8. I've chosen the conservative way which keeps the documented intent of the source code. Regtested on x86_64-pc-linux-gnu. OK for master? Backport to affected 10- and 9-branches? (8.4.1 was/is fine). Thanks, Harald PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913 Add checks for NULL pointers before dereferencing them. gcc/fortran/ChangeLog: PR fortran/95342 * decl.c (gfc_match_function_decl): Avoid NULL pointer dereference. (gfc_match_subroutine): Likewise. gcc/testsuite/ChangeLog: PR fortran/95342 * gfortran.dg/pr95342.f90: New test. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 93a155c5f75..c85ae0de952 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -7408,6 +7408,7 @@ gfc_match_function_decl (void) procedure interface body. */ if (sym->attr.is_bind_c && sym->attr.module_procedure && sym->old_symbol && strcmp (sym->name, sym->old_symbol->name) == 0 + && sym->binding_label && sym->old_symbol->binding_label && strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0) { const char *null = "NULL", *s1, *s2; @@ -7923,6 +7924,7 @@ gfc_match_subroutine (void) procedure interface body. */ if (sym->attr.module_procedure && sym->old_symbol && strcmp (sym->name, sym->old_symbol->name) == 0 + && sym->binding_label && sym->old_symbol->binding_label && strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0) { const char *null = "NULL", *s1, *s2; diff --git a/gcc/testsuite/gfortran.dg/pr95342.f90 b/gcc/testsuite/gfortran.dg/pr95342.f90 new file mode 100644 index 00000000000..41c987d3bbb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95342.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913 + +module m1 + interface + module subroutine s() + end + subroutine s() bind(c) ! { dg-error "EXTERNAL attribute conflicts" } + end ! { dg-error "END INTERFACE" } + end interface +end + +module m2 + interface + module function f() + end + function f() bind(c) + end ! { dg-error "Duplicate EXTERNAL attribute" } + end interface +end