From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 96BB63858D39; Thu, 28 Dec 2023 20:54:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 96BB63858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703796892; bh=zUmsdTA9kV3IUDm4+VgPCPd3S3riyT32BoqM1ADeVgk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Eh0uWYj/0PQyTZcmclczpkGtkkD2Cw93E/dxVzOaHeQe2P7qQMMdMDSdFub+joY4w cmRvYwsDBMB4ETUcrepUWggKowEI6bLD9LOLKkn93Kbxeq6m2ExWrne9yYnFRTpgLl crlukG7JJw9jIvNFPKL/Xj4VTPJDJwNDZDUJX0zU= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113165] Code containing more than one type declaration for a variable results in confusing error messages from compiler Date: Thu, 28 Dec 2023 20:54:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: enhancement X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 --- Comment #2 from kargl at gcc dot gnu.org --- With the attached example code and the patch at the end of this message, gfortran can be changes to identify both lines of code. Fixing the run-on errors when -fimplicit-none is used is left as an exercise for a new contributor or will be ignored until such time as someone closes this bug report. % gfcx -c e.f90 e.f90:3:30: 3 | double precision a,b,c,d,f,g | 1 4 | integer i,j,k,l 5 | double precision d,q,r ! 'd' was already declared as double prec. | 2=20=20=20=20=20=20 Error: Symbol =E2=80=98d=E2=80=99 declared at (1) already has basic type of= REAL and cannot appear in the declaration at (2) diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index a6078bc608a..7fa1839323b 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -2015,8 +2015,9 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where) gfc_error ("Symbol %qs at %L already has basic type of %s", sym->ns->proc_name->name, where, gfc_basic_typename (typ= e)); else - gfc_error ("Symbol %qs at %L already has basic type of %s", sym->na= me, - where, gfc_basic_typename (type)); + gfc_error ("Symbol %qs declared at %L already has basic type of %s " + "and cannot appear in the declaration at %L", sym->name, + &sym->declared_at, gfc_basic_typename (type), where); return false; }=