From patchwork Wed Apr 17 16:43:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 1924682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=k1wKMron; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VKRZV15z0z1yZ2 for ; Thu, 18 Apr 2024 02:44:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71B15384AB7F for ; Wed, 17 Apr 2024 16:44:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 1821D3858D20; Wed, 17 Apr 2024 16:43:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1821D3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1821D3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1031 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713372231; cv=none; b=TTB2ydmE1HlsWvqR9FxAexY85SVP3FRI0WHKBu6yUEI5wmDRuYZxhwkNfgqx0BHZSQreuAliEakBKuup965lyc9vQO06LYu8qEYjv2ahxhz0JvvAVshMyGlqUxxPU47EeI92C8Hohb+uTK5/bGfbopyyAi6reMHLFDizmtKZ0bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713372231; c=relaxed/simple; bh=XcIr/rVaBha2PbKaHl9qkBHPj68uFW6VPbKujdixHHs=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=OT+xyyzupD82r/wEYhGD5vkilIXo/s1MxWaU0sT2qTFkX5Mxou2nmYV2YG+7Ap+WE2ixKBZVazwW/E+j9vdG+15yGarVecKnfrWqaRAeKZbX859bhNIGTqJ3CTn0XL0rF7ha+T11fED2Rw8R4FUISs/5l2bNJtsM74jYe+5i9vk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2a53b331400so3609336a91.1; Wed, 17 Apr 2024 09:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713372226; x=1713977026; darn=gcc.gnu.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=IGoWGQQoafY7PnrdsxI0AqadFUwH6xC9KJI2+7kb5VI=; b=k1wKMronV+qtn9oQqnv1diwQEeYrb/AxCN8S+sTjf6GfEXmulPR9w+BtpQBkBb3dJ1 vE/j5huxb9bxTcBSbX0QL/oyG+KBsV6EAmWUx7L51BV2pWidf5XT1E+przZB8JSxOfoa VxP3I1+gSBiBupny99sFM1xfpOo0Ub7BRoqMVGzBfBqVIeLyvHhQ+bcYUQrWeSRZ3z5A UqIkLr+xNUtZzDPKYDcwAQ6vACyYcJ0kn7UcZXZCBHGMTZmwrX3aJ3WtNLf8IHgr1+lJ v+bbXnE+PbBMH0M88wc+UtGAdg07k79YTZsMbQA5PlQ/2LW/jN1dVrfHa2GBwDL8CWU+ dQDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713372226; x=1713977026; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IGoWGQQoafY7PnrdsxI0AqadFUwH6xC9KJI2+7kb5VI=; b=K9Z2eCgh7ifsQxSMnlpsTjPcPWd+dC6Galr5sJcoOn+lGcPMTmGu0Z1PoC+qwKB1Oi XmHw8XfmhVbOXSBgQbqN2fNphHuySHTq2jKzV1CRRjTphXIa0JKPCZqAm2v/JaMcEM08 LY1jGOkvUYtH0G/vGhldLzKOov+MuWdpbeZKHn2DET9Eda4nUHu2lxWEfMb/CjXUp9ys 8+Eh6R5l/tyY2l8grM1Kvg4HFQLCdfEsYUVq4mZJCs03khmjjG3JAVyP9gV9FcNVjcc9 EKAvZOym9OdJKpTGIoACHhP97X4SokLmAKiKLUjJYQ3aoiD7EFfODgAmXWp6J6khutyO n8OA== X-Forwarded-Encrypted: i=1; AJvYcCUBJENzv5EgVJx+AIUKBTqwRBMlJSSDviOyBpI4KfNOtppFv5yv+27zssAlcHJBNp0OTlTcOBmQvdCDrWwiqJXBpiITD4kkeA== X-Gm-Message-State: AOJu0YzsLy0gwGzppQr/jo4VSx/4FNAj7eNW/y+lSfuWLbi/LaqUcQYc RyfPYxhDKgVIpHjXL0w5ndM5yyRAVd35E/jIVj8el9R6fwRGd9GRqdDN+FIc7cE0+WcbQXXYXKW byG3UQQz8nx8tT1vTyCnKvIpHJ+pScqS2 X-Google-Smtp-Source: AGHT+IFj3mz0F3yB8CLK4JVCAo0SZ+G7HiP7tVr2vNVT/6FNf09rTWi+p0DXRA6KIT3EzbfCH4+UcXm4yzLtQM8JI+E= X-Received: by 2002:a17:90a:8cf:b0:2a4:f53d:e6bc with SMTP id 15-20020a17090a08cf00b002a4f53de6bcmr15222661pjn.15.1713372225393; Wed, 17 Apr 2024 09:43:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Paul Richard Thomas Date: Wed, 17 Apr 2024 17:43:33 +0100 Message-ID: Subject: [Patch, fortran] PR114739 [14 Regression] ice in gfc_find_derived_types, at fortran/symbol.cc:2458 To: "fortran@gcc.gnu.org" , gcc-patches X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This ICE was caused by my patch r14-9489-g3fd46d859cda10. However, the ICE hid a wrong error going back to at least 6.4.1 20180703. The patch fixes both and exposed incorrect error messages in existing tests in gfortran.dg. The fix for these was to add 'IMPLICIT NONE' in call cases so that there really is no implicit type. Regtests OK - I will commit in 24 hours time, if there are no objections and will backport in a couple of weeks. Paul Fortran: Fix ICE in gfc_match_varspec and error messages [PR114739] 2024-04-17 Paul Thomas gcc/fortran PR fortran/114739 * primary.cc (gfc_match_varspec): Check for default type before checking for derived types with the right component name. gcc/testsuite/ PR fortran/114739 * gfortran.dg/pr114739.f90: New test. * gfortran.dg/derived_comp_array_ref_8.f90: Add 'implicit none' for consistency with expected error message. * gfortran.dg/nullify_4.f90: ditto * gfortran.dg/pointer_init_6.f90: ditto * gfortran.dg/pr107397.f90: ditto * gfortran.dg/pr88138.f90: ditto diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 5dd6875a4a6..3c64fa73dfa 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -2236,6 +2236,15 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, match mm; old_loc = gfc_current_locus; mm = gfc_match_name (name); + + /* Check to see if this is default complex. */ + if (sym->ts.type == BT_UNKNOWN && tgt_expr == NULL + && gfc_get_default_type (sym->name, sym->ns)->type != BT_UNKNOWN) + { + gfc_set_default_type (sym, 0, sym->ns); + primary->ts = sym->ts; + } + /* This is a usable inquiry reference, if the symbol is already known to have a type or no derived types with a component of this name can be found. If this was an inquiry reference with the same name diff --git a/gcc/testsuite/gfortran.dg/derived_comp_array_ref_8.f90 b/gcc/testsuite/gfortran.dg/derived_comp_array_ref_8.f90 index 739f4adfb78..22dfdc668a6 100644 --- a/gcc/testsuite/gfortran.dg/derived_comp_array_ref_8.f90 +++ b/gcc/testsuite/gfortran.dg/derived_comp_array_ref_8.f90 @@ -2,6 +2,7 @@ ! ! PR fortran/52325 ! +implicit none real :: f cc%a = 5 ! { dg-error "Symbol 'cc' at .1. has no IMPLICIT type" } f%a = 5 ! { dg-error "Unexpected '%' for nonderived-type variable 'f' at" } diff --git a/gcc/testsuite/gfortran.dg/nullify_4.f90 b/gcc/testsuite/gfortran.dg/nullify_4.f90 index 0fd5056ee07..240110fabf8 100644 --- a/gcc/testsuite/gfortran.dg/nullify_4.f90 +++ b/gcc/testsuite/gfortran.dg/nullify_4.f90 @@ -3,6 +3,7 @@ ! ! Check error recovery; was crashing before. ! +implicit none real, pointer :: ptr nullify(ptr, mesh%coarser) ! { dg-error "Symbol 'mesh' at .1. has no IMPLICIT type" } end diff --git a/gcc/testsuite/gfortran.dg/pointer_init_6.f90 b/gcc/testsuite/gfortran.dg/pointer_init_6.f90 index 3abad4ae179..477626e66bb 100644 --- a/gcc/testsuite/gfortran.dg/pointer_init_6.f90 +++ b/gcc/testsuite/gfortran.dg/pointer_init_6.f90 @@ -21,7 +21,7 @@ end module m1 module m2 - + implicit none type :: t procedure(s), pointer, nopass :: ppc end type diff --git a/gcc/testsuite/gfortran.dg/pr107397.f90 b/gcc/testsuite/gfortran.dg/pr107397.f90 index fd59bf16007..f77b4b00d00 100644 --- a/gcc/testsuite/gfortran.dg/pr107397.f90 +++ b/gcc/testsuite/gfortran.dg/pr107397.f90 @@ -1,6 +1,7 @@ !{ dg-do compile } ! program p + implicit none type t real :: a = 1.0 end type diff --git a/gcc/testsuite/gfortran.dg/pr114739.f90 b/gcc/testsuite/gfortran.dg/pr114739.f90 new file mode 100644 index 00000000000..eb82cb3f65b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr114739.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! The fix here was triggered by an ICE prior to r14-9489-g3fd46d859cda10 +! Before that gfortran gave an incorrect "no implicit type" error for all +! three statements. +program main + implicit complex(z) + implicit character(c) + z2%re = 1. + z2%im = 2. + print *, z2, c%kind +end diff --git a/gcc/testsuite/gfortran.dg/pr88138.f90 b/gcc/testsuite/gfortran.dg/pr88138.f90 index c4019a6ca2e..f1130cf2bab 100644 --- a/gcc/testsuite/gfortran.dg/pr88138.f90 +++ b/gcc/testsuite/gfortran.dg/pr88138.f90 @@ -1,5 +1,6 @@ ! { dg-do compile } program p + implicit none type t character :: c = 'c' end type