From patchwork Sun Jun 14 12:43:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1308938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=lj2p35Se; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49lDff0fD0z9sQx for ; Sun, 14 Jun 2020 22:43:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 873D3383E83E; Sun, 14 Jun 2020 12:43:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 873D3383E83E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592138628; bh=WjSeOtgXj909r5fGWz1dU2panxaWxMvspjRRdgtLGuw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lj2p35SeNmUZDPUWWObpB9DZ5R2b0hMncCcfXbG0jPf/jR6rzRWQ8LJYszCfVxl7w 2H89GRUF1lvsDkLXKS3OWctJs2GE7W3tQqhH2YB7cw+2YeCzDV6yeJyTsiHqqhj1Ob WUTDkPlf7jWTc9vKaumBakFBRYKlt3nC5bDuOWHo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cc-smtpout2.netcologne.de (cc-smtpout2.netcologne.de [89.1.8.212]) by sourceware.org (Postfix) with ESMTPS id 4D791383F86F; Sun, 14 Jun 2020 12:43:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4D791383F86F Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id BFBCB12933; Sun, 14 Jun 2020 14:43:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id B75DE11ED7; Sun, 14 Jun 2020 14:43:43 +0200 (CEST) Received: from [2001:4dd6:36e3:0:5b1c:29fc:15e7:fe34] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.11.6) (envelope-from ) id 5ee61b7f-7104-7f0000012729-7f000001a41e-1 for ; Sun, 14 Jun 2020 14:43:43 +0200 Received: from linux-p51k.fritz.box (2001-4dd6-36e3-0-5b1c-29fc-15e7-fe34.ipv6dyn.netcologne.de [IPv6:2001:4dd6:36e3:0:5b1c:29fc:15e7:fe34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sun, 14 Jun 2020 14:43:42 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran, committed] Fix PR 95037, NULL location in error message Message-ID: <6bedabd5-5b1a-cc8f-e8b1-fd91d5ed490c@netcologne.de> Date: Sun, 14 Jun 2020 14:43:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 Content-Language: de-DE X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Thomas Koenig via Gcc-patches From: Thomas Koenig Reply-To: Thomas Koenig Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, I just committed as obvious and simple the attached patch, as r11-1297-g4644e8f15f835a9934a8d289ee08ba4cb46cbfac . Regards Thomas Always use locations from get and put arguments for error messages. A simple and obvios patch - the error location was taken from a variable that was not initialized for optional variables. gcc/fortran/ChangeLog: * check.c (gfc_check_random_seed): Always use locations from get and put arguments for error messages. gcc/testsuite/ChangeLog: * gfortran.dg/random_seed_4.f90: New test. diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 148a3269815..9c9552404f3 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -6643,7 +6643,7 @@ gfc_check_random_seed (gfc_expr *size, gfc_expr *put, gfc_expr *get) gfc_error ("Size of %qs argument of %qs intrinsic at %L " "too small (%i/%i)", gfc_current_intrinsic_arg[1]->name, gfc_current_intrinsic, - where, (int) mpz_get_ui (put_size), seed_size); + &put->where, (int) mpz_get_ui (put_size), seed_size); } if (get != NULL) @@ -6675,7 +6675,7 @@ gfc_check_random_seed (gfc_expr *size, gfc_expr *put, gfc_expr *get) gfc_error ("Size of %qs argument of %qs intrinsic at %L " "too small (%i/%i)", gfc_current_intrinsic_arg[2]->name, gfc_current_intrinsic, - where, (int) mpz_get_ui (get_size), seed_size); + &get->where, (int) mpz_get_ui (get_size), seed_size); } /* RANDOM_SEED may not have more than one non-optional argument. */ diff --git a/gcc/testsuite/gfortran.dg/random_seed_4.f90 b/gcc/testsuite/gfortran.dg/random_seed_4.f90 new file mode 100644 index 00000000000..4c3afe5f928 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/random_seed_4.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/95037 +! This led to a segfault or a confusing error message. Original +! test case by Bill Long. + +subroutine my_random_seed_v (size, put, get) +integer, optional :: size +integer, optional :: put(1) +integer, optional :: get(1) +call random_seed (size, get=get) ! { dg-error "too small" } +call random_seed (size, put=put) ! { dg-error "too small" } +call random_seed (size, get=get, put=put) ! { dg-error "too small" } +end subroutine my_random_seed_v +