[C++] Two literal operator template location fixes

Message ID cd372fe4-9413-156d-e509-b8307c2c3de0@oracle.com
State New
Headers show
Series
  • [C++] Two literal operator template location fixes
Related show

Commit Message

Paolo Carlini May 21, 2019, 11:03 a.m.
Hi,

also in my back queue a few more location fixes (of course ;) Tested 
x86_64-linux.

Thanks, Paolo.

////////////////
/cp
2019-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	* parser.c (cp_parser_template_declaration_after_parameters): Use
	DECL_SOURCE_LOCATION in literal operator template errors.

/testsuite
2019-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/udlit-tmpl-arg-neg2.C: Check locations too.
	* g++.dg/cpp0x/udlit-tmpl-parms-neg.C: Likewise.

Comments

Jason Merrill May 21, 2019, 9:03 p.m. | #1
On 5/21/19 7:03 AM, Paolo Carlini wrote:
> Hi,

> 

> also in my back queue a few more location fixes (of course ;) Tested 

> x86_64-linux.


OK.
Christophe Lyon May 22, 2019, 8:28 a.m. | #2
On Tue, 21 May 2019 at 13:03, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>

> Hi,

>

> also in my back queue a few more location fixes (of course ;) Tested

> x86_64-linux.

>

> Thanks, Paolo.

>

> ////////////////

>


Hi,

I think you incorrectly committed an additional chunk:
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-pr66548.C
b/gcc/testsuite/g++.dg/cpp0x/decltype-pr66548.C
index f4b7caa..3f20d15 100644
--- a/gcc/testsuite/g++.dg/cpp0x/decltype-pr66548.C
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype-pr66548.C
@@ -11,7 +11,7 @@ struct Meow {};

 void f ()
 {
-  decltype (Meow.purr ()) d;   // { dg-error "expected
primary-expression" "pr89875" { xfail c++98_only } }
+  decltype (Meow.purr ()) d;   // { dg-error "expected primary-expression" }
   (void)&d;
 }


As a result, the test now fails
/gcc/testsuite/g++.dg/cpp0x/decltype-pr66548.C:20:3: error: expected
primary-expression before '__typeof__'
compiler exited with status 1
FAIL: g++.dg/cpp0x/decltype-pr66548.C  -std=gnu++98  (test for errors, line 14)

Christophe
Paolo Carlini May 22, 2019, 8:51 a.m. | #3
On 22/05/19 10:28, Christophe Lyon wrote:
> On Tue, 21 May 2019 at 13:03, Paolo Carlini <paolo.carlini@oracle.com> wrote:

>> Hi,

>>

>> also in my back queue a few more location fixes (of course ;) Tested

>> x86_64-linux.

>>

>> Thanks, Paolo.

>>

>> ////////////////

>>

> Hi,

>

> I think you incorrectly committed an additional chunk:


I fixed that earlier today, sorry.

Paolo.

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 271459)
+++ cp/parser.c	(working copy)
@@ -27912,14 +27912,16 @@  cp_parser_template_declaration_after_parameters (c
       if (!ok)
 	{
 	  if (cxx_dialect > cxx17)
-	    error ("literal operator template %qD has invalid parameter list;"
-		   " expected non-type template parameter pack %<<char...>%> "
-		   "or single non-type parameter of class type",
-		   decl);
+	    error_at (DECL_SOURCE_LOCATION (decl), "literal operator "
+		      "template %qD has invalid parameter list; expected "
+		      "non-type template parameter pack %<<char...>%> or "
+		      "single non-type parameter of class type",
+		      decl);
 	  else
-	    error ("literal operator template %qD has invalid parameter list;"
-		   " expected non-type template parameter pack %<<char...>%>",
-		   decl);
+	    error_at (DECL_SOURCE_LOCATION (decl), "literal operator "
+		      "template %qD has invalid parameter list; expected "
+		      "non-type template parameter pack %<<char...>%>",
+		      decl);
 	}
     }
 
Index: testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C
===================================================================
--- testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C	(revision 271459)
+++ testsuite/g++.dg/cpp0x/udlit-tmpl-arg-neg2.C	(working copy)
@@ -2,6 +2,6 @@ 
 // { dg-do compile { target c++11 } }
 
 template <T, T... U>		// { dg-error "'T' has not been declared" }
-int operator"" _foo ();		// { dg-error "has invalid parameter list" }
+int operator"" _foo ();		// { dg-error "5:literal operator template .int operator\"\"_foo\\(\\). has invalid parameter list" }
 template <T... U>		// { dg-error "'T' has not been declared" }
-int operator"" _bar ();		// { dg-error "has invalid parameter list" }
+int operator"" _bar ();		// { dg-error "5:literal operator template .int operator\"\"_bar\\(\\). has invalid parameter list" }
Index: testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C
===================================================================
--- testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C	(revision 271459)
+++ testsuite/g++.dg/cpp0x/udlit-tmpl-parms-neg.C	(working copy)
@@ -3,10 +3,10 @@ 
 class Foo { };
 
 template<wchar_t...>
-  Foo operator"" _Foo(); // { dg-error "literal operator template|has invalid parameter list" }
+  Foo operator"" _Foo(); // { dg-error "7:literal operator template .Foo operator\"\"_Foo\\(\\). has invalid parameter list" }
 
 template<char>
-  Foo operator"" _Bar(); // { dg-error "literal operator template|has invalid parameter list" }
+  Foo operator"" _Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" }
 
 template<typename... Type>
-  Foo operator"" _Bar(); // { dg-error "literal operator template|has invalid parameter list" }
+  Foo operator"" _Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" }