From patchwork Fri May 22 18:42:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1296439 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=8.43.85.97; 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=MzxNQraa; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 49TFjM5YD0z9sRf for ; Sat, 23 May 2020 04:42:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CEE2383E83C; Fri, 22 May 2020 18:42:42 +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.15.18]) by sourceware.org (Postfix) with ESMTPS id C373D386F471; Fri, 22 May 2020 18:42:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C373D386F471 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=1590172957; bh=3kcGrNYo8E1FFF5q4JvPfh2Q3hloEV02WkHVdYlkO/c=; h=X-UI-Sender-Class:From:To:Subject:Date; b=MzxNQraahI6pg7U9A3EDQ5xjL+c7TPR1QrZvLoHcAB/I6vpIjrVrpsggIYelDv+Ha MXOmZCZhWDG0nR2lJAgyMTSJWe+azD2vvwppMvg0w0dOqa6I71422HJpi84CMftSIj AhH7t2ChBr2330npQg8AKl1IQLdg0zD9FaVlBPU0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.88.141] ([93.207.88.141]) by web-mail.gmx.net (3c-app-gmx-bs60.server.lan [172.19.170.144]) (via HTTP); Fri, 22 May 2020 20:42:37 +0200 MIME-Version: 1.0 Message-ID: From: "Harald Anlauf" To: fortran , gcc-patches Subject: [Patch] PR fortran/95106 - truncation of long symbol names with EQUIVALENCE Date: Fri, 22 May 2020 20:42:37 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:K7KMgqam9aokzxPegcIxnBwzyn4w9NpuG8czIxciJxJJI2jUpjoxVtIJwNNX8f/dKKyfP Hjps67VVu91efumO8oazyppMJ4hwZ59YMitENa+OgqZmEfi6NanT1tnp573zEXaFJLbM5osD85kT XBTMxx7DU+OrudS1/TuB7mpGCXB6W7+lHsaFEWJgPEVtcCg4wkwBUztRq+CQ9GqeN5GB24d5QMW4 QtPV36yfYIio67fwq9XLK/83nX8ejipANUXdXdR0XyVQmw/G4kp5JN5pQZh89E6+fduOhz8uKV7h DQ= X-UI-Out-Filterresults: notjunk:1;V03:K0:zJ/Sm0NPGU4=:3nbcVAACeWFL2FrEVGcx+N xkrCxFRqMGCcdVf/m3VVFFexao8H+f/YSlzVeVYE/1lA/8jlP+mnnziShfDdXj2VX3acds3Zs 9CZBDA3voR5b5rUGSLseFzJk7Y3PYMUVS57X/6LWwAkeaFJG5C4VaP64qonRnf5pH1Oyl+r4R fnOOS+l5a8WD5eUSP418JqgOdU9d8pjT9SmAOLCKL7zsj/ljg+mKCp8kM+muNK8wx7g9R+GBJ TcDMeRToAQ1izWUbNPZaD9nIEJP2tXv5fV+DQPr+lcD4EMoT8LaLV1ZYFGHF5I5q/rq28ND+S wxfFOtI5CUFdsrewbmIrUbIC/7wmBKBOqHReZauJxgZap0cK8gaC+upooC0Tusg13hVChw/6T depJ7HYwyzCLKuP/GO8+xlp4t2HgKtfn4TQX/lYLxrqdUKv3JkY1VyOxvuf4AnmqazlRYVqI+ PptlJrrU4oDvh26UZFpHHlYu+hGQfsCFGanD/BBNk2PJWbJmBbtiFdidNS1SeFkBlh9DOzGyc vWTrjZtks35V/SvI5muzXujrEhPW0Ocp6SKbIZ5wr80xco0uW/gTe+93xM2v4vp5aqD2VoFFd SW6R+MBpf/z+49jwgE2SZPBJH2Ndg08aUgokuY705W1QlBh4QLfcyK0QLxIw1865+uhd/S+Zo +N84chVIZjA5gCYH+sFyLRJzbGqhwvg6+RU4E2ndLjJ8dhfspJUbewVLzugvosBujk3w= X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, 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" The PR is originally about a bogus warning, which turned out to originate from truncation of mangled names. Fix: simply extend temporaries to hold all possible allowed values (which would enable 2^31 equivalences). Regtested on x86_64-pc-linux-gnu. The testcase checks the presence of properly generated mangled names in the assembler. If this should be restricted to x86-type systems, I can adjust that. OK for master? Thanks, Harald PR fortran/95106 - truncation of long symbol names with EQUIVALENCE For long module names, the generated name-mangled symbol was truncated, leading to bogus warnings about COMMON block mismatches. Provide sufficiently large temporaries. gcc/fortran/ 2020-05-22 Harald Anlauf PR fortran/95106 * trans-common.c (gfc_sym_mangled_common_id): Enlarge temporaries for name-mangling. gcc/testsuite/ 2020-05-22 Harald Anlauf PR fortran/95106 * gfortran.dg/equiv_11.f90: New test. diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index bf163bc4f52..3775a8bea74 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -242,8 +242,9 @@ static tree gfc_sym_mangled_common_id (gfc_common_head *com) { int has_underscore; - char mangled_name[GFC_MAX_MANGLED_SYMBOL_LEN + 1]; - char name[GFC_MAX_SYMBOL_LEN + 1]; + /* Provide sufficient space to hold "symbol.eq.1234567890__". */ + char mangled_name[GFC_MAX_MANGLED_SYMBOL_LEN + 1 + 16]; + char name[GFC_MAX_SYMBOL_LEN + 1 + 16]; /* Get the name out of the common block pointer. */ strcpy (name, com->name); diff --git a/gcc/testsuite/gfortran.dg/equiv_11.f90 b/gcc/testsuite/gfortran.dg/equiv_11.f90 new file mode 100644 index 00000000000..0f4a1ab5c32 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/equiv_11.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-fsecond-underscore" } +! PR fortran/95106 + +module m2345678901234567890123456789012345678901234567890123456789_123 + implicit none + real :: a(4), u(3,2) + real :: b(4), v(4,2) + equivalence (a(1),u(1,1)), (b(1),v(1,1)) +end +! { dg-final { scan-assembler {m2345678901234567890123456789012345678901234567890123456789_123.eq.0__} } } +! { dg-final { scan-assembler {m2345678901234567890123456789012345678901234567890123456789_123.eq.1__} } }