This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: tidy up incomplete_type_error
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH]: tidy up incomplete_type_error
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 17 Nov 2000 10:15:57 +0000
- Organization: Codesourcery LLC
Hi,
I've installed the attached which tidies up incomplete_type_error so
that it doesn't issue excessive diagnostics.
built & tested on i686-pc-linux-gnu, approved by Mark,
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-11-15 Nathan Sidwell <nathan@codesourcery.com>
* typeck2.c (incomplete_type_error): Reorganise to avoid
excessive diagnostics.
Index: cp/typeck2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.89
diff -c -3 -p -r1.89 typeck2.c
*** typeck2.c 2000/10/20 20:23:11 1.89
--- typeck2.c 2000/11/15 15:23:03
*************** incomplete_type_error (value, type)
*** 187,196 ****
--- 187,204 ----
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. */
*************** retry:
*** 199,210 ****
case RECORD_TYPE:
case UNION_TYPE:
case ENUMERAL_TYPE:
! 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");
break;
case ARRAY_TYPE:
--- 207,219 ----
case RECORD_TYPE:
case UNION_TYPE:
case ENUMERAL_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 `%T'", type);
break;
case ARRAY_TYPE:
*************** retry:
*** 239,248 ****
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
--- 248,253 ----