From 393d9df7b33313418ae8921cdb587537bd641c1c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 20 Feb 2018 09:22:31 +0100 Subject: [PATCH] re PR c++/84445 (ICE with __builtin_launder and virtual function) PR c++/84445 * class.c (fixed_type_or_null) : Only test TREE_HAS_CONSTRUCTOR if instance is not an internal function call. * g++.dg/cpp1z/launder7.C: New test. From-SVN: r257840 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/class.c | 3 ++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp1z/launder7.C | 10 ++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/launder7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8a786bb4c06..1e0f9eb321f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-02-20 Jakub Jelinek + PR c++/84445 + * class.c (fixed_type_or_null) : Only test + TREE_HAS_CONSTRUCTOR if instance is not an internal function call. + PR c++/84449 * tree.c (bot_manip): If build_cplus_new or break_out_target_exprs returns error_mark_node, return it immediately. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 296305ea644..afa5c41bfff 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7128,7 +7128,8 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) case CALL_EXPR: /* This is a call to a constructor, hence it's never zero. */ - if (TREE_HAS_CONSTRUCTOR (instance)) + if (CALL_EXPR_FN (instance) + && TREE_HAS_CONSTRUCTOR (instance)) { if (nonnull) *nonnull = 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd21d3b8a42..29157ac3c24 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-02-20 Jakub Jelinek + PR c++/84445 + * g++.dg/cpp1z/launder7.C: New test. + PR c++/84449 * g++.dg/cpp0x/constexpr-84449.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/launder7.C b/gcc/testsuite/g++.dg/cpp1z/launder7.C new file mode 100644 index 00000000000..e418329f931 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/launder7.C @@ -0,0 +1,10 @@ +// PR c++/84445 +// { dg-do compile } + +struct A { virtual void foo (); }; + +void +bar (A *p) +{ + __builtin_launder (p)->foo (); +} -- 2.30.2