diff options
author | Marek Polacek <polacek@redhat.com> | 2015-04-30 09:35:05 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-04-30 09:35:05 +0000 |
commit | ac9f18db1b0c465646a4aa9566528045c9e4c973 (patch) | |
tree | d6bafc73f07c3c0bb3449ddd288ff6407ffd6869 /gcc/c | |
parent | 9babc352483293e84371af273b1aa1be037cdf31 (diff) | |
download | gcc-ac9f18db1b0c465646a4aa9566528045c9e4c973.zip gcc-ac9f18db1b0c465646a4aa9566528045c9e4c973.tar.gz gcc-ac9f18db1b0c465646a4aa9566528045c9e4c973.tar.bz2 |
c-typeck.c (c_incomplete_type_error): Refactor to use %qT.
* c-typeck.c (c_incomplete_type_error): Refactor to use %qT. Print
the type of a decl.
* gcc.dg/incomplete-typedef-1.c: New test.
From-SVN: r222614
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 16 |
2 files changed, 6 insertions, 13 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 0ee7f1b..3894bb9 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -3,6 +3,9 @@ * c-typeck.c (set_init_label): Call error_at instead of error and pass LOC to it. + * c-typeck.c (c_incomplete_type_error): Refactor to use %qT. Print + the type of a decl. + 2015-04-29 Thomas Schwinge <thomas@codesourcery.com> * c-parser.c (c_parser_oacc_enter_exit_data): Use diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 466079f..413cd07 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -229,15 +229,13 @@ require_complete_type (tree value) void c_incomplete_type_error (const_tree value, const_tree type) { - const char *type_code_string; - /* Avoid duplicate error message. */ if (TREE_CODE (type) == ERROR_MARK) return; if (value != 0 && (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == PARM_DECL)) - error ("%qD has an incomplete type", value); + error ("%qD has an incomplete type %qT", value, type); else { retry: @@ -246,15 +244,8 @@ c_incomplete_type_error (const_tree value, const_tree type) switch (TREE_CODE (type)) { case RECORD_TYPE: - type_code_string = "struct"; - break; - case UNION_TYPE: - type_code_string = "union"; - break; - case ENUMERAL_TYPE: - type_code_string = "enum"; break; case VOID_TYPE: @@ -280,11 +271,10 @@ c_incomplete_type_error (const_tree value, const_tree type) } if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) - error ("invalid use of undefined type %<%s %E%>", - type_code_string, TYPE_NAME (type)); + error ("invalid use of undefined type %qT", type); else /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL. */ - error ("invalid use of incomplete typedef %qD", TYPE_NAME (type)); + error ("invalid use of incomplete typedef %qT", type); } } |