From: Paolo Carlini Date: Wed, 19 Mar 2014 18:21:52 +0000 (+0000) Subject: re PR c++/51474 ([c++0x] ICE with pure virtual function in initialization of non... X-Git-Tag: upstream/12.2.0~64196 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d092805ba995e042a89072bcbf2948800d87d3f;p=platform%2Fupstream%2Fgcc.git re PR c++/51474 ([c++0x] ICE with pure virtual function in initialization of non-static data member) /cp 2014-03-19 Paolo Carlini PR c++/51474 * call.c (build_new_method_call_1): Handle pure virtuals called by NSDMIs too. /testsuite 2014-03-19 Paolo Carlini PR c++/51474 * g++.dg/cpp0x/nsdmi-virtual2.C: New. From-SVN: r208686 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3cf6858..655f6d4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-03-19 Paolo Carlini + + PR c++/51474 + * call.c (build_new_method_call_1): Handle pure virtuals called by + NSDMIs too. + 2014-03-17 Adam Butcher PR c++/60390 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 **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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c40bddb..d0f56cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-03-19 Paolo Carlini + + PR c++/51474 + * g++.dg/cpp0x/nsdmi-virtual2.C: New. + 2014-03-19 H.J. Lu PR testsuite/60590 diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-virtual2.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-virtual2.C new file mode 100644 index 0000000..157854c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-virtual2.C @@ -0,0 +1,8 @@ +// PR c++/51474 +// { dg-do compile { target c++11 } } + +struct A +{ + virtual int foo() = 0; + int i = foo(); // { dg-warning "pure virtual" } +};