From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7C8C83858404; Thu, 28 Dec 2023 15:21:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C8C83858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703776862; bh=0uMMsM82aVg775TJrhe36RY3tQKVEH6LpI9Wuh4do/o=; h=From:To:Subject:Date:From; b=SHI/uvb8hVgA/tdG3ATP24hdMqtfLGlGxHQlW2mK6Og+JDj2YnFSwNEQ35q6y0OL8 jWi2CLlElfL+b7bILzgz3WF8O9lHGobqNKJHHlfouuORiCHmlTCt4X6XPvpmz9rfkQ o4PuggZGlH/Ws+hPeQgSe6CPKdLhhO+gU+0cI028= From: "xecej4 at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113165] New: Code containing more than one type declaration for a variable results in confusing error messages from compiler Date: Thu, 28 Dec 2023 15:21:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xecej4 at outlook dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113165 Bug ID: 113165 Summary: Code containing more than one type declaration for a variable results in confusing error messages from compiler Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: xecej4 at outlook dot com Target Milestone: --- Created attachment 56960 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D56960&action=3Dedit Fixed form Fortran77 source file that causes compiler to issue confusing messages Some old Fortran codes (e.g., www.netlib.org/ode/epsode.f ) may contain duplicate declarations of some variables. Lines 1239-1241 of epsode.f: double precision eps, epsj, h, hmax, hmin, pw, save1, save2, 1 ss, t, uround, ymax double precision d, r, r0, t, yj The variable t is declared twice, albeit with the same type and kind. Gfortran correctly flags this error, but seems to go farther and mark the variable t as implicitly typed single precision REAL, causing the issuing a number of misleading error messages when the concerned variable is used in expressions later on in the program unit. I enclose a short program to illustrate. Please compile the program with (a= ) no options, (b) with -Wall and (c) with -fimplicit-none. Case (c) results in: muldecl.f:4:24: 4 | double precision d,q,r ! 'd' was already declared as double prec. | 1 Error: Symbol 'd' at (1) already has basic type of REAL muldecl.f:7:7: 7 | r =3D sqrt(d) | 1 Error: Symbol 'r' at (1) has no IMPLICIT type I suspect that the multiple declaration of d has caused even the unrepeated declaration of r to be tainted.=