Various small C++ cleanup PATCHes

Message ID CADzB+2n1UvgfdEdbCEz+VCbf8=mFdrsSWiQk7mY_9zR5_M6dxA@mail.gmail.com
State New
Headers show
Series
  • Various small C++ cleanup PATCHes
Related show

Commit Message

Jason Merrill May 10, 2018, 6:38 p.m.
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.

Patch

commit fb725d091432d694c1d565710691bda335f38146
Author: Jason Merrill <jason@redhat.com>
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 <typename... T>
-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<int, double> 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<typename... Args> void f(Args...);
 template<typename... Args> void g(Args... args) 
 {
    f(const_cast<const Args*>(&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 <class T> 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" }