From patchwork Sat Mar 9 19:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1053864 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-497619-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uBc64oBw"; 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 44Gvbt3R82z9s5c for ; Sun, 10 Mar 2019 06:30:47 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=eLmO2du5Ve4ym+iLBhqgHo3OmXBrWS4inqGQPcLwIPYBtc lDmHAp9SX7vrCc/UJASLEqltW3rVHM6ZD9YiiR13ocIPtZTqO0sfSDGwMcpfvhev M0QRF8uanpgY8vQAgRYXgSb945CKpreKM7sUHdEEZG2QQCpCo63mta7NrljJg= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=V3sxLPYyYFTeIwmpxNoTycttRr0=; b=uBc64oBwOkOaXSoHSy+d C0S3C5z6zKb4cb5HHr7pqL0ImulRBQ17wRvjoDUar3xyRGIzerd5Thul6UqEW/X/ Tgh4Wq7ZcgG/ccrYBfx21pkNJKc/eclRpm1Khq8nYguB2JnphH4JQoMTJu00RxOs JdP6eRtJrPglYlNQU6qYeKw= Received: (qmail 24517 invoked by alias); 9 Mar 2019 19:30:39 -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 24406 invoked by uid 89); 9 Mar 2019 19:30:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=error_at X-HELO: mail-qt1-f173.google.com Received: from mail-qt1-f173.google.com (HELO mail-qt1-f173.google.com) (209.85.160.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Mar 2019 19:30:28 +0000 Received: by mail-qt1-f173.google.com with SMTP id b3so963143qtj.3 for ; Sat, 09 Mar 2019 11:30:25 -0800 (PST) MIME-Version: 1.0 From: Iain Buclaw Date: Sat, 9 Mar 2019 20:30:12 +0100 Message-ID: Subject: [PATCH, PR d/89041] Committed fix for ICE in get_frame_for_symbol To: gcc-patches X-IsSubscribed: yes Hi, This patch changes an assertion into an early return condition, handling the case of delegate literals defined at module scope. Fixing PR d/89041. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r269533. diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 58c8257c63c..e8233b43c67 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -2172,7 +2172,16 @@ get_frame_for_symbol (Dsymbol *sym) fdparent = (FuncDeclaration *) sym; } - gcc_assert (fdparent != NULL); + /* Not a nested function, there is no frame pointer to pass. */ + if (fdparent == NULL) + { + /* Only delegate literals report as being nested, even if they are in + global scope. */ + gcc_assert (fd && fd->isFuncLiteralDeclaration ()); + return null_pointer_node; + } + + gcc_assert (thisfd != NULL); if (thisfd != fdparent) { @@ -2180,8 +2189,8 @@ get_frame_for_symbol (Dsymbol *sym) if (!thisfd->vthis) { error_at (make_location_t (sym->loc), - "is a nested function and cannot be accessed from %qs", - thisfd->toChars ()); + "%qs is a nested function and cannot be accessed from %qs", + fd->toPrettyChars (), thisfd->toPrettyChars ()); return null_pointer_node; } diff --git a/gcc/testsuite/gdc.dg/pr89041.d b/gcc/testsuite/gdc.dg/pr89041.d new file mode 100644 index 00000000000..b62c2db85d4 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr89041.d @@ -0,0 +1,13 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89041 +module pr89041; + +enum dg = delegate {}; + +void fn() +{ + auto var = dg; + + auto inner() { + return dg(); + } +}