From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by sourceware.org (Postfix) with ESMTPS id 9297F3858D20; Sun, 19 Nov 2023 00:04:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9297F3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: sourceware.org; spf=none smtp.mailfrom=troutmask.apl.washington.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9297F3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=128.95.76.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700352253; cv=none; b=BhUXhKfIolDdoOt+RVhiDhAmb3PLiUlKI0AmMP0gfVWDihAWnDWYau02b1ptiQBeyXECrBLx7Smm1TXPoJYT42HZHMdFxv9w6LUu5C8WfvEmVr5mVYdNkPoOvbGZqCaCkYMJGKmHSWMhbI55LpTr/msTBz9or+D6BNjHucN11jM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700352253; c=relaxed/simple; bh=pOWFpd4y0DFsgai2BIp1IiOjulYQy5pLpf4gVKWu/L4=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=hGtLSSYMvRLIojHSofUlmr+7d08XCV+/mkdQKZMTMBBvuEw+ygi1jtVFLQ4/JljdaAe8pUcN0WC560Vr5k6eXWh7ZHyaT3r44Z8T9NCno/9vMsNnz0Hczf/X6pg3PETZOrKz2P65i307IQqbdRFzaorVFEMk3rwUVETGJU4TsQY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.17.1/8.17.1) with ESMTP id 3AJ04ACQ038511; Sat, 18 Nov 2023 16:04:10 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.17.1/8.17.1/Submit) id 3AJ049mh038510; Sat, 18 Nov 2023 16:04:09 -0800 (PST) (envelope-from sgk) Date: Sat, 18 Nov 2023 16:04:09 -0800 From: Steve Kargl To: Harald Anlauf Cc: fortran , gcc-patches Subject: Re: [PATCH] Fortran: restrictions on integer arguments to SYSTEM_CLOCK [PR112609] Message-ID: Reply-To: sgk@troutmask.apl.washington.edu References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, Nov 18, 2023 at 11:12:55PM +0100, Harald Anlauf wrote: > > Fortran 2023 added restrictions on integer arguments to SYSTEM_CLOCK. > The attached patch implements these. > > I was struggling with the way we should handle features that are sort-of > deleted in a new standard, but not described as such in the standard, > which is why we do not have GFC_STD_F2023_DEL. As -std=gnu should not > apply this restriction, I came up with the solution in the patch. > While playing, I hit a gcc_unreachable in notify_std_msg due to a > missing case, also fixed. > > Interestingly, the standard now has a recommendation: > > 16.9.202 SYSTEM_CLOCK > > It it recommended that all references to SYSTEM_CLOCK use integer > arguments with a decimal exponent range of at least 18. ... > > In case the user chooses integer(4), shall we emit a warning > e.g. under -pedantic, or some other flag? This is not done > in the patch, but could be added. > > Regtested on x86_64-pc-linux-gnu. OK for mainline? > Not in its current form. > { > + int first_int_kind = -1; > + bool f2023 = ((gfc_option.allow_std & GFC_STD_F2023) != 0 > + && (gfc_option.allow_std & GFC_STD_GNU) == 0); > + If you use the gfc_notify_std(), then you should not need the above check on GFC_STD_GNU as it should include GFC_STD_F2023. > > + if (f2023 && count->ts.kind < gfc_default_integer_kind) > + { > + gfc_error ("Fortran 2023: COUNT argument to SYSTEM_CLOCK " > + "at %L must have kind of at least default integer", > + &count->where); > + return false; > + } Elsewhere in the FE, gfortran uses gfc_notify_std() to enforce requirements of a Fortran standard. The above would be if (count->ts.kind < gfc_default_integer_kind && gfc_notify_std (GFC_STD_F2023, "COUNT argument to SYSTEM_CLOCK " "at %L must have kind of at least default integer", &count->where)) Note, gfc_notify_std() should add the 'Fortran 2023: ' string, if not, that should be fixed. Of course, I seldom provide patches if others don't have a comment then do as you like. -- Steve