diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2000-11-17 09:48:53 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2000-11-17 09:48:53 +0000 |
commit | 146c8d603442514a3d8ad791630e87c2cf5169c3 (patch) | |
tree | 6719ea214e9eb7d8d41cf312484af570b5b68c57 | |
parent | 078c72b67f3047e7f8d67503274fc607cd1083b4 (diff) | |
download | gcc-146c8d603442514a3d8ad791630e87c2cf5169c3.zip gcc-146c8d603442514a3d8ad791630e87c2cf5169c3.tar.gz gcc-146c8d603442514a3d8ad791630e87c2cf5169c3.tar.bz2 |
typeck2.c (incomplete_type_error): Reorganise to avoid excessive diagnostics.
* typeck2.c (incomplete_type_error): Reorganise to avoid
excessive diagnostics.
From-SVN: r37516
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 17 |
2 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a9930ee..f059212 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-11-17 Nathan Sidwell <nathan@codesourcery.com> + + * typeck2.c (incomplete_type_error): Reorganise to avoid + excessive diagnostics. + 2000-11-16 Zack Weinberg <zack@wolery.stanford.edu> * lex.c (struct impl_files, internal_filename): Constify a char *. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index b030a05..60933e3 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 |