From patchwork Sun Nov 13 06:49:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 694088 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 3tGkmY5p5Qz9t0Z for ; Sun, 13 Nov 2016 17:50:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GuvR9RL9"; 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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=js8DRTX70lu7nQ4swJ36TS5SrF75XSrlzbnD7/7ONvkjDt vMPosfY+QDGUk99uGY4S4omBp1KjrqsP9O5Qn0dQC3F2bNyVkb0Z8uQUVTXN5GG0 g6VsUyZmRTHMKUKQxHL0OzKZ9oNKUNUFdDvvdUCfBEfsErcLalul5655C4Vek= 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:from:date:message-id:subject:to:content-type; s= default; bh=9an8QM+IFJ5hgWT76aoV517A8Pc=; b=GuvR9RL9THPf6MP3g6+O CDrNn5ClPJL6cDlojdnNGGOi5xXTxpmpZQE4Ug2ndZlPTX8USgVlWaeoeSJ3xKNx RGXONGmv9x/oCOgGETuHT3hE1VX8gEcgRGh4AnjbW1IiU1m+yRbIROL+rb3TqMHp lJQjjE2qRLgkA4AmfWVcypU= Received: (qmail 44678 invoked by alias); 13 Nov 2016 06:49:57 -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 44663 invoked by uid 89); 13 Nov 2016 06:49:55 -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= X-HELO: mail-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Nov 2016 06:49:54 +0000 Received: by mail-oi0-f44.google.com with SMTP id x4so29463201oix.2 for ; Sat, 12 Nov 2016 22:49:54 -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:from:date:message-id:subject:to; bh=cVPbBM7uKdqGcKlxDSzeOTx6ywb+pRkkSnY0uE3BDDY=; b=Dp+h+HVFrMV+0YNcx+i3LlQJfDcFG2UDU8ZZ+lfCqqVcSkHuf5uO2p5q9xTPq9AedA FmCZDdckHvghZMW88o8TA/nU3SlSyF5nxByVKd/RNyXqf+IUudnSpyIdBpXxPp50tADa AF4VAFul3cdfeEkyWg2q4QhCWWc2O4hq+PUFmJw2DJcWVIE2+TRgq4D8fSDA4BCVhy0I KKhQ6Z+1XVQgkoAGFgUrqVD42K469mT8rVzHkD19vkUyxXSdUJX1JZdcXMIMFSDija9I 57qZp1nCiy7+hU2ytH6LzaZ8BMBY+DSslojYbU8KGOW7cmlFoOcpoYzxgqLKSm2zF2iA N4Cw== X-Gm-Message-State: ABUngvea9xJWYZkPwcebKbjsOIeB9Zl30+4cFBEYvFb+P0ccMRJCL1IkcQe+W2UhbB+i/xg01O8jA84jlY8Z+rS7 X-Received: by 10.157.12.203 with SMTP id o11mr4624003otd.31.1479019792232; Sat, 12 Nov 2016 22:49:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.153.138 with HTTP; Sat, 12 Nov 2016 22:49:31 -0800 (PST) From: Jason Merrill Date: Sat, 12 Nov 2016 22:49:31 -0800 Message-ID: Subject: C++ PATCH for CWG2233 To: gcc-patches List X-IsSubscribed: yes In Core working group discussions today we were looking at this testcase, which caused the compiler to ICE because it assumed that once we had seen one default argument, all following parameters would have them as well. This is no longer true now that we allow a parameter pack to follow default arguments. Tested x86_64-pc-linux-gnu, applying to trunk. commit 4c59e1a2f90e1aa6f381692e843164ad0543f53b Author: Jason Merrill Date: Sat Nov 12 14:37:33 2016 -0800 CWG 2233 - default arg and parameter pack * typeck.c (convert_arguments): Handle default arg followed by none. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 211696c..24ca1b5 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3835,6 +3835,10 @@ convert_arguments (tree typelist, vec **values, tree fndecl, { for (; typetail != void_list_node; ++i) { + /* After DR777, with explicit template args we can end up with a + default argument followed by no default argument. */ + if (!TREE_PURPOSE (typetail)) + break; tree parmval = convert_default_arg (TREE_VALUE (typetail), TREE_PURPOSE (typetail), @@ -3850,9 +3854,10 @@ convert_arguments (tree typelist, vec **values, tree fndecl, break; } } - else + + if (typetail && typetail != void_list_node) { - if (complain & tf_error) + if (complain & tf_error) error_args_num (input_location, fndecl, /*too_many_p=*/false); return -1; } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic169.C b/gcc/testsuite/g++.dg/cpp0x/variadic169.C new file mode 100644 index 0000000..6858973 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic169.C @@ -0,0 +1,9 @@ +// DR 2233 +// { dg-do compile { target c++11 } } + +template void f(int n = 0, T ...t); + +int main() +{ + f(); // { dg-error "too few arguments" } +}