diff options
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 184e922..877f6d9 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7828,15 +7828,20 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, if (!(flags & LOOKUP_NONVIRTUAL) && DECL_PURE_VIRTUAL_P (fn) && instance == current_class_ref - && (DECL_CONSTRUCTOR_P (current_function_decl) - || DECL_DESTRUCTOR_P (current_function_decl)) && (complain & tf_warning)) - /* This is not an error, it is runtime undefined - behavior. */ - warning (0, (DECL_CONSTRUCTOR_P (current_function_decl) ? - "pure virtual %q#D called from constructor" - : "pure virtual %q#D called from destructor"), - fn); + { + /* This is not an error, it is runtime undefined + behavior. */ + if (!current_function_decl) + warning (0, "pure virtual %q#D called from " + "non-static data member initializer", fn); + else if (DECL_CONSTRUCTOR_P (current_function_decl) + || DECL_DESTRUCTOR_P (current_function_decl)) + warning (0, (DECL_CONSTRUCTOR_P (current_function_decl) + ? "pure virtual %q#D called from constructor" + : "pure virtual %q#D called from destructor"), + fn); + } if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE && is_dummy_object (instance)) |