From patchwork Thu Jan 30 03:45:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 315254 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 6FBCA2C00D3 for ; Thu, 30 Jan 2014 14:46:11 +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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=tPMowW1TyDCfN6GkfDF7Dik8iJ2l8dntrcx9rHafArC Q714a9HbxtOVBvQm3xuiF5uBy2ED9ezjIOlH9KNYimskLYT8z5TFqFLhzE9NSzY1 iRFpLxMq0j6zkQHMAYfTcxoifhPPCc3+RUCK8Th0IPGkQWzi2ivjHwbM+GNJ+a3U = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=FdMfjdRtlhhsJf05DniDLMsL9Z0=; b=bSECzTC8sZ2l0zk29 gd0lzB4v9IvaBXf0Cac+6MPIm38puAp3XVFGSnXthe7Pqut45kbtDPaL1xujSoMr K2f32wbBhRPYUOoAENS1EWM8ZkAAMdMKsu28xz8v6GWVad+cqwyEk4JAdn/o1eOy Dg01IWEOzylixRPlD3JuVhKdaI= Received: (qmail 12619 invoked by alias); 30 Jan 2014 03:46:02 -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 12610 invoked by uid 89); 30 Jan 2014 03:46:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jan 2014 03:46:00 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0U3jwRr004876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 29 Jan 2014 22:45:58 -0500 Received: from [10.10.116.22] ([10.10.116.22]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0U3jvdc019466; Wed, 29 Jan 2014 22:45:58 -0500 Message-ID: <52E9CAF5.1090806@redhat.com> Date: Wed, 29 Jan 2014 22:45:57 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Jan Hubicka CC: gcc-patches List Subject: RFA: cgraph PATCH for c++/59645 (ICE with covariant virtual function with volatile parameter) If a parameter of a covariant virtual function is volatile, we can't just use the parameter directly in the call we build for the thunk, or the gimple verifier will complain. We need to copy it into a temporary first. Tested x86_64-pc-linux-gnu. OK for trunk? commit 0cbf28df997d109615545f113b01ac233d64879f Author: Jason Merrill Date: Wed Jan 29 20:47:54 2014 -0500 PR c++/59645 * cgraphunit.c (expand_thunk): Copy volatile arg to a temporary. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index d22265a..38c91df 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1592,7 +1592,18 @@ expand_thunk (struct cgraph_node *node, bool output_asm_thunks) if (nargs) for (i = 1, arg = DECL_CHAIN (a); i < nargs; i++, arg = DECL_CHAIN (arg)) - vargs.quick_push (arg); + { + tree tmp = arg; + if (TREE_THIS_VOLATILE (TREE_TYPE (arg))) + { + gcc_assert (is_gimple_reg_type (TREE_TYPE (arg))); + tmp = create_tmp_reg (TYPE_MAIN_VARIANT + (TREE_TYPE (arg)), "arg"); + gimple stmt = gimple_build_assign (tmp, arg); + gsi_insert_after (&bsi, stmt, GSI_NEW_STMT); + } + vargs.quick_push (tmp); + } call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs); node->callees->call_stmt = call; gimple_call_set_from_thunk (call, true); diff --git a/gcc/testsuite/g++.dg/inherit/covariant21.C b/gcc/testsuite/g++.dg/inherit/covariant21.C new file mode 100644 index 0000000..42cdf87 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/covariant21.C @@ -0,0 +1,17 @@ +// PR c++/59645 + +struct A { virtual ~A(); }; +struct B { virtual ~B(); }; +struct C : A, B {}; + +struct X +{ + virtual B* foo(volatile int); +}; + +struct Y : X +{ + virtual C* foo(volatile int); +}; + +C* Y::foo(volatile int) { return 0; }