From patchwork Thu Jan 21 12:54:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1429817 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) 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=Mtex44hY; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4DM2QY54vTz9sCq for ; Thu, 21 Jan 2021 23:54:12 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 667643836C18; Thu, 21 Jan 2021 12:54:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by sourceware.org (Postfix) with ESMTPS id 699393854804 for ; Thu, 21 Jan 2021 12:54:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 699393854804 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-qk1-x72b.google.com with SMTP id 19so1427873qkm.8 for ; Thu, 21 Jan 2021 04:54:05 -0800 (PST) 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=o//LW6S1pNqr9UNqAPgnN9p6AIXGY3GOCAD2DbjsDY8=; b=Mtex44hYIV7qZg988XTtNaE7VwLCwAHxUUvWYCtAdplfR0eT/8c/tfieWHrjdiGcb/ 1ceVOXOJMlDFNVfmrsQtJOvYBQQa0u9hZoBOlzol3di1obWkYS1YaAFd3QX6r/r1P+iD 6MGnDN5T7KUq6z/kn8hKXJKzTu3/nz5JN/IfSWdvfnBrX33wAE9vOoSO6Aro/Alk/gK0 noTozri2AZliSR7EdrpjyKpF9wSs79FedY66RHPOxnA/72eN+UyLd/0+cqVqGiLJ3uow GzPEVDz9fP5l8YA+SiJNnvNDlvbl0V4cSret9mVxrcscBNHBVBOdRnRfHd1I6PW+YKBu rI/Q== 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=o//LW6S1pNqr9UNqAPgnN9p6AIXGY3GOCAD2DbjsDY8=; b=T92YRHj7sFC62YX2F+yd72z0ADZ3z+yHjDcs+GBPxj75kwKmha0ApTKkETL4xeKM5w yWpOqJOqpfPVfcYNANbvsasaYrW+RPd9mKjLalrva5QqL1js6TSoKCG8qih9Co1a0I+1 OIbgdEGc86BVKOd83FQGS85Rw7erzVTwOrGI7gNo0icoHavvplVNFauL5pzoJJ0vIOsD 4axFnNfg0Q63EqHW089M3N1pwWoECuYor9dmsdCHx0ObFhMFku0mDQTpWB49yMUNBPTo kE6UkMZ1jlbiOzHhueko+UahmgyuYIrZcTntWqEZs0j8GqYWiPeM4AxH8DRilUihuG05 dCTw== X-Gm-Message-State: AOAM532X/5ektem0NJYYUobQdftEvbZ93Ezxs3HnR5nCZM3cSxVqViM+ AjgYaneXz+3E1HLrPmQKozs= X-Google-Smtp-Source: ABdhPJyOqv1Rrw2EglY39WdkB3pgXRf1puIz4fVcGnVmiWi/41Q06RL9bZ5UgcqTy9u4Hc9tbwHMIw== X-Received: by 2002:a37:6313:: with SMTP id x19mr875682qkb.171.1611233644929; Thu, 21 Jan 2021 04:54:04 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:a599:4f76:a7a0:5a9e? ([2620:10d:c091:480::1:b381]) by smtp.googlemail.com with ESMTPSA id c28sm3515309qtv.2.2021.01.21.04.54.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Jan 2021 04:54:03 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: Stat-hack for members [PR 98530] Message-ID: <6d2023c8-6314-b788-26b5-26e05ffd7437@acm.org> Date: Thu, 21 Jan 2021 07:54:02 -0500 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=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, 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" This was a header file that deployed the stat-hack inside a class (both a member-class and a [non-static data] member had the same name). Due to the way that's represented in name lookup we missed the class. Sadly just changing the representation globally has detrimental effects elsewhere, and this is a rare case, so just creating a new overload on the fly shouldn't be a problem. PR c++/98530 gcc/cp/ * name-lookup.c (lookup_class_binding): Rearrange a stat-hack. gcc/testsuite/ * g++.dg/modules/stat-mem-1.h: New. * g++.dg/modules/stat-mem-1_a.H: New. * g++.dg/modules/stat-mem-1_b.C: New. diff --git c/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c index b4b6c0b81b5..c99f2e3622d 100644 --- c/gcc/cp/name-lookup.c +++ w/gcc/cp/name-lookup.c @@ -3926,11 +3926,16 @@ lookup_class_binding (tree klass, tree name) vec *member_vec = CLASSTYPE_MEMBER_VEC (klass); found = member_vec_binary_search (member_vec, name); - if (IDENTIFIER_CONV_OP_P (name)) + if (!found) + ; + else if (STAT_HACK_P (found)) + /* Rearrange the stat hack so that we don't need to expose that + internal detail. */ + found = ovl_make (STAT_TYPE (found), STAT_DECL (found)); + else if (IDENTIFIER_CONV_OP_P (name)) { gcc_checking_assert (name == conv_op_identifier); - if (found) - found = OVL_CHAIN (found); + found = OVL_CHAIN (found); } } else diff --git c/gcc/testsuite/g++.dg/modules/stat-mem-1.h w/gcc/testsuite/g++.dg/modules/stat-mem-1.h new file mode 100644 index 00000000000..b5703ea2262 --- /dev/null +++ w/gcc/testsuite/g++.dg/modules/stat-mem-1.h @@ -0,0 +1,6 @@ + +struct fpu { + struct NAME { + int state; + } NAME; +}; diff --git c/gcc/testsuite/g++.dg/modules/stat-mem-1_a.H w/gcc/testsuite/g++.dg/modules/stat-mem-1_a.H new file mode 100644 index 00000000000..6daa137be4f --- /dev/null +++ w/gcc/testsuite/g++.dg/modules/stat-mem-1_a.H @@ -0,0 +1,5 @@ +// { dg-additional-options -fmodule-header } +// PR c++ 98530 stat-hack inside a structure +// { dg-module-cmi {} } + +#include "stat-mem-1.h" diff --git c/gcc/testsuite/g++.dg/modules/stat-mem-1_b.C w/gcc/testsuite/g++.dg/modules/stat-mem-1_b.C new file mode 100644 index 00000000000..9b83d4e6e30 --- /dev/null +++ w/gcc/testsuite/g++.dg/modules/stat-mem-1_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "stat-mem-1.h" +import "stat-mem-1_a.H";