Improve diagnostic for forgotten ().
authorJason Merrill <jason@redhat.com>
Fri, 13 May 2016 19:17:47 +0000 (15:17 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 May 2016 19:17:47 +0000 (15:17 -0400)
* parser.c (cp_parser_postfix_dot_deref_expression): Use
complete_type_or_else for unknown_type_node, too.

From-SVN: r236220

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/gomp/udr-4.C
gcc/testsuite/g++.dg/parse/dot1.C
gcc/testsuite/g++.dg/template/pseudodtor3.C

index a48bd47..06ce87f 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-13  Jason Merrill  <jason@redhat.com>
+
+       * parser.c (cp_parser_postfix_dot_deref_expression): Use
+       complete_type_or_else for unknown_type_node, too.
+
 2016-05-12  Marek Polacek  <polacek@redhat.com>
 
        PR c/70756
index f4c6f74..7030740 100644 (file)
@@ -7207,18 +7207,12 @@ 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.  */
-      if (scope == unknown_type_node)
-       {
-         error_at (location, "%qE does not have class type",
-                   postfix_expression.get_value ());
-         scope = NULL_TREE;
-       }
       /* Unlike the object expression in other contexts, *this is not
         required to be of complete type for purposes of class member
         access (5.2.5) outside the member function body.  */
-      else if (postfix_expression != current_class_ref
-              && !(processing_template_decl && scope == current_class_type))
-       scope = complete_type_or_else (scope, NULL_TREE);
+      if (postfix_expression != current_class_ref
+         && !(processing_template_decl && scope == current_class_type))
+       scope = complete_type_or_else (scope, postfix_expression);
       /* Let the name lookup machinery know that we are processing a
         class member access expression.  */
       parser->context->object_type = scope;
index 566d7d1..012ff0c 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do compile }
 
 struct S;                                      // { dg-message "forward declaration" }
-#pragma omp declare reduction (+:S:omp_out.s += omp_in.s) // { dg-error "invalid use of incomplete type" }
+#pragma omp declare reduction (+:S:omp_out.s += omp_in.s) // { dg-error "incomplete type" }
 struct S { int s; S () : s (1) {} };
 #pragma omp declare reduction (*:S:omp_out.s *= omp_in.s)
 
index 3b027d7..416ef92 100644 (file)
@@ -1,4 +1,4 @@
 // PR c++/24560
 
 struct A { void f(); };
-void g() { A().f.a; } // { dg-error "class" }
+void g() { A().f.a; } // { dg-error "invalid use of member function" }
index 8700bb9..8f1f6a7 100644 (file)
@@ -5,7 +5,7 @@ struct A
 {
   typedef int T;
   T &foo ();
-  A () { foo.~T (); }  // { dg-error "10:does not have class type|expected" }
+  A () { foo.~T (); }  // { dg-error "10:invalid use of member function|expected" }
 };
 
 template <typename T> struct B