From patchwork Thu Nov 7 19:14:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Easwaran Raman X-Patchwork-Id: 289465 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 490532C007E for ; Fri, 8 Nov 2013 06:15:21 +1100 (EST) 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:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=DavDzXcGaBQ2WzzWfgNDDhbL+YlXK9Qt70e27Lyflz/ zeMOE9AV0T2MZWnftlzDJm3GVUKbdHM04C9u+OmRBT3v8ctqLQ2aKYFyeXmfVZ+X Y9QjxzOfDDPGz9DxJiDlZGoWXl16uUl3k0Xojeurjc1krU7zHKA+nPf1XknHjDH8 = 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:date:message-id:subject:from:to:cc:content-type; s=default; bh=jlBaP+9oLuTQpF90GxVbBzcxM24=; b=bRqtboA0iZv5xknjg XrCGHy3SfRysvpvXJ009B2b+v9NrLYXjw8ln5wTo/OD4Rb+rkqZYzHxh/FG8pLeT GJyFlBkruwGzJOPEJXRQvERqyF/WQKr826UeqkqZNTjt6xbCQCCht8e8EUKEgGxd UtMqr6qQZGcEDxHXTbdDgfH/5I= Received: (qmail 25637 invoked by alias); 7 Nov 2013 19:15:11 -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 25563 invoked by uid 89); 7 Nov 2013 19:15:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, RDNS_NONE, SPAM_SUBJECT, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ve0-f178.google.com Received: from Unknown (HELO mail-ve0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 07 Nov 2013 19:15:01 +0000 Received: by mail-ve0-f178.google.com with SMTP id db12so748349veb.9 for ; Thu, 07 Nov 2013 11:14:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=5OF2QQcGDM17uG7kmlnuY6HPX14QaWycOQU98vOWtiM=; b=fFRD6VELUSfCcrm2S3IdIzNFteIgJc7JUwVXZ0BRq26/fJAgWfhs33wsvzgqyJkPe3 ATt+k9uXJqpuUeWHlPMpq6eyp15m+iZHL9wWhXdofPrDbTiG1OSBSQYt1nyOtOdJQ93c ZaAa8a313KUuRoZPqMtq+qG9Uuy4OMif/S1Fc4FhLp8y58z84HaUE7grf0WmMkN4CW5+ iqMa7RxMOuRlaK011chpZo0dlIM31QBX1f0laZFLM2DfbXScTZR/zEaHYKWYNcBuZySt Db2RlLRoU+0GwJBFG8eaAzKQQZgdubTn/aWwQaBVnNy40JVbw31dH2tD+6/ya69EIpHO Xgxg== X-Gm-Message-State: ALoCoQk0iYGdQzm9q/flx0LuAy9BhvldKcnJ9H7oM0ax69oygTXDd1qrlBUrFJXSSi9m/rOaFDBTaU6EWL9oXqWIi4wbQIgH9qM/dWWmy/k3qcnD5RK7klerTRhpcV9m10LQ7FxonZV8Kj7BXMK0V+X9hpCnSesNb8PhF/J4tCRxlvPHX9H3Ts+anoS709UC5zCaJQo5ke1Kr1G48ui/WKNBYZcbyr9A6w== MIME-Version: 1.0 X-Received: by 10.220.159.4 with SMTP id h4mr283223vcx.1.1383851693222; Thu, 07 Nov 2013 11:14:53 -0800 (PST) Received: by 10.52.184.69 with HTTP; Thu, 7 Nov 2013 11:14:52 -0800 (PST) Date: Thu, 7 Nov 2013 11:14:52 -0800 Message-ID: Subject: Fix for PR c++/59031 From: Easwaran Raman To: GCC Patches Cc: Jason Merrill , Paolo Carlini X-IsSubscribed: yes Before r193504, if a method can not be overridden, LOOKUP_NONVIRTUAL is set and the call is direct. The changes at r193504 (to fix PR c++/11750) caused a regression to this behavior. This patch attempts to fix that. Bootstraps and no test regressions on x86_64/linux. Is this a correct fix and is this ok for trunk? Thanks, Easwaran 2013-11-07 Easwaran Raman PR c++/59031 * call.c (build_new_method_call_1): Comnpare function context with BASELINK_BINFO type rather than instance type before marking the call with LOOKUP_NONVIRTUAL. testsuite/ChangeLog: 2013-11-07 Easwaran Raman PR c++/59031 * g++.dg/inherit/virtual11.C: New test. Index: testsuite/g++.dg/inherit/virtual11.C =================================================================== --- testsuite/g++.dg/inherit/virtual11.C (revision 0) +++ testsuite/g++.dg/inherit/virtual11.C (revision 0) @@ -0,0 +1,17 @@ +// PR c++/59031 +// { dg-do compile } +// { dg-options "-fdump-tree-gimple " } +class B { + public: + virtual int add (int a, int b) {return a+ b;} +}; + +class D : public B { +}; + +int foo (int a, int b) { + D d; + return d.add(a, b); +} +// { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } } Index: cp/call.c =================================================================== --- cp/call.c (revision 204466) +++ cp/call.c (working copy) @@ -7511,7 +7511,7 @@ build_new_method_call_1 (tree instance, tree fns, struct z_candidate *candidates = 0, *cand; tree explicit_targs = NULL_TREE; tree basetype = NULL_TREE; - tree access_binfo; + tree access_binfo, binfo; tree optype; tree first_mem_arg = NULL_TREE; tree name; @@ -7550,6 +7550,7 @@ build_new_method_call_1 (tree instance, tree fns, if (!conversion_path) conversion_path = BASELINK_BINFO (fns); access_binfo = BASELINK_ACCESS_BINFO (fns); + binfo = BASELINK_BINFO (fns); optype = BASELINK_OPTYPE (fns); fns = BASELINK_FUNCTIONS (fns); if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) @@ -7802,7 +7803,7 @@ build_new_method_call_1 (tree instance, tree fns, do not want to perform a non-virtual call. */ if (DECL_VINDEX (fn) && ! (flags & LOOKUP_NONVIRTUAL) && same_type_ignoring_top_level_qualifiers_p - (DECL_CONTEXT (fn), TREE_TYPE (instance)) + (DECL_CONTEXT (fn), TREE_TYPE (binfo)) && resolves_to_fixed_type_p (instance, 0)) flags |= LOOKUP_NONVIRTUAL; if (explicit_targs)