diff mbox series

[C++] Improve build_x_unary_op locations

Message ID 9c05a55c-5389-1e91-8552-c177945008ed@oracle.com
State New
Headers show
Series [C++] Improve build_x_unary_op locations | expand

Commit Message

Paolo Carlini Oct. 22, 2019, 6:48 p.m. UTC
Hi,

at the moment I'm going through more typeck.c and typeck2.c functions: 
the below are some straightforward changes for build_x_unary_op (fwiw, 
the resulting locations are also consistent with clang)

Tested x86_64-linux.

Thanks, Paolo.

////////////////////////////
/cp
2019-10-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck.c (build_x_unary_op): Use the location_t argument in
	three error_at.

/testsuite
2019-10-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/other/ptrmem8.C: Test locations too.
	* g++.dg/template/dtor6.C: Likewise.

Comments

Marek Polacek Oct. 22, 2019, 6:52 p.m. UTC | #1
On Tue, Oct 22, 2019 at 08:48:30PM +0200, Paolo Carlini wrote:
> Hi,
> 
> at the moment I'm going through more typeck.c and typeck2.c functions: the
> below are some straightforward changes for build_x_unary_op (fwiw, the
> resulting locations are also consistent with clang)
> 
> Tested x86_64-linux.

Can't approve but looks OK, thanks.

Marek
Jason Merrill Oct. 29, 2019, 8:26 p.m. UTC | #2
On 10/22/19 2:52 PM, Marek Polacek wrote:
> On Tue, Oct 22, 2019 at 08:48:30PM +0200, Paolo Carlini wrote:
>> Hi,
>>
>> at the moment I'm going through more typeck.c and typeck2.c functions: the
>> below are some straightforward changes for build_x_unary_op (fwiw, the
>> resulting locations are also consistent with clang)
>>
>> Tested x86_64-linux.
> 
> Can't approve but looks OK, thanks.

Yes, OK.

Jason
diff mbox series

Patch

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 277268)
+++ cp/typeck.c	(working copy)
@@ -5829,10 +5831,10 @@  build_x_unary_op (location_t loc, enum tree_code c
 	  if (DECL_CONSTRUCTOR_P (fn) || DECL_DESTRUCTOR_P (fn))
 	    {
 	      if (complain & tf_error)
-		error (DECL_CONSTRUCTOR_P (fn)
-		       ? G_("taking address of constructor %qD")
-		       : G_("taking address of destructor %qD"),
-		       fn);
+		error_at (loc, DECL_CONSTRUCTOR_P (fn)
+			  ? G_("taking address of constructor %qD")
+			  : G_("taking address of destructor %qD"),
+			  fn);
 	      return error_mark_node;
 	    }
 	}
@@ -5847,10 +5849,10 @@  build_x_unary_op (location_t loc, enum tree_code c
 	    {
 	      if (complain & tf_error)
 		{
-		  error ("invalid use of %qE to form a "
-			 "pointer-to-member-function", xarg.get_value ());
+		  error_at (loc, "invalid use of %qE to form a "
+			    "pointer-to-member-function", xarg.get_value ());
 		  if (TREE_CODE (xarg) != OFFSET_REF)
-		    inform (input_location, "  a qualified-id is required");
+		    inform (loc, "  a qualified-id is required");
 		}
 	      return error_mark_node;
 	    }
@@ -5857,9 +5859,9 @@  build_x_unary_op (location_t loc, enum tree_code c
 	  else
 	    {
 	      if (complain & tf_error)
-		error ("parentheses around %qE cannot be used to form a"
-		       " pointer-to-member-function",
-		       xarg.get_value ());
+		error_at (loc, "parentheses around %qE cannot be used to "
+			  "form a pointer-to-member-function",
+			  xarg.get_value ());
 	      else
 		return error_mark_node;
 	      PTRMEM_OK_P (xarg) = 1;
Index: testsuite/g++.dg/other/ptrmem8.C
===================================================================
--- testsuite/g++.dg/other/ptrmem8.C	(revision 277268)
+++ testsuite/g++.dg/other/ptrmem8.C	(working copy)
@@ -6,11 +6,11 @@  struct A {};
 template<int> void foo(void (A::* f)())
 {
   A a;
-  &(a.*f);	// { dg-error "invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" }
+  &(a.*f);	// { dg-error "3:invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" }
 }
 
 template<int> void bar(void (A::* f)())
 {
   A *p;
-  &(p->*f);	// { dg-error "invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" }
+  &(p->*f);	// { dg-error "3:invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" }
 }
Index: testsuite/g++.dg/template/dtor6.C
===================================================================
--- testsuite/g++.dg/template/dtor6.C	(revision 277268)
+++ testsuite/g++.dg/template/dtor6.C	(working copy)
@@ -5,12 +5,12 @@  template<int> struct A
   static int i;
 };
 
-template<int N> int A<N>::i = { A::~A }; // { dg-error "non-static member function" }
+template<int N> int A<N>::i = { A::~A }; // { dg-error "36:invalid use of non-static member function" }
 
 template class A<0>;
 
 struct X { };
 
-int i1 = X::~X;			// { dg-error "non-static member function" }
-int i2 = &X::~X;		// { dg-error "address of destructor" }
-int i3 = &A<0>::~A;		// { dg-error "address of destructor" }
+int i1 = X::~X;			// { dg-error "13:invalid use of non-static member function" }
+int i2 = &X::~X;		// { dg-error "10:taking address of destructor" }
+int i3 = &A<0>::~A;		// { dg-error "10:taking address of destructor" }