From patchwork Thu May 10 18:38:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 911517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477530-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="R3Dzszk0"; dkim-atps=neutral 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 40hhpR6Th9z9s33 for ; Fri, 11 May 2018 04:39:24 +1000 (AEST) 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=BMEiMjAynEIcg17qb/wTSEjUe+/b3wxt1qTPO0PhwVF8X/ eak+TtHznEv0VUAiZgg4UfroxdY5uYK2EOghU4clz9Q7lOV6b9qeDq0BcvOkv9ys AnK9D2pt5CxmZfyRyjJt/poWVidxiqNtaSYFqLCNvOpU8wLZ+kusUkB3icBxU= 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=+UdNTiOpfDba9cVv/XAybYzaqQs=; b=R3Dzszk0DCF4hwJ4cOfw WqqG/8e+SYK5aIsyKjIaIjyWWQPm8cGswbOb7OxQ/L3gL1hBQYJnZ2iRCeUKlJXK RzSTp7UzBU6/v9f/Up/k/svnZE1MtHXlcc+1AasTiNGicsQbtB9tqekjN6rjey2K N77TFr11+J56gzIlZOEBCb8= Received: (qmail 89259 invoked by alias); 10 May 2018 18:39:17 -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 88450 invoked by uid 89); 10 May 2018 18:39:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=45, lambda.c, UD:lambda.c, Feb X-HELO: mail-ot0-f177.google.com Received: from mail-ot0-f177.google.com (HELO mail-ot0-f177.google.com) (74.125.82.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 18:39:14 +0000 Received: by mail-ot0-f177.google.com with SMTP id g7-v6so3422831otj.11 for ; Thu, 10 May 2018 11:39:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8QoQuzCZKy2o4rZUeqJssWHy97c/G0fLWTUJe+L/B4w=; b=U7QxpvWmJ0l5mePKRHamNB+hAe1U1qaUKThZ5WC1cZfG/hzaEZGBT094qzo163RKIh CGMDTQtKvkf8EWRKM4kJhBlsE0tTa8CvmYTYObBc/aykchb3MjfeAt+XaDb+qMijHvHu 6sQRGCrmJwMKFW6h7KFDnsMILTUFNyOB0oYHuy9RdpqenVWFvuDpnZWWAdkU7xkJfw0N VX7RSdWHVEwCQHxxG/dbKW7WX622CSj8x0fsflV+EoVxESYH3TSigDtHtirxRf70/mc0 zMH7yJ7uCh/zY+YDDlJud4/OJw7aa1jNi+tegy2qL8TmAT5F8gx80IDgLBvQg8wTgOx2 k7gw== X-Gm-Message-State: ALKqPweAh4hgsE6Ii9mxINt2mUmbqxVyuQJPXMXoi8EDWpyqTzdFjsob O8K3XTd9gbW2tcoUijI7lXUYm0+pyFABuZH0m8tSMsq0 X-Google-Smtp-Source: AB8JxZp5pc7xoSLxaOVrufrQhy1rbeQEK7rm3beQLmEA17wP4s3svVBXq4LfQ/9HZ3Qfq6bMaI5Kqqgkrn38a3l6smo= X-Received: by 2002:a9d:1103:: with SMTP id g3-v6mr1801920ote.313.1525977552985; Thu, 10 May 2018 11:39:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.13.229 with HTTP; Thu, 10 May 2018 11:38:52 -0700 (PDT) From: Jason Merrill Date: Thu, 10 May 2018 14:38:52 -0400 Message-ID: Subject: Various small C++ cleanup PATCHes To: gcc-patches List X-IsSubscribed: yes 1) There's a function to count how many template headers we should have, we should use it. 2) While working on something a while back I ran into trying to instantiate a nested function while still in processing_template_decl context, which doesn't work so well. Let's check for that. 3) A predicate asking about user-provided functions should use user_provided_p, not DECL_ARTIFICIAL. 4) A minor simplification of the this-capture logic. 5) Correcting wrong uses of "argument" vs. "parameter". Tested x86_64-pc-linux-gnu, applying to trunk. commit fb725d091432d694c1d565710691bda335f38146 Author: Jason Merrill Date: Fri Feb 9 17:25:24 2018 -0500 * decl.c (make_typename_type): s/parameters/arguments/. * parser.c (cp_parser_nested_name_specifier_opt): Likewise. * pt.c (make_pack_expansion): Correct error message. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fccddd54d69..d58964754b9 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3756,7 +3756,7 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, if (TREE_CODE (name) == TEMPLATE_DECL) { if (complain & tf_error) - error ("%qD used without template parameters", name); + error ("%qD used without template arguments", name); return error_mark_node; } gcc_assert (identifier_p (name)); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f8ecf030c0d..88db9988bd4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6346,7 +6346,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, token->location); if (TREE_CODE (decl) == TEMPLATE_DECL) error_at (token->location, - "%qD used without template parameters", + "%qD used without template arguments", decl); else if (ambiguous_decls) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 180dfd6861c..e8346d3bf58 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4007,9 +4007,9 @@ make_pack_expansion (tree arg, tsubst_flags_t complain) if (complain & tf_error) { if (TYPE_P (arg)) - error ("expansion pattern %qT contains no argument packs", arg); + error ("expansion pattern %qT contains no parameter packs", arg); else - error ("expansion pattern %qE contains no argument packs", arg); + error ("expansion pattern %qE contains no parameter packs", arg); } return error_mark_node; } diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas9.C b/gcc/testsuite/g++.dg/cpp0x/alignas9.C index 98fe7077582..05d15ffe40b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alignas9.C +++ b/gcc/testsuite/g++.dg/cpp0x/alignas9.C @@ -2,5 +2,5 @@ // { dg-do compile { target c++11 } } template -struct A { alignas(int...) char c; }; // { dg-error "no argument packs|expected" } +struct A { alignas(int...) char c; }; // { dg-error "no parameter packs|expected" } A a; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C index 105208701bf..ca7ed33ac02 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C @@ -32,7 +32,7 @@ template void f(Args...); template void g(Args... args) { f(const_cast(&args)...); // okay: ``Args'' and ``args'' are expanded - f(5 ...); // { dg-error "contains no argument packs" } + f(5 ...); // { dg-error "contains no parameter packs" } f(args); // { dg-error "5:parameter packs not expanded" } // { dg-message "args" "note" { target *-*-* } .-1 } f(h(args...) + args...); // okay: first ``args'' expanded within h, second ``args'' expanded within f. diff --git a/gcc/testsuite/g++.dg/template/type1.C b/gcc/testsuite/g++.dg/template/type1.C index b74d975ac49..0191ae55dfc 100644 --- a/gcc/testsuite/g++.dg/template/type1.C +++ b/gcc/testsuite/g++.dg/template/type1.C @@ -4,5 +4,5 @@ struct A { template struct B { static int c; }; }; -int A::B::c; // { dg-error "parameters" } +int A::B::c; // { dg-error "arguments" } int A::C::d; // { dg-error "declared" }