diff mbox

C++ PATCH to improve dump_decl (PR c++/71075)

Message ID 20160519175504.GJ1611@redhat.com
State New
Headers show

Commit Message

Marek Polacek May 19, 2016, 5:55 p.m. UTC
On Thu, May 19, 2016 at 12:55:18PM -0400, Jason Merrill wrote:
> Well, constants aren't declarations.  Why are we calling dump_decl here?

Eh, not sure what I was thinking...

We call dump_decl because unify_template_argument_mismatch has %qD:
    inform (input_location,
            "  template argument %qE does not match %qD", arg, parm);
so I suspect we want to print expression ever for PARM:

Untested, but I think it should test fine.  Ok if testing passes?

2016-05-19  Marek Polacek  <polacek@redhat.com>

	PR c++/71075
	* pt.c (unify_template_argument_mismatch): Use %qE instead of %qD.

	* g++.dg/diagnostic/pr71075.C: New test.


	Marek

Comments

Marek Polacek May 19, 2016, 8:03 p.m. UTC | #1
On Thu, May 19, 2016 at 07:55:05PM +0200, Marek Polacek wrote:
> On Thu, May 19, 2016 at 12:55:18PM -0400, Jason Merrill wrote:
> > Well, constants aren't declarations.  Why are we calling dump_decl here?
> 
> Eh, not sure what I was thinking...
> 
> We call dump_decl because unify_template_argument_mismatch has %qD:
>     inform (input_location,
>             "  template argument %qE does not match %qD", arg, parm);
> so I suspect we want to print expression ever for PARM:
> 
> Untested, but I think it should test fine.  Ok if testing passes?

Which it did.

	Marek
Jason Merrill May 19, 2016, 8:53 p.m. UTC | #2
OK.

On Thu, May 19, 2016 at 4:03 PM, Marek Polacek <polacek@redhat.com> wrote:
> On Thu, May 19, 2016 at 07:55:05PM +0200, Marek Polacek wrote:
>> On Thu, May 19, 2016 at 12:55:18PM -0400, Jason Merrill wrote:
>> > Well, constants aren't declarations.  Why are we calling dump_decl here?
>>
>> Eh, not sure what I was thinking...
>>
>> We call dump_decl because unify_template_argument_mismatch has %qD:
>>     inform (input_location,
>>             "  template argument %qE does not match %qD", arg, parm);
>> so I suspect we want to print expression ever for PARM:
>>
>> Untested, but I think it should test fine.  Ok if testing passes?
>
> Which it did.
>
>         Marek
diff mbox

Patch

diff --git gcc/cp/pt.c gcc/cp/pt.c
index fde3091..ea7778d 100644
--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -6165,7 +6165,7 @@  unify_template_argument_mismatch (bool explain_p, tree parm, tree arg)
 {
   if (explain_p)
     inform (input_location,
-	    "  template argument %qE does not match %qD", arg, parm);
+	    "  template argument %qE does not match %qE", arg, parm);
   return 1;
 }
 
diff --git gcc/testsuite/g++.dg/diagnostic/pr71075.C gcc/testsuite/g++.dg/diagnostic/pr71075.C
index e69de29..6bb1e68 100644
--- gcc/testsuite/g++.dg/diagnostic/pr71075.C
+++ gcc/testsuite/g++.dg/diagnostic/pr71075.C
@@ -0,0 +1,8 @@ 
+// PR c++/71075
+
+template<typename T, int I> struct A {};
+template<typename T> void foo(A<T,1>) {}
+int main() {
+  foo(A<int,2>()); // { dg-error "no matching" }
+// { dg-message "template argument .2. does not match .1." "" { target *-*-* } 6 }
+}