From patchwork Mon Mar 19 14:04:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 887745 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-474937-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Jv0ekAcq"; 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 404d9p2W8hz9sBF for ; Tue, 20 Mar 2018 01:05:01 +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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=FUuZi6lURhdi1Z9mRH4J9rBbAnck9R8rxnp1y43KVhtGNo9Ji1 0LOw/z32zs2xnXe5+diSJ9k18e9gbAJt6CSbcVWPTAjqJQTchPVxR8bi3AvjFLrv 5fLps7RNgxoEwAmzV4X+BZT9Yr6qVCz4Mo5HqSmf+0+KoBH3fHxAzodys= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=gNdHfE2rz0R0NjW91xw4n58h4O4=; b=Jv0ekAcqKXGUFtGCcxP6 pZIenMg3/6D75ZVOEAGTge/RECD7Bl2YTi8akuzArfofbxg0H0p8NZ6eean5oAyC RPovdOn1RPjShiNh0zusGHMTaBFiJpJnhwOFLlpGG+yQMYwDwH8EClKfOBDAwDWt vuoriaZq79n/1W6ATyt+fXc= Received: (qmail 118993 invoked by alias); 19 Mar 2018 14:04:54 -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 118974 invoked by uid 89); 19 Mar 2018 14:04:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:200, opportunity X-HELO: mail-yw0-f181.google.com Received: from mail-yw0-f181.google.com (HELO mail-yw0-f181.google.com) (209.85.161.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Mar 2018 14:04:52 +0000 Received: by mail-yw0-f181.google.com with SMTP id r145so8639801ywe.7 for ; Mon, 19 Mar 2018 07:04:52 -0700 (PDT) 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=bEMw9F/gxOtC4N9sbZ9cJvqID3GnlNb9e2NPqqfmMwE=; b=nyxVBdFrNfbCw03gFhc/FbW6KdRWNqbXd/aCyhclG57eNEO9SJ3aIPOw/v/lQzsEKK mAqniESUNcDU+J39iXi8ydPfeFzxBHJl0MuIzor6+jl/jfSrkqE2rko2VSRMPWMnDqJx /W8uKJ20xyHXAHqHlnrjXoa38+XgDXEDhwd3b40sOqOLHq1ddvyGL29hixy7IKDheIqJ vQAq23djqjQQ3gWuraLkJGp27mqvXQuZNB78CyXmUMaRSzo4gZDEInCqKCM5F2np4biv 5xSyS/cBR2zg233DiTe0TLoqdtP41L4EzCAeOJBCQk70B86JDmOjphZc9+Qe/tQLMoQR VMHA== X-Gm-Message-State: AElRT7HE61OErLq1klv2SjT4mon+et2DVyt+yDF72QXvS+/YS5IWQVp4 NlVQMEpMda4srYQFOT7KbQQ= X-Google-Smtp-Source: AG47ELvrhslvYBRXBwscrRXUgKo3KQQ1YklbHq0R2yQS/LoNE8FaCaoVOWyPrpzSUXfQq9ULHpOENA== X-Received: by 10.129.82.21 with SMTP id g21mr6782685ywb.42.1521468291089; Mon, 19 Mar 2018 07:04:51 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::1:1aa7]) by smtp.googlemail.com with ESMTPSA id c15sm40257ywh.38.2018.03.19.07.04.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 07:04:49 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++/84812] ICE with local fn decl Message-ID: <1a63cb7f-5c42-8b59-f88a-3b410180f4e1@acm.org> Date: Mon, 19 Mar 2018 10:04:47 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 This bug happens when the machinery to check for an implicit extern "C" linkage on a local declaration, meets an ambiguous local lookup. I was misled by a comment that implied TREE_LIST -> overload. That was true way back, but now means ambiguous lookup. I declined the opportunity to micro-optimize the test to 'TREE_CODE (x) == ERROR_MARK || TTEE_CODE (X) == TREE_LIST'. nathan 2018-03-19 Nathan Sidwell PR c++/84812 * name-lookup.c (set_local_extern_decl_linkage): Defend against ambiguous lookups. PR c++/84812 * g++.dg/lookup/pr84812.C: New. Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 258642) +++ cp/name-lookup.c (working copy) @@ -2878,7 +2878,9 @@ set_local_extern_decl_linkage (tree decl = find_namespace_value (current_namespace, DECL_NAME (decl)); loc_value = ns_value; } - if (loc_value == error_mark_node) + if (loc_value == error_mark_node + /* An ambiguous lookup. */ + || (loc_value && TREE_CODE (loc_value) == TREE_LIST)) loc_value = NULL_TREE; for (ovl_iterator iter (loc_value); iter; ++iter) @@ -2926,7 +2928,8 @@ set_local_extern_decl_linkage (tree decl if (ns_value == decl) ns_value = find_namespace_value (current_namespace, DECL_NAME (decl)); - if (ns_value == error_mark_node) + if (ns_value == error_mark_node + || (ns_value && TREE_CODE (ns_value) == TREE_LIST)) ns_value = NULL_TREE; for (ovl_iterator iter (ns_value); iter; ++iter) Index: testsuite/g++.dg/lookup/pr84812.C =================================================================== --- testsuite/g++.dg/lookup/pr84812.C (revision 0) +++ testsuite/g++.dg/lookup/pr84812.C (working copy) @@ -0,0 +1,18 @@ +// PR 84812. ICE determining implicit "C" linkage + +struct A { void foo(); }; +struct B { void foo(); }; + +struct C : A, B +{ + void X (); +}; + +void C::X () +{ + void foo (); // local decl of ::foo + + foo (); +} + +// { dg-final { scan-assembler "_Z3foov" } }