Improve diagnostic for forgotten ().

* parser.c (cp_parser_postfix_dot_deref_expression): Use
	complete_type_or_else for unknown_type_node, too.

From-SVN: r236220
This commit is contained in:
Jason Merrill 2016-05-13 15:17:47 -04:00 committed by Jason Merrill
parent a278aa17f4
commit 827e5d3f70
5 changed files with 11 additions and 12 deletions

View 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

View 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;

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

View 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" }

View 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