re PR c++/24560 ("insufficient contextual information to determine type" is not a...
authorMark Mitchell <mark@codesourcery.com>
Wed, 2 Nov 2005 23:36:05 +0000 (23:36 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 2 Nov 2005 23:36:05 +0000 (23:36 +0000)
PR c++/24560
* parser.c (cp_parser_postfix_dot_deref_expression): Improve error
message for use of overloaded functions on LHS of "." operator.
PR c++/24560
* g++.dg/parse/dot1.C: New test.

From-SVN: r106408

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

index 3df790125ee9face0d76783f27d1cb4849d7e9ea..8d2ab78a21408166a86c3d72814d2569cfcdad90 100644 (file)
@@ -1,5 +1,9 @@
 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.
+
        PR c++/19253
        * parser.c (cp_parser_postfix_expression): Use
        cp_parser_elaborated_type_specifier to handle typename-types in
index 94ce45f5f2d39d4014fd746d9297d85eb430e809..9821981f310f43e453226b0fc9cbea2e7c95f774 100644 (file)
@@ -4363,7 +4363,13 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
         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 058fcb30e3e8dba569058ed48f9f6616b110e372..e71f25cbdc8d01be26f5dcd0cfaf0e366aab54c2 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/24560
+       * g++.dg/parse/dot1.C: New test.
+
 2005-11-02  Jan Hubicka  <jh@suse.cz>
 
        PR target/23303
diff --git a/gcc/testsuite/g++.dg/parse/dot1.C b/gcc/testsuite/g++.dg/parse/dot1.C
new file mode 100644 (file)
index 0000000..3b027d7
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/24560
+
+struct A { void f(); };
+void g() { A().f.a; } // { dg-error "class" }