From patchwork Sun Aug 25 11:16:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1152754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507670-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="IuilnIb3"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="m0/e5L2r"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46GXdz5pgLz9s00 for ; Sun, 25 Aug 2019 21:16:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=N3/8wz0W9MtO/jIHPVTw+Jx+xRqGMBkt9zXkL77yF9A1JTlXgz Vk/GYi/FjDI+OGgaegU8yfO44ppxLuFjjL5DwrNxFFxtktZCy04kfUccpLvYtYOY WuQpHOHYIj6BVhuKBNANOvzGXxQ3FNn1UioJCHykDgs9UZyM1Y4nRp/vY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=eqNKqVaeXfGr6ZSfsUuBAAg9MNY=; b=IuilnIb3eEFc2O166Dcl YK+K+iP1m/EMRQtp+441cdiVSL+XYygCoVDE2f+mAw9RCp0i5QTAR5WBEIDBysQ/ gSfPREctBrBgrKE8LvLfFWAtVRRCektRyXIHAgbgjPl/edmHYAVU8kI2K5C4I3N+ VaK45pb+pWsR1i+Pa7HAh+E= Received: (qmail 122000 invoked by alias); 25 Aug 2019 11:16:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 121974 invoked by uid 89); 25 Aug 2019 11:16:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.8 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=hej, kitchen, Accept, END X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Aug 2019 11:16:36 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 4966D1330C; Sun, 25 Aug 2019 13:16:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1566731793; bh=2m9ALuCNnbbDJv/it6S2WdwasnJ3JD4Xzb9qARhI6I0=; h=To:From:Subject:Message-ID:Date:From; b=m0/e5L2r41SbAaCfkGr7egttAt9mHVppB6/eGqILHcPwUzfI+VOf3hpteoBgXC+yZ vw9sWfBhWjxzAfeRizmGFskBk0PoG2+hx0CWgatt/aCEWJWV9QeA095uwl2HWBjmCj /HzBgz/N11+BGTo5jJLOVC5blPIwKRvmq3EZZW1vP9bqx/m3HJuRFfZU4LsIfjvkMv h6qgtEOhtW8h2AJZ9qX1MGiy708xAk2PKuPd6w1sP98yMZUAL2DWo+wfov8du65CE3 OUHu2hlCVwHTRPs6G6QgFCvU+Q87NZUYQp4IpgjIRAwHWI0pWvY+vdgG+zNawZerZK OY8gw0Y1Pp8Dw== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id 3A62311EFF; Sun, 25 Aug 2019 13:16:33 +0200 (CEST) Received: from [2001:4dd7:34e1:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5d626e11-669a-7f0000012729-7f000001c9c4-1 for ; Sun, 25 Aug 2019 13:16:33 +0200 Received: from [IPv6:2001:4dd7:34e1:0:7285:c2ff:fe6c:992d] (2001-4dd7-34e1-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:34e1:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Sun, 25 Aug 2019 13:16:30 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Introduce -fallow-argument-mismatch Message-ID: <344d941a-546d-7c75-926f-4b70296eec73@netcologne.de> Date: Sun, 25 Aug 2019 13:16:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Hello world, attached is a patch introducing the -fallow-argument-mismatch option, to separate this from the general kitchen sink -std=legacy. As discussed, this can only be turned off by -w. Regression-tested on powerpc64le-unknown-linux-gnu. Documentation tested by "make dvi" and "make pdf". OK for trunk? Regads Thomas 2019-08-25 Thomas Koenig PR fortran/91390 PR fortran/91473 * frontend-passes.c (gfc_check_externals): Make gfc_errors_to_warnings conditional on -fallow-argument-mismatch. * invoke.texi: Document -fallow-argument-mismatch. * lang.opt: Add -fallow-argument-mismatch. 2019-08-25 Thomas Koenig PR fortran/91390 PR fortran/91473 * gfortran.dg/used_before_typed_4.f90: Change warning to error. * gfortran.dg/argument_checking_20.f90: New test. Index: gcc/fortran/frontend-passes.c =================================================================== --- gcc/fortran/frontend-passes.c (revision 274907) +++ gcc/fortran/frontend-passes.c (working copy) @@ -5477,9 +5477,9 @@ gfc_check_externals (gfc_namespace *ns) gfc_clear_error (); - /* Turn errors into warnings if -std=legacy is given by the user. */ + /* Turn errors into warnings if the user indicated this. */ - if (!pedantic && !(gfc_option.warn_std & GFC_STD_LEGACY)) + if (!pedantic && flag_allow_argument_mismatch) gfc_errors_to_warnings (true); gfc_code_walker (&ns->code, check_externals_code, check_externals_expr, NULL); Index: gcc/fortran/invoke.texi =================================================================== --- gcc/fortran/invoke.texi (revision 274907) +++ gcc/fortran/invoke.texi (working copy) @@ -116,12 +116,12 @@ by type. Explanations are in the following sectio @table @emph @item Fortran Language Options @xref{Fortran Dialect Options,,Options controlling Fortran dialect}. -@gccoptlist{-fall-intrinsics -fallow-invalid-boz -fbackslash -fcray-pointer @gol --fd-lines-as-code -fd-lines-as-comments -fdec -fdec-structure @gol --fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include @gol +@gccoptlist{-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz @gol +-fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments -fdec @gol +-fdec-structure-fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include @gol -fdec-format-defaults -fdec-blank-format-item -fdefault-double-8 @gol -fdefault-integer-8 -fdefault-real-8 -fdefault-real-10 -fdefault-real-16 @gol --fdollar-ok @gol -ffixed-line-length-@var{n} -ffixed-line-length-none @gol +-fdollar-ok -ffixed-line-length-@var{n} -ffixed-line-length-none @gol -fpad-source -ffree-form -ffree-line-length-@var{n} -ffree-line-length-none @gol -fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol -fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol @@ -232,6 +232,14 @@ available with @command{gfortran}. As a consequen will be ignored and no user-defined procedure with the same name as any intrinsic will be called except when it is explicitly declared @code{EXTERNAL}. +@item -fallow-argument-mismatch +@opindex @code{fallow-argument-mismatch} +Some code contains calls to external procedures whith mismatches +between the calls and the procedure definition, or with mismatches +between different calls. Such code is non-conforming, and will usually +be flagged with an error. This options degrades the error to a +warning. This option is implied by @option{-std=legacy}. + @item -fallow-invalid-boz @opindex @code{allow-invalid-boz} A BOZ literal constant can occur in a limited number of context in Index: gcc/fortran/lang.opt =================================================================== --- gcc/fortran/lang.opt (revision 274907) +++ gcc/fortran/lang.opt (working copy) @@ -365,6 +365,10 @@ d Fortran Joined ; Documented in common.opt +fallow-argument-mismatch +Fortran Var(flag_allow_argument_mismatch) LangEnabledBy(Fortran,std=legacy) +Accept argument mismatches in procedure calls. + faggressive-function-elimination Fortran Var(flag_aggressive_function_elimination) Eliminate multiple function invocations also for impure functions. Index: gcc/testsuite/gfortran.dg/used_before_typed_4.f90 =================================================================== --- gcc/testsuite/gfortran.dg/used_before_typed_4.f90 (revision 274907) +++ gcc/testsuite/gfortran.dg/used_before_typed_4.f90 (working copy) @@ -22,5 +22,5 @@ END SUBROUTINE test PROGRAM main IMPLICIT NONE INTEGER :: arr1(42), arr2(42) - CALL test (3, arr1, 2, arr2) ! { dg-warning "Type mismatch in argument" } + CALL test (3, arr1, 2, arr2) ! { dg-error "Type mismatch in argument" } END PROGRAM main