From: Paolo Carlini <paolo.carlini@oracle.com>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: Jason Merrill <jason@redhat.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 48630 (PR 31423)
Date: Fri, 21 Oct 2011 18:31:00 -0000 [thread overview]
Message-ID: <4EA1B14E.80307@oracle.com> (raw)
In-Reply-To: <4E9F736D.8000404@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]
Hi again,
>> Another acceptable fix is to
>> -- leave the current diagnostic as is if -fms-extensions
>> -- suggest '()' is member function
>> -- otherwise suggest '&'.
> Thanks for your help Gaby, in particular about the MS extension which
> I had overlooked completely (as any hard-code Linux guy would ;).
> Anyway, seriously, I'll try to come up with an improved proposal over
> the next days.
Thus I tested on x86_64-linux the below. Ok for mainline?
Thanks,
Paolo.
/////////////////////////
[-- Attachment #2: CL_31423 --]
[-- Type: text/plain, Size: 329 bytes --]
/cp
2011-10-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31423
* typeck2.c (cxx_incomplete_type_diagnostic): Improve error message
for invalid use of member function.
/testsuite
2011-10-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31423
* g++.dg/parse/error43.C: New.
* g++.dg/parse/error44.C: Likewise.
[-- Attachment #3: patch_31423 --]
[-- Type: text/plain, Size: 1599 bytes --]
Index: testsuite/g++.dg/parse/error43.C
===================================================================
--- testsuite/g++.dg/parse/error43.C (revision 0)
+++ testsuite/g++.dg/parse/error43.C (revision 0)
@@ -0,0 +1,5 @@
+// PR c++/31423
+// { dg-options "" }
+
+class C { public: C* f(); int get(); };
+int f(C* p) { return p->f->get(); } // { dg-error "forget the '\\(\\)'|base operand" }
Index: testsuite/g++.dg/parse/error44.C
===================================================================
--- testsuite/g++.dg/parse/error44.C (revision 0)
+++ testsuite/g++.dg/parse/error44.C (revision 0)
@@ -0,0 +1,11 @@
+// PR c++/31423
+// { dg-options "-fms-extensions" }
+
+struct C {
+ int f() { return 1; }
+ int g() { return 2; }
+};
+
+int f(C& c) {
+ return c.g == &c.f; // { dg-error "forget the '&'" }
+}
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c (revision 180307)
+++ cp/typeck2.c (working copy)
@@ -428,8 +428,15 @@ cxx_incomplete_type_diagnostic (const_tree value,
case OFFSET_TYPE:
bad_member:
- emit_diagnostic (diag_kind, input_location, 0,
- "invalid use of member (did you forget the %<&%> ?)");
+ if (DECL_FUNCTION_MEMBER_P (TREE_OPERAND (value, 1))
+ && ! flag_ms_extensions)
+ emit_diagnostic (diag_kind, input_location, 0,
+ "invalid use of member function "
+ "(did you forget the %<()%> ?)");
+ else
+ emit_diagnostic (diag_kind, input_location, 0,
+ "invalid use of member "
+ "(did you forget the %<&%> ?)");
break;
case TEMPLATE_TYPE_PARM:
next prev parent reply other threads:[~2011-10-21 17:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-19 22:13 Paolo Carlini
2011-10-19 22:18 ` Gabriel Dos Reis
2011-10-19 23:39 ` Jason Merrill
2011-10-20 0:12 ` Paolo Carlini
2011-10-20 0:47 ` Gabriel Dos Reis
2011-10-20 1:06 ` Paolo Carlini
2011-10-20 4:40 ` Gabriel Dos Reis
2011-10-20 5:48 ` Gabriel Dos Reis
2011-10-20 6:03 ` Paolo Carlini
2011-10-21 18:31 ` Paolo Carlini [this message]
2011-10-21 18:42 ` Jason Merrill
2011-10-22 5:54 ` Gabriel Dos Reis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EA1B14E.80307@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gdr@integrable-solutions.net \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).