PR c++/77777 improve location for diagnostic
authorJonathan Wakely <jwakely@redhat.com>
Wed, 30 May 2018 23:13:48 +0000 (00:13 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 30 May 2018 23:13:48 +0000 (00:13 +0100)
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.

From-SVN: r260979

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/pr77777.C [new file with mode: 0644]

index cbec7d01487fcff563ca61a63f57642dfd81cfbc..434fde6ae593ae82339ac9a87ceac25c8a24f63b 100644 (file)
@@ -1,3 +1,9 @@
+2018-05-30  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/77777
+       * call.c (resolve_args): Use location of expression, not current input
+       location.
+
 2018-05-30  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Do not warn about zero-as-null when NULL is used.
index 98319f98c7d50ec3b0ba6932654eae5a433804c5..d222b41c0600583ca7b5d4db6e6493c12c9e7687 100644 (file)
@@ -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;
index 338cbb254b3bf973d6b854f0e526f5ee5b5b6c17..af97797b0f84b50b384a22001333794bffd25b74 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-30  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/77777
+       * g++.dg/diagnostic/pr77777.C: New test.
+
 2018-05-30  David Pagan  <dave.pagan@oracle.com>
 
        PR c/55976
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr77777.C b/gcc/testsuite/g++.dg/diagnostic/pr77777.C
new file mode 100644 (file)
index 0000000..0e7676d
--- /dev/null
@@ -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" }
+   );
+}