diff mbox

[C++] Improve check_for_bare_parameter_packs location

Message ID 5741D01A.1000204@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 22, 2016, 3:28 p.m. UTC
Hi,

I'm finally completing a candidate fix for c++/69095 and I noticed that 
in order to get function parameters (not just template parameters, as 
originally reported) right it's important that the location used by 
check_for_bare_parameter_packs is (more) accurate. But the below seems 
conceptually independent anyway. Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////
/cp
2016-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

	* pt.c (check_for_bare_parameter_packs): Improve error message
	location.

/testsuite
2016-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/pr31445.C: Test column number too.
	* g++.dg/cpp0x/pr32253.C: Likewise.
	* g++.dg/cpp0x/variadic-ex13.C: Likewise.
	* g++.dg/cpp0x/variadic36.C: Likewise.

Comments

Jason Merrill May 23, 2016, 1:30 p.m. UTC | #1
On 05/22/2016 11:28 AM, Paolo Carlini wrote:
> +      location_t loc = EXPR_LOC_OR_LOC (t, input_location);

Hmm, we can get types here as well, but I guess that works fine.  OK.

Jason
diff mbox

Patch

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 236569)
+++ cp/pt.c	(working copy)
@@ -3761,7 +3761,8 @@  check_for_bare_parameter_packs (tree t)
 
   if (parameter_packs) 
     {
-      error ("parameter packs not expanded with %<...%>:");
+      location_t loc = EXPR_LOC_OR_LOC (t, input_location);
+      error_at (loc, "parameter packs not expanded with %<...%>:");
       while (parameter_packs)
         {
           tree pack = TREE_VALUE (parameter_packs);
@@ -3776,9 +3777,9 @@  check_for_bare_parameter_packs (tree t)
             name = DECL_NAME (pack);
 
 	  if (name)
-	    inform (input_location, "        %qD", name);
+	    inform (loc, "        %qD", name);
 	  else
-	    inform (input_location, "        <anonymous>");
+	    inform (loc, "        <anonymous>");
 
           parameter_packs = TREE_CHAIN (parameter_packs);
         }
Index: testsuite/g++.dg/cpp0x/pr31445.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr31445.C	(revision 236569)
+++ testsuite/g++.dg/cpp0x/pr31445.C	(working copy)
@@ -2,7 +2,7 @@ 
 template <typename... T> struct A
 {
   void foo(T...);
-  A(T... t) { foo(t); } // { dg-error "parameter packs|t" }
+  A(T... t) { foo(t); } // { dg-error "18:parameter packs|t" }
 };
 
 A<int> a(0);
Index: testsuite/g++.dg/cpp0x/pr32253.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr32253.C	(revision 236569)
+++ testsuite/g++.dg/cpp0x/pr32253.C	(working copy)
@@ -1,7 +1,7 @@ 
 // { dg-do compile { target c++11 } }
 template<void (*... fp)()> struct A
 {
-  A() { fp(); } // { dg-error "not expanded|fp" }
+  A() { fp(); } // { dg-error "11:parameter packs not expanded|fp" }
 };
 
 void foo();
Index: testsuite/g++.dg/cpp0x/variadic-ex13.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic-ex13.C	(revision 236569)
+++ testsuite/g++.dg/cpp0x/variadic-ex13.C	(working copy)
@@ -33,7 +33,7 @@  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(args); // { dg-error "parameter packs not expanded" }
+   f(args); // { dg-error "5:parameter packs not expanded" }
    // { dg-message "args" "note" { target *-*-* } 36 }
    f(h(args...) + args...); // okay: first ``args'' expanded within h, second ``args'' expanded within f.
 }
Index: testsuite/g++.dg/cpp0x/variadic36.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic36.C	(revision 236569)
+++ testsuite/g++.dg/cpp0x/variadic36.C	(working copy)
@@ -2,7 +2,7 @@ 
 template<typename T, typename... Args>
 void f(const T&, const Args&... args)
 {
-  f(args); // { dg-error "packs not expanded" }
+  f(args); // { dg-error "4:parameter packs not expanded" }
 }
 
 template<typename... Values>