From 146c8d603442514a3d8ad791630e87c2cf5169c3 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 17 Nov 2000 09:48:53 +0000 Subject: [PATCH] typeck2.c (incomplete_type_error): Reorganise to avoid excessive diagnostics. * typeck2.c (incomplete_type_error): Reorganise to avoid excessive diagnostics. From-SVN: r37516 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck2.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a9930eedd64..f059212cd3a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-11-17 Nathan Sidwell + + * typeck2.c (incomplete_type_error): Reorganise to avoid + excessive diagnostics. + 2000-11-16 Zack Weinberg * lex.c (struct impl_files, internal_filename): Constify a char *. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index b030a050490..60933e385d3 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -187,10 +187,18 @@ incomplete_type_error (value, type) tree value; tree type; { + int decl = 0; + /* Avoid duplicate error message. */ if (TREE_CODE (type) == ERROR_MARK) return; + if (value != 0 && (TREE_CODE (value) == VAR_DECL + || TREE_CODE (value) == PARM_DECL)) + { + cp_error_at ("`%D' has incomplete type", value); + decl = 1; + } retry: /* We must print an error message. Be clever about what it says. */ @@ -199,12 +207,13 @@ retry: case RECORD_TYPE: case UNION_TYPE: case ENUMERAL_TYPE: - cp_error ("invalid use of undefined type `%#T'", type); + if (!decl) + cp_error ("invalid use of undefined type `%#T'", type); cp_error_at ("forward declaration of `%#T'", type); break; case VOID_TYPE: - cp_error ("invalid use of void expression"); + cp_error ("invalid use of `%T'", type); break; case ARRAY_TYPE: @@ -239,10 +248,6 @@ retry: default: my_friendly_abort (108); } - - if (value != 0 && (TREE_CODE (value) == VAR_DECL - || TREE_CODE (value) == PARM_DECL)) - cp_error_at ("incomplete `%D' defined here", value); } /* This is a wrapper around fancy_abort, as used in the back end and -- 2.30.2