From patchwork Thu Jan 6 00:06:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 77647 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]) by ozlabs.org (Postfix) with SMTP id E8082B6EE8 for ; Thu, 6 Jan 2011 11:07:00 +1100 (EST) Received: (qmail 3734 invoked by alias); 6 Jan 2011 00:06:57 -0000 Received: (qmail 3722 invoked by uid 22791); 6 Jan 2011 00:06:57 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Jan 2011 00:06:52 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0606oTf007066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Jan 2011 19:06:50 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0606nb1018048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Jan 2011 19:06:49 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p0606nZD020781; Thu, 6 Jan 2011 01:06:49 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0606mD4020779; Thu, 6 Jan 2011 01:06:48 +0100 Date: Thu, 6 Jan 2011 01:06:48 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Use tsubst instead of tsubst_copy for VA_ARG_EXPR's second argument (PR c++/47022) Message-ID: <20110106000648.GN16156@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110101182742.GX16156@tyan-ft48-01.lab.bos.redhat.com> <4D24752F.8080809@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4D24752F.8080809@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 On Wed, Jan 05, 2011 at 08:42:07AM -0500, Jason Merrill wrote: > On 01/01/2011 01:27 PM, Jakub Jelinek wrote: > >One fix is attached, another possibility (untested) would be to pass through > >all TYPE_Ps to tsubst in default: for tsubst_copy, another is > >use tsubst instead of tsubst_copy on VA_ARG_EXPR's second argument in > >tsubst_copy_and_build (or any combination of those). > > The last of those, please. Here it is, bootstrapped/regtested on x86_64-linux and i686-linux, ok? 2011-01-05 Jakub Jelinek PR c++/47022 * pt.c (tsubst_copy_and_build): Use tsubst instead of tsubst_copy for the second build_x_va_arg argument. * g++.dg/template/stdarg1.C: New test. Jakub --- gcc/cp/pt.c.jj 2011-01-03 09:54:01.000000000 +0100 +++ gcc/cp/pt.c 2011-01-05 14:50:22.000000000 +0100 @@ -13239,8 +13239,7 @@ tsubst_copy_and_build (tree t, case VA_ARG_EXPR: return build_x_va_arg (RECUR (TREE_OPERAND (t, 0)), - tsubst_copy (TREE_TYPE (t), args, complain, - in_decl)); + tsubst (TREE_TYPE (t), args, complain, in_decl)); case OFFSETOF_EXPR: return finish_offsetof (RECUR (TREE_OPERAND (t, 0))); --- gcc/testsuite/g++.dg/template/stdarg1.C.jj 2010-12-31 11:56:29.000000000 +0100 +++ gcc/testsuite/g++.dg/template/stdarg1.C 2010-12-31 11:55:56.000000000 +0100 @@ -0,0 +1,53 @@ +// PR c++/47022 +// { dg-do compile } + +#include + +template +void +f1 (T *p, va_list ap) +{ + *p = va_arg (ap, long double); + *p += va_arg (ap, double); +} + +template +void +f2 (T *p, va_list ap) +{ + *p = __real__ va_arg (ap, _Complex int); + *p += __imag__ va_arg (ap, _Complex double); + *p += __imag__ va_arg (ap, _Complex long double); +} + +template +void +f3 (T *p, va_list ap) +{ + *p = va_arg (ap, T); +} + +void +foo (int x, va_list ap) +{ + if (x == 0) + { + long double ld; + f1 (&ld, ap); + } + else if (x == 1) + { + int i; + f2 (&i, ap); + } + else if (x == 2) + { + long double ld; + f3 (&ld, ap); + } + else if (x == 3) + { + _Complex double cd; + f3 (&cd, ap); + } +}