From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 995DB3858D28; Tue, 2 Apr 2024 22:15:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 995DB3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712096148; bh=au9R1i52KVQRLpdoqrlbzPleynKg/EcG85g27TAdrCY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BKef3w5a7fMfAHgSxF7OM3nxasLTabwdvwXuDV8CO176fEKVRfiHpwNi6M8lTzIMN z6aVcHrct7nFY0kdVrYC/rC9Tc28Iezlz59kUX+5wzsMjZrsLHit4KLK+yF0bQ4rlo SvzUm/4c7OPDn7FJuwUX6Hvx5DVJ/Rc07GLcQRj4= From: "kargls at comcast dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113412] ATAN(Y,X) does not check arguments and generates wrong error message. Date: Tue, 02 Apr 2024 22:15:48 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargls at comcast dot net X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 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=3D113412 --- Comment #5 from kargls at comcast dot net --- (In reply to anlauf from comment #4) > (In reply to kargls from comment #3) > > Created attachment 57109 [details] > > patch > >=20 > > The attached patch has been regtested. There were no regression. >=20 > Steve, >=20 > I just tried your patch. While it fixes comment#0, it misses: >=20 > print *, atan(1.d0,1.0) > end >=20 Ugh. I forgot literal constants don't have symtrees or names. :( gfc_error ("%qs argument of %qs intrinsic at %L must be the same type " "and kind as %qs", (*ap)->next->expr->symtree->name, name, &(*ap)->next->expr->where, (*ap)->expr->symtree->name); The pointers to expr->symtree is NULL. This new patch catches your example. diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc index c35f2bdd183..a8a92874583 100644 --- a/gcc/fortran/intrinsic.cc +++ b/gcc/fortran/intrinsic.cc @@ -4371,7 +4371,19 @@ sort_actual (const char *name, gfc_actual_arglist **= ap, goto do_sort; whoops: - gfc_error ("Too many arguments in call to %qs at %L", name, where); + if ((gfc_option.allow_std & GFC_STD_F2008) !=3D 0 + && strcmp(name, "atan") =3D=3D 0) + { + if ((*ap)->expr->symtree =3D=3D NULL || (*ap)->next->expr->symtree = =3D=3D NULL) + gfc_error ("Arguments of %qs intrinsic at %L must have the same " + "type and kind", name, &(*ap)->expr->where); + else + gfc_error ("%qs argument of %qs intrinsic at %L must be the same " + "type and kind as %qs", (*ap)->next->expr->symtree->name, + name, &(*ap)->next->expr->where, (*ap)->expr->symtree->name); + } + else + gfc_error ("Too many arguments in call to %qs at %L", name, where); return false; keywords:=