diff mbox series

PR c++/77777 improve location for diagnostic

Message ID 20180530202839.GA5958@redhat.com
State New
Headers show
Series PR c++/77777 improve location for diagnostic | expand

Commit Message

Jonathan Wakely May 30, 2018, 8:28 p.m. UTC
Pass in the location of the invalid expression, not the next input
location (which might be a comma or closing parenthesis on a different
line).

gcc/cp:

	PR c++/77777
	* call.c (resolve_args): Use location of expression, not current input
	location.

gcc/testsuite:

	PR c++/77777
	* g++.dg/diagnostic/pr77777.C: New test.


Tested powerpc64le-linux, OK for trunk?
commit bd001d60121a9978c8945d2dfbc2f607b8493fbe
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed May 30 17:46:43 2018 +0100

    PR c++/77777 improve location for diagnostic
    
    Pass in the location of the invalid expression, not the next input
    location (which might be a comma or closing parenthesis on a different
    line).
    
    gcc/cp:
    
            PR c++/77777
            * call.c (resolve_args): Use location of expression, not current input
            location.
    
    gcc/testsuite:
    
            PR c++/77777
            * g++.dg/diagnostic/pr77777.C: New test.

Comments

Jason Merrill May 30, 2018, 9:29 p.m. UTC | #1
OK.

On Wed, May 30, 2018 at 4:28 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> Pass in the location of the invalid expression, not the next input
> location (which might be a comma or closing parenthesis on a different
> line).
>
> gcc/cp:
>
>         PR c++/77777
>         * call.c (resolve_args): Use location of expression, not current
> input
>         location.
>
> gcc/testsuite:
>
>         PR c++/77777
>         * g++.dg/diagnostic/pr77777.C: New test.
>
>
> Tested powerpc64le-linux, OK for trunk?
>
>
diff mbox series

Patch

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2bbf9837487..ebf63d88623 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4147,7 +4147,7 @@  resolve_args (vec<tree, va_gc> *args, tsubst_flags_t complain)
 	    error ("invalid use of void expression");
 	  return NULL;
 	}
-      else if (invalid_nonstatic_memfn_p (input_location, arg, complain))
+      else if (invalid_nonstatic_memfn_p (arg->exp.locus, arg, complain))
 	return NULL;
     }
   return args;
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr77777.C b/gcc/testsuite/g++.dg/diagnostic/pr77777.C
new file mode 100644
index 00000000000..0e7676d5819
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr77777.C
@@ -0,0 +1,16 @@ 
+// PR c++/77777
+// { dg-do compile }
+
+struct X {
+  int f();
+};
+
+void g(int);
+
+int main()
+{
+  X x;
+  g(
+      x.f  // { dg-error "invalid use of non-static member function" }
+   );
+}