OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2011 18:18:55 +0000 (18:18 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2011 18:18:55 +0000 (18:18 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180309 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/error43.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/error44.C [new file with mode: 0644]

index 11994ee..b58ee15 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2011-10-21  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR c++/50811
index 580f669..0cb1104 100644 (file)
@@ -428,8 +428,15 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
 
     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:
index ef34046..ae3e60f 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/31423
+       * g++.dg/parse/error43.C: New.
+       * g++.dg/parse/error44.C: Likewise.
+
 2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>
            Kirill Yukhin  <kirill.yukhin@intel.com>
 
diff --git a/gcc/testsuite/g++.dg/parse/error43.C b/gcc/testsuite/g++.dg/parse/error43.C
new file mode 100644 (file)
index 0000000..e352fa5
--- /dev/null
@@ -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" }
diff --git a/gcc/testsuite/g++.dg/parse/error44.C b/gcc/testsuite/g++.dg/parse/error44.C
new file mode 100644 (file)
index 0000000..2ebbe71
--- /dev/null
@@ -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 '&'" }
+}