Commit 827e5d3f by Jason Merrill Committed by Jason Merrill

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
parent a278aa17
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> 2016-05-12 Marek Polacek <polacek@redhat.com>
PR c/70756 PR c/70756
......
...@@ -7207,18 +7207,12 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, ...@@ -7207,18 +7207,12 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
underlying type here. */ underlying type here. */
scope = non_reference (scope); scope = non_reference (scope);
/* The type of the POSTFIX_EXPRESSION must be complete. */ /* 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 /* Unlike the object expression in other contexts, *this is not
required to be of complete type for purposes of class member required to be of complete type for purposes of class member
access (5.2.5) outside the member function body. */ access (5.2.5) outside the member function body. */
else if (postfix_expression != current_class_ref if (postfix_expression != current_class_ref
&& !(processing_template_decl && scope == current_class_type)) && !(processing_template_decl && scope == current_class_type))
scope = complete_type_or_else (scope, NULL_TREE); scope = complete_type_or_else (scope, postfix_expression);
/* Let the name lookup machinery know that we are processing a /* Let the name lookup machinery know that we are processing a
class member access expression. */ class member access expression. */
parser->context->object_type = scope; parser->context->object_type = scope;
// { dg-do compile } // { dg-do compile }
struct S; // { dg-message "forward declaration" } 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) {} }; struct S { int s; S () : s (1) {} };
#pragma omp declare reduction (*:S:omp_out.s *= omp_in.s) #pragma omp declare reduction (*:S:omp_out.s *= omp_in.s)
......
// PR c++/24560 // PR c++/24560
struct A { void f(); }; struct A { void f(); };
void g() { A().f.a; } // { dg-error "class" } void g() { A().f.a; } // { dg-error "invalid use of member function" }
...@@ -5,7 +5,7 @@ struct A ...@@ -5,7 +5,7 @@ struct A
{ {
typedef int T; typedef int T;
T &foo (); 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 template <typename T> struct B
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment