This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Improve location of CALL_EXPRs (PR c++/60862)
- From: Marek Polacek <polacek at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 13 Sep 2014 09:51:14 +0200
- Subject: Re: [C++ PATCH] Improve location of CALL_EXPRs (PR c++/60862)
- Authentication-results: sourceware.org; auth=none
- References: <20140912205202 dot GA23226 at redhat dot com> <541397FD dot 5000808 at redhat dot com>
On Fri, Sep 12, 2014 at 09:03:57PM -0400, Jason Merrill wrote:
> On 09/12/2014 04:52 PM, Marek Polacek wrote:
> >+ protected_set_expr_location (postfix_expression, loc);
>
> Let's use the location of the (, which should just be token->location at
> this point. So column 17 instead of 13 in the new test. OK with that
> change.
Ok, fixed.
> In some cases postfix_expression won't be a CALL_EXPR at this point; it
> might be a TARGET_EXPR or an INDIRECT_REF. But I suppose setting the
> location on whatever it happens to be will work well enough for now.
Right. I didn't want to add a check for a CALL_EXPR, since I think
that for other *_EXPRs this should work equally well.
(The libstdc++ bits weren't needed no more, so I dropped 'em.)
Bootstrapped/regtested on x86_64-linux, applying to trunk.
2014-09-13 Marek Polacek <polacek@redhat.com>
PR c++/60862
* parser.c (cp_parser_postfix_expression) <case CPP_OPEN_PAREN>: Set
location of a call expression.
* g++.dg/diagnostic/pr60862.C: New test.
diff --git gcc/gcc/cp/parser.c gcc/gcc/cp/parser.c
index c696fd2..a3c947a 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, token->location);
+
/* 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..cc5279c 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 "17:invalid conversion" }
+}
Marek