From 827e5d3f706ff07400025488c76e1ad7b3300d83 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 13 May 2016 15:17:47 -0400 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 12 +++--------- gcc/testsuite/g++.dg/gomp/udr-4.C | 2 +- gcc/testsuite/g++.dg/parse/dot1.C | 2 +- gcc/testsuite/g++.dg/template/pseudodtor3.C | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a48bd4740fa..06ce87f8ba6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-05-13 Jason Merrill + + * parser.c (cp_parser_postfix_dot_deref_expression): Use + complete_type_or_else for unknown_type_node, too. + 2016-05-12 Marek Polacek PR c/70756 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f4c6f74b3d0..7030740c239 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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; diff --git a/gcc/testsuite/g++.dg/gomp/udr-4.C b/gcc/testsuite/g++.dg/gomp/udr-4.C index 566d7d1321f..012ff0c97dd 100644 --- a/gcc/testsuite/g++.dg/gomp/udr-4.C +++ b/gcc/testsuite/g++.dg/gomp/udr-4.C @@ -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) diff --git a/gcc/testsuite/g++.dg/parse/dot1.C b/gcc/testsuite/g++.dg/parse/dot1.C index 3b027d7c1f0..416ef925287 100644 --- a/gcc/testsuite/g++.dg/parse/dot1.C +++ b/gcc/testsuite/g++.dg/parse/dot1.C @@ -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" } diff --git a/gcc/testsuite/g++.dg/template/pseudodtor3.C b/gcc/testsuite/g++.dg/template/pseudodtor3.C index 8700bb95252..8f1f6a736a8 100644 --- a/gcc/testsuite/g++.dg/template/pseudodtor3.C +++ b/gcc/testsuite/g++.dg/template/pseudodtor3.C @@ -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 struct B -- 2.30.2