This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 24560


This patch fixes a bad diagnostic from the C++ parser.  In particular,
when the left-hand side of "." was a function (like "a.f", where "f"
is a member function), we issued a message about having insufficient
context to resolve the overload; this makes us say something
considerably more helpful.

Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
4.0 branch. 

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-11-02  Mark Mitchell  <mark@codesourcery.com>

	PR c++/24560
	* parser.c (cp_parser_postfix_dot_deref_expression): Improve error
	message for use of overloaded functions on LHS of "." operator.

2005-11-02  Mark Mitchell  <mark@codesourcery.com>

	PR c++/24560
	* g++.dg/parse/dot1.C: New test.

Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 106398)
+++ gcc/cp/parser.c	(working copy)
@@ -4363,7 +4363,13 @@ cp_parser_postfix_dot_deref_expression (
 	 underlying type here.  */
       scope = non_reference (scope);
       /* The type of the POSTFIX_EXPRESSION must be complete.  */
-      scope = complete_type_or_else (scope, NULL_TREE);
+      if (scope == unknown_type_node)
+	{
+	  error ("%qE does not have class type", postfix_expression);
+	  scope = NULL_TREE;
+	}
+      else
+	scope = complete_type_or_else (scope, NULL_TREE);
       /* Let the name lookup machinery know that we are processing a
 	 class member access expression.  */
       parser->context->object_type = scope;
Index: gcc/testsuite/g++.dg/parse/dot1.C
===================================================================
--- gcc/testsuite/g++.dg/parse/dot1.C	(revision 0)
+++ gcc/testsuite/g++.dg/parse/dot1.C	(revision 0)
@@ -0,0 +1,4 @@
+// PR c++/24560
+
+struct A { void f(); };
+void g() { A().f.a; } // { dg-error "class" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]