public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 48630 (PR 31423)
@ 2011-10-19 22:13 Paolo Carlini
  2011-10-19 22:18 ` Gabriel Dos Reis
  2011-10-19 23:39 ` Jason Merrill
  0 siblings, 2 replies; 12+ messages in thread
From: Paolo Carlini @ 2011-10-19 22:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 643 bytes --]

Hi,

in these two twin PRs filed by Ian and Gerald, it is pointed out that 
cases like:

    struct C {
      int f() { return 1; }
    };

    int f(C&c) {
      return ( 1 == c.f );
    }

where the user actually forgot the open-closed round braces are much 
more likely than cases where an ampersand is missing, still we output

invalid use of member (did you forget the ‘&’ ?)

Thus, the idea of saying instead

invalid use of member (did you forget the ‘()’ ?)

which I implemented in the patchlet below. Alternately we could give 
both hints, or refer to the argument list.

Tested x86_64-linux.

Thanks,
Paolo.

///////////////////

[-- Attachment #2: CL_48630 --]
[-- Type: text/plain, Size: 314 bytes --]

/cp
2011-10-19  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/31423
	PR c++/48630
	* typeck2.c (cxx_incomplete_type_diagnostic): Improve error message
	for invalid use of member.

/testsuite
2011-10-19  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/31423
	PR c++/48630
	* g++.dg/parse/error42.C: New.




[-- Attachment #3: patch_48630 --]
[-- Type: text/plain, Size: 890 bytes --]

Index: testsuite/g++.dg/parse/error42.C
===================================================================
--- testsuite/g++.dg/parse/error42.C	(revision 0)
+++ testsuite/g++.dg/parse/error42.C	(revision 0)
@@ -0,0 +1,5 @@
+// PR c++/48630
+// { dg-options "" }
+
+class C { public: C* f(); int get(); }; // { dg-error "forget the '\\(\\)'|base operand" }
+int f(C* p) { return p->f->get(); }
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c	(revision 180206)
+++ cp/typeck2.c	(working copy)
@@ -429,7 +429,7 @@ 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 %<&%> ?)");
+		       "invalid use of member (did you forget the %<()%> ?)");
       break;
 
     case TEMPLATE_TYPE_PARM:

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-10-22  0:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-19 22:13 [C++ Patch] PR 48630 (PR 31423) 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
2011-10-21 18:42                 ` Jason Merrill
2011-10-22  5:54                 ` Gabriel Dos Reis

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).