diff options
author | Giovanni Bajo <giovannibajo@gcc.gnu.org> | 2004-02-05 02:48:31 +0000 |
---|---|---|
committer | Giovanni Bajo <giovannibajo@gcc.gnu.org> | 2004-02-05 02:48:31 +0000 |
commit | b1e5b86c5245015820f99043feb2fe5e9958daa7 (patch) | |
tree | 5064c31166066fcd9c2eaafa931c5dacf4345b1c /gcc | |
parent | 6f3d0d2f8d6f7b1405a9e2548dd71dd0d26f3fe2 (diff) | |
download | gcc-b1e5b86c5245015820f99043feb2fe5e9958daa7.zip gcc-b1e5b86c5245015820f99043feb2fe5e9958daa7.tar.gz gcc-b1e5b86c5245015820f99043feb2fe5e9958daa7.tar.bz2 |
re PR c++/13086 (the location of the warning message is wrong when calling delete on incomplete type)
PR c++/13086
* init.c (build_delete): Emit a more informative error message in
case of an incomplete type, and on the correct source line.
From-SVN: r77289
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 38 |
2 files changed, 31 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ae4493a..083bebe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-02-04 Giovanni Bajo <giovannibajo@gcc.gnu.org> + + PR c++/13086 + * init.c (build_delete): Emit a more informative error message in + case of an incomplete type, and on the correct source line. + 2004-02-04 Kazu Hirata <kazu@cs.umass.edu> * error.c, search.c: Update copyright. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 2c89996..e380444 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2020,12 +2020,12 @@ build_new_1 (tree exp) use_java_new = 1; if (!get_global_value_if_present (get_identifier (alloc_name), &alloc_decl)) - {
+ { error ("call to Java constructor with `%s' undefined", alloc_name); return error_mark_node; } else if (really_overloaded_fn (alloc_decl)) - {
+ { error ("`%D' should never be overloaded", alloc_decl); return error_mark_node; } @@ -2856,23 +2856,35 @@ build_delete (tree type, tree addr, special_function_kind auto_delete, if (TREE_CODE (type) == POINTER_TYPE) { + bool complete_p = true; + type = TYPE_MAIN_VARIANT (TREE_TYPE (type)); if (TREE_CODE (type) == ARRAY_TYPE) goto handle_array; - if (VOID_TYPE_P (type) - /* We don't want to warn about delete of void*, only other - incomplete types. Deleting other incomplete types - invokes undefined behavior, but it is not ill-formed, so - compile to something that would even do The Right Thing - (TM) should the type have a trivial dtor and no delete - operator. */ - || !complete_type_or_diagnostic (type, addr, 1) - || !IS_AGGR_TYPE (type)) + /* We don't want to warn about delete of void*, only other + incomplete types. Deleting other incomplete types + invokes undefined behavior, but it is not ill-formed, so + compile to something that would even do The Right Thing + (TM) should the type have a trivial dtor and no delete + operator. */ + if (!VOID_TYPE_P (type)) { - /* Call the builtin operator delete. */ - return build_builtin_delete_call (addr); + complete_type (type); + if (!COMPLETE_TYPE_P (type)) + { + warning ("possible problem detected in invocation of " + "delete operator:"); + cxx_incomplete_type_diagnostic (addr, type, 1); + inform ("neither the destructor nor the class-specific "
+ "operator delete will be called, even if they are "
+ "declared when the class is defined."); + complete_p = false; + } } + if (VOID_TYPE_P (type) || !complete_p || !IS_AGGR_TYPE (type)) + /* Call the builtin operator delete. */ + return build_builtin_delete_call (addr); if (TREE_SIDE_EFFECTS (addr)) addr = save_expr (addr); |