From patchwork Wed Oct 5 18:58:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 678563 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 3sq4nn53Yvz9s1h for ; Thu, 6 Oct 2016 05:59:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=XzGjXlZ9; 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 :mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; q=dns; s=default; b=iEZqdJMPq7w0sycxC5 2TVdF5VNgbZ9YNOYpNh8Kai7xh5rMRlGIMfQxjThLSOlD72FpxDNuoGHbCcVDFwx 4IShIK7m+4d4B00gN3v38oLDhtFjq40yfvZd6foSG2Nw9z/p+qXL4vGNeiucMmfv YFAj5durfW2Om1ZgrdwLBfosI= 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:in-reply-to:references:from:date:message-id :subject:to:content-type; s=default; bh=LIdG3XLQC5Nu8F6l+H+rVjX/ e/w=; b=XzGjXlZ9GjDAykrgOCAcChIDZr/OIWmBb6qF2b+bqBva4b1Cv64CFegt S/ZzawT9oKe7zkFB4XNX05M/rFdloD13J47TXe0R+xJS8FjEYYJWNIOPqh+6vHxU Ifk0R+NnYVS7vYM1uM55YJb1aGxfw6oRXs5VB3pc03EiXe7BvuI= Received: (qmail 53707 invoked by alias); 5 Oct 2016 18:59: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 53686 invoked by uid 89); 5 Oct 2016 18:59:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=jasonredhatcom, jason@redhat.com, sk:CLASS_P, sk:class_p X-HELO: mail-oi0-f45.google.com Received: from mail-oi0-f45.google.com (HELO mail-oi0-f45.google.com) (209.85.218.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Oct 2016 18:59:00 +0000 Received: by mail-oi0-f45.google.com with SMTP id r126so284692882oib.0 for ; Wed, 05 Oct 2016 11:58:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=fEa7EVCN4lZ4Ik3JO9CMFNGqNeXI2rn466UzD5BOjcM=; b=Dobxl5JvplSkwQzBHYWsCH471kCRlr1zGfAj1pnvSlP+M7li8u62GP0BlZBAgk2z9m slLxgG0smxW7cL7X/NbcibqzbS5Rv+5olW0MrkkwQ+Olr5PJBhOJgRSSpXvc621MVPtt Fbt9/9waDZGA+rqTt6W+lpG61u2lmTmKt9PyyU+zxCYLVyEuWqISz2uEz2qEJ11KXYPp S3W0YA8omP1tqPzHatGsz2H9Jpa61TSiMjGuSwec2RItGLoPyYeWOnCebU2kUjjpmWd8 O5hJ2TvNHPq7zyRr39zpu8D9INVnJIvwurr7g1ag3aoQ3uqYnOGYkY7u9ZZxr3M1rEG+ UEig== X-Gm-Message-State: AA6/9Rn4L/6pn3+994p9jQzMT9B/sELw+1eKt8K8B3RJuPyAJfQKlnR8SQbb63qcxBfFmRgQ1TmvkFIiKJ+HAbOK X-Received: by 10.157.52.188 with SMTP id g57mr6463233otc.125.1475693938027; Wed, 05 Oct 2016 11:58:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.39.225 with HTTP; Wed, 5 Oct 2016 11:58:37 -0700 (PDT) In-Reply-To: References: From: Jason Merrill Date: Wed, 5 Oct 2016 14:58:37 -0400 Message-ID: Subject: Re: C++ PATCH for C++17 class template placeholders To: gcc-patches List X-IsSubscribed: yes On Tue, Oct 4, 2016 at 11:11 PM, Jason Merrill wrote: > On Tue, Oct 4, 2016 at 4:42 PM, Jason Merrill wrote: >> C++17 adds the ability to omit the template arguments for a class >> template when declaring a variable with an initializer, much like auto >> but supporting a wider variety of initialization. This is intended to >> replace functions like make_tuple. >> >> Tested x86_64-pc-linux-gnu, applying to trunk. > > A few tweaks... And another. commit 38f26c12a24dae80a51daeb6f9401e99ce5920b7 Author: Jason Merrill Date: Wed Oct 5 14:32:16 2016 -0400 * semantics.c (finish_compound_literal): Handle class placeholder. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1d8f336..2467a3d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2671,6 +2671,11 @@ finish_compound_literal (tree type, tree compound_literal, return error_mark_node; } + if (tree anode = type_uses_auto (type)) + if (CLASS_PLACEHOLDER_TEMPLATE (anode)) + type = do_auto_deduction (type, compound_literal, anode, complain, + adc_variable_type); + if (processing_template_decl) { TREE_TYPE (compound_literal) = type; diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction18.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction18.C new file mode 100644 index 0000000..ab2126e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction18.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++1z } + +template struct S{S(T){}}; + +int main() { + S{1}; +}