From patchwork Thu Jan 14 17:35:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 567609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 73CDC140C19 for ; Fri, 15 Jan 2016 04:35:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=at41cg9B; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=i4rDN8H/8yNc Xh/lgonCK5qPpFI7Gxphik4AssMWVtRExxqKH2fcunq3m6HKS9rKbdAwbiFRw6XB LcBP7z8wrnd39p+2g201451KUjG4Th+fdJUTZxk0AbeirkCmmqR0Aypp7F8rGt/f EDnrmzXAqhhypL4PeWMJDKjh9HzjXpM= 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:from :to:cc:subject:date:message-id; s=default; bh=bi5mBqwOZr/P3BZgVd O6+kWTqWY=; b=at41cg9BimUJ5UB1fY7DIHWtI/eR/gSWwq9vjDhtQJ0ayrGdsv HsTyFGxXPo2J4r2OZ/dwiIHVFxpV38FAirhR7wK0YcV9URZZ0wt5l8OSksPzm8Iz 6uRpXRhGWJOY0Yvm9Cnq1aU3UDhRFXDKTjS2Ntf6d7aG9vG/D5kv4VCxo= Received: (qmail 76048 invoked by alias); 14 Jan 2016 17:35:41 -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 76037 invoked by uid 89); 14 Jan 2016 17:35:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=retain, 27477, 2747, 7, retention X-HELO: mail-qg0-f45.google.com Received: from mail-qg0-f45.google.com (HELO mail-qg0-f45.google.com) (209.85.192.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 14 Jan 2016 17:35:39 +0000 Received: by mail-qg0-f45.google.com with SMTP id e32so399864630qgf.3 for ; Thu, 14 Jan 2016 09:35:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/CRasy9kTEbUOJkKjHFH3kxBJeVWDZo4hgMgFlQD964=; b=Ni8T7kP4z58cFaPpJ0oKus48sX4LPPQ+BlvGGPc/mmCSV+ro2rPHX3K+V37qh2UVBo 2Wt7vQGm4bfqWevQZ1x+WTa9MNiB3rz18za0IczVsxIHpi3s7QWiJDDL8LHvt4SKEE1b lEmYNcOdNiJ6S0X9I0MhSDVDXnAu6Nqns8m5L0BDlh54CoUedNe1jqv8vriJK/48Dx8u VC3wf4mbcRTwvQmpbBosjWPA8JOegO69seJcyCsPHXe9jZd5Ddq24SIQSlbvUR14l1fb 7DGRNpEpCH9KGCNvh3LVgG5O3w5GlhW+KGZjYXTe5L5aVbsQQvdduiV2qZgnChbwjjXU Obrg== X-Gm-Message-State: ALoCoQlbGSSHDuRoPRPgAxczHt94d+GCOufPXBVdEMchr0NcsgBKqIEMeVBz2qz+VlgigfO+9L6Y7lU0nKFEB09fcKxsQchGvg== X-Received: by 10.140.16.225 with SMTP id 88mr7554725qgb.96.1452792937524; Thu, 14 Jan 2016 09:35:37 -0800 (PST) Received: from localhost.localdomain (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id d6sm2867899qkb.13.2016.01.14.09.35.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jan 2016 09:35:36 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] Fix PR c++/68936 Date: Thu, 14 Jan 2016 12:35:32 -0500 Message-Id: <1452792932-1807-1-git-send-email-patrick@parcs.ath.cx> With my fix for PR c++/21802 I changed build_min_non_dep_call_vec() to additionally retain the KOENIG_LOOKUP_P flag of the non-dependent expression that's been built. This change was a little too general though, since retaining the KOENIG_LOOKUP_P flag is only necessary for build_min_non_dep_op_overload(), which builds a CALL_EXPR to an operator overload -- other callers of build_min_non_dep_call_vec() do not need or expect this to be done. So this patch moves this KOENIG_LOOKUP_P flag retention from build_min_non_dep_call_vec() to build_min_non_dep_op_overload(), the only place where it's needed and where we are sure that NON_DEP is a CALL_EXPR. Bootstrap and regtest in progress on x86_64-pc-linux-gnu, OK to commit after testing? gcc/cp/ChangeLog: PR c++/68936 * tree.c (build_min_non_dep_call_vec): Don't retain the KOENIG_LOOKUP_P flag of the non-dependent expression that's been built. (build_min_non_dep_op_overload): Instead, do it here. gcc/testsuite/ChangeLog: PR c++/68936 * g++.dg/template/pr68936.C: New test. --- gcc/cp/tree.c | 6 +++++- gcc/testsuite/g++.dg/template/pr68936.C | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/pr68936.C diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d679889..e2123ac 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2747,7 +2747,6 @@ build_min_non_dep_call_vec (tree non_dep, tree fn, vec *argvec) non_dep = TREE_OPERAND (non_dep, 0); TREE_TYPE (t) = TREE_TYPE (non_dep); TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep); - KOENIG_LOOKUP_P (t) = KOENIG_LOOKUP_P (non_dep); return convert_from_reference (t); } @@ -2810,6 +2809,11 @@ build_min_non_dep_op_overload (enum tree_code op, call = build_min_non_dep_call_vec (non_dep, fn, args); release_tree_vector (args); + tree call_expr = call; + if (REFERENCE_REF_P (call_expr)) + call_expr = TREE_OPERAND (call_expr, 0); + KOENIG_LOOKUP_P (call_expr) = KOENIG_LOOKUP_P (non_dep); + return call; } diff --git a/gcc/testsuite/g++.dg/template/pr68936.C b/gcc/testsuite/g++.dg/template/pr68936.C new file mode 100644 index 0000000..ecfc09e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr68936.C @@ -0,0 +1,20 @@ +// PR c++/68936 + +class A {}; + +struct predefined_macros { + struct B { + A (predefined_macros::*generator)(); + }; +}; + +template class C { + void m_fn1(); + predefined_macros predef; +}; + +predefined_macros::B m; + +template void C::m_fn1() { + (predef.*m.generator)(); +}