From patchwork Fri Apr 19 16:52:53 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: 88756 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56A003849AFA for ; Fri, 19 Apr 2024 16:53:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 6A4DE3849AFC for ; Fri, 19 Apr 2024 16:53:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A4DE3849AFC 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 6A4DE3849AFC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713545589; cv=none; b=YLmZVjW+d1bIu4V1z05MnGl5IhTuXumshpPutsU+pPYb/GywDzEOC0xpwI3k/U3Q1GdbKNF4LJwP1ksacy8C5GEDFvdiQ2OP7K8woAn7wP9ww1fvRu2FhqC0Fvq05ymksLbCM3v3FbwUhX6bqXaiMHvI+O64IhFQ2LAAAjnwP84= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713545589; c=relaxed/simple; bh=sZMkxUkOxLdG1oSKnEsYH3Uf2EHtfo3DgbwwcK/rEn0=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=esCRUb82qvcOCFfkULFZ7n+hJ4HcK4/hufbqaXyHBYFPDJJ6TZz7qQOJGCv8Whi0Svj8n33LWF9xzXdYBx6UFP7VlGuIX1E7sph7gp3jj2NWnyBwxeENJmwhNNvIMAIvrOGdS+VXZ9GLc+vz28KjveWtbNWq46OPXs7fZyhfs4M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so1361104a12.0; Fri, 19 Apr 2024 09:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713545586; x=1714150386; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=ZpaOTvXIuwueP5brwePmEtta/a4LpwH6HBAvRJ8lHXA=; b=RMI34KkQvu3Ds1WxbZRAYgYz4bqywrU8GICO5k4wX8pAkrvMlhZpPyYxVHcDQKYE1X WzErwrQU4tyZLQLGjnWxtPn+9JtKw+OYk4bi/jgZlOM7t6EXc4kC5Hqe7sKVJMIKxUFl X5FbkkMOveLLbMERLHVlgEH8C8W4/OSFaEcg3mLsrF6ksZlWTLsohkV5hU0/UDzFjdUb aJkN9hZ+oK8xZkBu0KHwV3IWGjbLvFIllNDzV0jzr1kPBNZmzkGlCCuSWcNh3zuLel7M I2wPYGU12HKbji0jElyAWtk0DAmPuSXr5sE01e4hkatI/PRIkY2vyHtvx4FyOmZbsA1t ngvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713545586; x=1714150386; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZpaOTvXIuwueP5brwePmEtta/a4LpwH6HBAvRJ8lHXA=; b=HHAtjxwd4VGuBenREMPRtpE9xm/nExnEq+iO2/jh9e6AbfKl8ZUUnbybgbWM0NSvoy 2tvIb0sakKyvxUr/bTINgQ+y9KI4pBlkN6gxRK83lZD6qWF2ggT5+sRSjgJE0Ajzkp3Q AU+VwjUgpKKHBLJMhohBL8p+wv5BKE9fBIEQF3kygzzDIZheN0FivsjbGvhq3LTKdREg 9dwVNXryR2rKkydR3nrjabMcNqr009euPeOA1Iu7IhMuMREVdrkE1S9ESYfP7IykrPUI DuM7eCiM/ckj+JznACzPpdXDcImYmUvvvhQTjxy9yN2e0eIQKAniZhuoIF3UIXRqjwRJ tNrg== X-Forwarded-Encrypted: i=1; AJvYcCXoYtaw2LVEqLvKjjH3KiNd95axab3hdN3IrhT1ZcyKpBv5EISobhtA5AqUyxMPWkHpYq9ljOlWpVuyqF0ZzoH0aPH9SjmRhg== X-Gm-Message-State: AOJu0YzGZETLNKrYTaIQYp6ZKLskdQXYZfILG5a0oofVPd2hM8UcKLxu ZA6hHCxbPjS5op65jn2Dw2yHyJya6u0aQTrpUXF35p54wB9nUp4xe9SzczvxD/fI3LnKIS7//Ur ynRe+2m6+YOiPAd4+uB18ssIZpdNz7q+R X-Google-Smtp-Source: AGHT+IEt0jdVLS4Fz/xJocg4gPLWj974l2d1UWdANKasr9NmbRXn7OfcKBJXxf2YIxa/a3h9wBFPjVMzkBMIgPwUPFo= X-Received: by 2002:a17:90a:df92:b0:2ab:f9af:cdce with SMTP id p18-20020a17090adf9200b002abf9afcdcemr3097605pjv.36.1713545585748; Fri, 19 Apr 2024 09:53:05 -0700 (PDT) MIME-Version: 1.0 From: Paul Richard Thomas Date: Fri, 19 Apr 2024 17:52:53 +0100 Message-ID: Subject: [Patch, fortran] PR103471 - [11/12/13/14 Regression] ICE in gfc_typenode_for_spec, at fortran/trans-types.c:1114 To: gfortran@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 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+patchwork=sourceware.org@gcc.gnu.org Hi All, This is a more or less obvious patch. The action is in resolve.cc. The chunk in symbol.cc is a tidy up of a diagnostic marker to distinguish where the 'no IMPLICIT type' error was coming from and the chunk in trans-decl.cc follows from discussion with Harald on the PR. Regtests fine. OK for mainline and backporting in a couple of weeks? Paul Fortran: Detect 'no implicit type' error in right place [PR103471] 2024-04-19 Paul Thomas gcc/fortran PR fortran/103471 * resolve.cc (gfc_resolve_index_1): Block index expressions of unknown type from being converted to default integer, avoiding the fatal error in trans-decl.cc. * symbol.cc (gfc_set_default_type): Remove '(symbol)' from the 'no IMPLICIT type' error message. * trans-decl.cc (gfc_get_symbol_decl): Change fatal error locus to that of the symbol declaration. (gfc_trans_deferred_vars): Remove two trailing tabs. gcc/testsuite/ PR fortran/103471 * gfortran.dg/pr103471.f90: New test. diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 6b3e5ba4fcb..9b7fabd3707 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -5001,7 +5001,8 @@ gfc_resolve_index_1 (gfc_expr *index, int check_scalar, if ((index->ts.kind != gfc_index_integer_kind && force_index_integer_kind) - || index->ts.type != BT_INTEGER) + || (index->ts.type != BT_INTEGER + && index->ts.type != BT_UNKNOWN)) { gfc_clear_ts (&ts); ts.type = BT_INTEGER; diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 3a3b6de5cec..8f7deac1d1e 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -320,7 +320,7 @@ gfc_set_default_type (gfc_symbol *sym, int error_flag, gfc_namespace *ns) "; did you mean %qs?", sym->name, &sym->declared_at, guessed); else - gfc_error ("Symbol %qs at %L has no IMPLICIT type(symbol)", + gfc_error ("Symbol %qs at %L has no IMPLICIT type", sym->name, &sym->declared_at); sym->attr.untyped = 1; /* Ensure we only give an error once. */ } diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index e160c5c98c1..301439baaf5 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -1797,7 +1797,8 @@ gfc_get_symbol_decl (gfc_symbol * sym) } if (sym->ts.type == BT_UNKNOWN) - gfc_fatal_error ("%s at %C has no default type", sym->name); + gfc_fatal_error ("%s at %L has no default type", sym->name, + &sym->declared_at); if (sym->attr.intrinsic) gfc_internal_error ("intrinsic variable which isn't a procedure"); @@ -5214,8 +5215,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) tree tmp = lookup_attribute ("omp allocate", DECL_ATTRIBUTES (n->sym->backend_decl)); tmp = TREE_VALUE (tmp); - TREE_PURPOSE (tmp) = se.expr; - TREE_VALUE (tmp) = align; + TREE_PURPOSE (tmp) = se.expr; + TREE_VALUE (tmp) = align; TREE_PURPOSE (TREE_CHAIN (tmp)) = init_stmtlist; TREE_VALUE (TREE_CHAIN (tmp)) = cleanup_stmtlist; } diff --git a/gcc/testsuite/gfortran.dg/pr93484.f90 b/gcc/testsuite/gfortran.dg/pr93484.f90 new file mode 100644 index 00000000000..4dcad47e8da --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103471.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! Test the fix for PR103471 in which, rather than giving a "no IMPLICIT type" +! message, gfortran took to ICEing. The fuzzy symbol check for 'kk' demonstrates +! that the error is being detected in the right place. +! +! Contributed by Gerhard Steinmetz +! +program p + implicit none + integer, parameter :: x(4) = [1,2,3,4] + integer :: kk + print *, [real(x(k))] ! { dg-error "has no IMPLICIT type; did you mean .kk.\\?" } +end