From patchwork Fri Mar 27 19:25:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1262953 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=acm.org Authentication-Results: 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=20161025 header.b=mWiIb4BA; 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 48psJV2VQrz9sP7 for ; Sat, 28 Mar 2020 06:25:30 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E1C0385E011; Fri, 27 Mar 2020 19:25:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by sourceware.org (Postfix) with ESMTPS id A4120385E006 for ; Fri, 27 Mar 2020 19:25:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A4120385E006 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qv1-xf2c.google.com with SMTP id c28so5481676qvb.10 for ; Fri, 27 Mar 2020 12:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=42aNA83ohqax/ByndyduYGUeG1nGeJfum2ZK1ahfDU8=; b=mWiIb4BAM3kqVuL7qeY7j6WhIBHXJTGgxr7wv0ruiVgHEr/uR96u8LrLbW7BOfQ5+A Xrlv1riiMe5Akdwz1y9zOAjapV0W1JuwBy3M6Ozp8AQpRVVWJQ4ofdkz61F/n9eBPoll 7X52HHXTq6ExzH3oIjmH3NAFBo+83BhkDtnds8Jk0iRdam0Zu2ZChslPxCGFwIj1xrRq kpxluV2Et9DhRobXwPaWYHOYeYLcKy3xLsuqoXDCKyTPL6pTORNZrBEgYvu/TFTyX95L 4/C3g9HkD40cy+snET0L9adHhAI7thRYiNrttgjvKEOnwQ3YQ8Tesv2rG1LxxLp0af38 9KFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=42aNA83ohqax/ByndyduYGUeG1nGeJfum2ZK1ahfDU8=; b=Aasye+F1DmekkpUffuNMnGu81VkzT9w6Izkq8EjzVuLAsAk0XtboFL01gIW6cIJn7g TYYhohpSbb275PBz3bRKDCG+WWI1kNF8Y1fyezthILOtMl+DuI2Erw90dITrJQXOm5ql IeVweWRCZYGQHFXIq5awYEmf43PySKyq6jYtdE0W1SL67cVCpLJHzWvzVKV7dma0N1Vp ohi8gVJnwPxjm0LL/4/g5OeeGln+qFM8fhr/arSdXKC6056NF53kxPL1MhE2hyi+VtP6 PT0RWU04o1TSuL2B+oT0z8NvhW5CynB4h2jcC3fNFNzWsNpMTS5aHLHQOjA1ze2sA0we L1wA== X-Gm-Message-State: ANhLgQ2jpSrlVa71aBB5P7fpr+0CMeePVUgvomeujmnZhxTc/ss/fX20 uv2d17Xze7UdACcIgkIM3Cg= X-Google-Smtp-Source: ADFU+vtskb9/yVlr5pwHM1bN5wu8t2McT+ROX2I0EizSFU9B6cpRQ25O6VwbyjUkhQ5yBJOFPrViHA== X-Received: by 2002:a0c:9104:: with SMTP id q4mr828334qvq.61.1585337125928; Fri, 27 Mar 2020 12:25:25 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:4d77:ff9a:934b:6478? ([2620:10d:c091:480::9ef3]) by smtp.googlemail.com with ESMTPSA id f13sm4434694qti.47.2020.03.27.12.25.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Mar 2020 12:25:25 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PR/84733] ICE popping local binding Message-ID: Date: Fri, 27 Mar 2020 15:25:23 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-21.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" We were pushing the variable 'e' into the cleanup pseudo-binding left by the try/catch block, but seeing past that for the implicit type decl for the structure 'e'. this bug seems to happen as far back as I can try -- gcc 6 at least. Fixed by looking through the cleanup binding in both cases. nathan 2020-03-27 Nathan Sidwell PR c++/84733 * name-lookup.c (do_pushdecl): Look through cleanp levels. diff --git c/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c index e6dfb9cc723..8dd0b0d723e 100644 --- c/gcc/cp/name-lookup.c +++ w/gcc/cp/name-lookup.c @@ -2998,7 +2998,8 @@ do_pushdecl (tree decl, bool is_friend) /* The binding level we will be pushing into. During local class pushing, we want to push to the containing scope. */ cp_binding_level *level = current_binding_level; - while (level->kind == sk_class) + while (level->kind == sk_class + || level->kind == sk_cleanup) level = level->level_chain; /* An anonymous namespace has a NULL DECL_NAME, but we still want to diff --git c/gcc/testsuite/g++.dg/lookup/pr84733.C w/gcc/testsuite/g++.dg/lookup/pr84733.C new file mode 100644 index 00000000000..d0394eab891 --- /dev/null +++ w/gcc/testsuite/g++.dg/lookup/pr84733.C @@ -0,0 +1,21 @@ +// { dg-do compile { target c++11 } } +// PR c++/84733 ICE popping local binding after cleanup region + +struct c { + ~c(); +} b; + +void f() { +#ifndef OK + try { + d: + ; + } catch (int) { + } +#endif + decltype(b) a; + int e; + struct e { } f; + e = 5; + struct e j; +}