diff mbox series

C++ PATCH to fix eb82.C

Message ID 20190216205421.GE3884@redhat.com
State New
Headers show
Series C++ PATCH to fix eb82.C | expand

Commit Message

Marek Polacek Feb. 16, 2019, 8:54 p.m. UTC
I noticed this test fails in c++2a since the implementation of P0846
landed in r265734.  Since it's in g++.old-deja/, I never noticted the
fail (but I don't see any others).  This patch tweaks a dg-error in
order to make it pass in c++2a also.

Tested on x86_64-linux, ok for trunk?

2019-02-16  Marek Polacek  <polacek@redhat.com>

	* g++.old-deja/g++.robertl/eb82.C: Tweak dg-error.

Comments

Marek Polacek Feb. 17, 2019, 4:54 p.m. UTC | #1
On Sat, Feb 16, 2019 at 03:54:21PM -0500, Marek Polacek wrote:
> I noticed this test fails in c++2a since the implementation of P0846
> landed in r265734.  Since it's in g++.old-deja/, I never noticted the
> fail (but I don't see any others).  This patch tweaks a dg-error in
> order to make it pass in c++2a also.
> 
> Tested on x86_64-linux, ok for trunk?
> 
> 2019-02-16  Marek Polacek  <polacek@redhat.com>
> 
> 	* g++.old-deja/g++.robertl/eb82.C: Tweak dg-error.
> 
> diff --git gcc/testsuite/g++.old-deja/g++.robertl/eb82.C gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
> index 9bf0398cd0a..fc2bf7866fe 100644
> --- gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
> +++ gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
> @@ -9,5 +9,5 @@ double val <int> () // { dg-error "" } bogus code
>  
>  int main ()
>  {
> -   printf ("%d\n", val<(int)3> ()); // { dg-error "" } val undeclared
> +   printf ("%d\n", val<(int)3> ()); // { dg-error "" "" { target c++17_down } } val undeclared
>  }

Actually I'll just go ahead with this, should be obvious anyway.

Marek
Jason Merrill Feb. 18, 2019, 9:35 p.m. UTC | #2
On 2/17/19 11:54 AM, Marek Polacek wrote:
> On Sat, Feb 16, 2019 at 03:54:21PM -0500, Marek Polacek wrote:
>> I noticed this test fails in c++2a since the implementation of P0846
>> landed in r265734.  Since it's in g++.old-deja/, I never noticted the
>> fail (but I don't see any others).  This patch tweaks a dg-error in
>> order to make it pass in c++2a also.
>>
>> Tested on x86_64-linux, ok for trunk?
>>
>> 2019-02-16  Marek Polacek  <polacek@redhat.com>
>>
>> 	* g++.old-deja/g++.robertl/eb82.C: Tweak dg-error.
>>
>> diff --git gcc/testsuite/g++.old-deja/g++.robertl/eb82.C gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
>> index 9bf0398cd0a..fc2bf7866fe 100644
>> --- gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
>> +++ gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
>> @@ -9,5 +9,5 @@ double val <int> () // { dg-error "" } bogus code
>>   
>>   int main ()
>>   {
>> -   printf ("%d\n", val<(int)3> ()); // { dg-error "" } val undeclared
>> +   printf ("%d\n", val<(int)3> ()); // { dg-error "" "" { target c++17_down } } val undeclared
>>   }
> 
> Actually I'll just go ahead with this, should be obvious anyway.

I had also noticed this test failing, and when investigating noticed 
that the remaining error strangely talked about a partial 
specialization.  This patch fixes that:
commit 848fa7b9ab2a55d4d3bbf791c828fc3ce60d61fa
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 18 10:05:31 2019 -1000

            Improve diagnostic for redundant template arguments in declaration.
    
            * pt.c (check_explicit_specialization): If the declarator is a
            template-id, only check whether the arguments are dependent.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 48cbf3d9892..d8be92ddca4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2849,7 +2849,7 @@ check_explicit_specialization (tree declarator,
 	  /* This case handles bogus declarations like template <>
 	     template <class T> void f<int>(); */
 
-	  if (!uses_template_parms (declarator))
+	  if (!uses_template_parms (TREE_OPERAND (declarator, 1)))
 	    error ("template-id %qD in declaration of primary template",
 		   declarator);
 	  else if (variable_template_p (TREE_OPERAND (declarator, 0)))
diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
index fc2bf7866fe..d4c5985cd8c 100644
--- a/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
+++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
@@ -2,7 +2,8 @@
 #include <stdio.h>
 
 template <int n1>
-double val <int> () // { dg-error "" } bogus code
+double val <int> () // { dg-error "expected" "" { target c++17_down } } bogus code
+// { dg-error "template-id .val<int>. in declaration of primary template" "" { target c++2a } .-1 }
 {                          
    return (double) n1;
 }
diff mbox series

Patch

diff --git gcc/testsuite/g++.old-deja/g++.robertl/eb82.C gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
index 9bf0398cd0a..fc2bf7866fe 100644
--- gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
+++ gcc/testsuite/g++.old-deja/g++.robertl/eb82.C
@@ -9,5 +9,5 @@  double val <int> () // { dg-error "" } bogus code
 
 int main ()
 {
-   printf ("%d\n", val<(int)3> ()); // { dg-error "" } val undeclared
+   printf ("%d\n", val<(int)3> ()); // { dg-error "" "" { target c++17_down } } val undeclared
 }