Today I've been playing again with locations in the C++ FE, but of
CALL_EXPRs only this time.  It seems that it's simplest to just set
the location after finish_call_expr does its work rather than to add
many new parameters here and there and pass the location all the way
down to build_cxx_call.  The issue is that build_cxx_call has
7437   location_t loc = EXPR_LOC_OR_LOC (fn, input_location);
7438   fn = build_call_a (fn, nargs, argarray);
7439   SET_EXPR_LOCATION (fn, loc);
but FN is often a FUNCTION_DECL, which cannot carry a location. 

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-09-12  Marek Polacek  <pola...@redhat.com>

        PR c++/60862
gcc/cp/
        * parser.c (cp_parser_postfix_expression) <case CPP_OPEN_PAREN>: Set
        location of a call expression.
gcc/testsuite/
        * g++.dg/diagnostic/pr60862.C: New test.
libstdc++-v3/
        * testsuite/20_util/bind/ref_neg.cc (test01): Adjust dg-error line
        numbers.

diff --git gcc/gcc/cp/parser.c gcc/gcc/cp/parser.c
index c696fd2..1bb72bc 100644
--- gcc/gcc/cp/parser.c
+++ gcc/gcc/cp/parser.c
@@ -6227,6 +6227,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool 
address_p, bool cast_p,
                                    koenig_p,
                                    complain);
 
+           protected_set_expr_location (postfix_expression, loc);
+
            /* The POSTFIX_EXPRESSION is certainly no longer an id.  */
            idk = CP_ID_KIND_NONE;
 
diff --git gcc/gcc/testsuite/g++.dg/diagnostic/pr60862.C 
gcc/gcc/testsuite/g++.dg/diagnostic/pr60862.C
index e69de29..73b7654 100644
--- gcc/gcc/testsuite/g++.dg/diagnostic/pr60862.C
+++ gcc/gcc/testsuite/g++.dg/diagnostic/pr60862.C
@@ -0,0 +1,10 @@
+// PR c++/60862
+// { dg-do compile }
+
+extern void **bar (int, void *, int);
+
+void
+foo (int x, int y)
+{
+  int **s = bar (x, &x, y); // { dg-error "13:invalid conversion" }
+}
diff --git gcc/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc 
gcc/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
index 5a46617..a85ccd8 100644
--- gcc/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
+++ gcc/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
@@ -31,9 +31,9 @@ void test01()
   const int dummy = 0;
   std::bind(&inc, _1)(0);               // { dg-error  "no match" }
   // { dg-error "rvalue|const" "" { target *-*-* } 1315 }
-  // { dg-error "rvalue|const" "" { target *-*-* } 1329 }
-  // { dg-error "rvalue|const" "" { target *-*-* } 1343 }
-  // { dg-error "rvalue|const" "" { target *-*-* } 1357 }
+  // { dg-error "rvalue|const" "" { target *-*-* } 1328 }
+  // { dg-error "rvalue|const" "" { target *-*-* } 1342 }
+  // { dg-error "rvalue|const" "" { target *-*-* } 1356 }
   std::bind(&inc, std::ref(dummy))();  // { dg-error  "no match" }
 }
 
        Marek

Reply via email to