From: Marek Polacek Date: Tue, 24 Sep 2019 14:38:53 +0000 (+0000) Subject: PR c++/91845 - ICE with invalid pointer-to-member. X-Git-Tag: upstream/12.2.0~21663 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fea3397e56a3662a9b2361c14e427c9786042ebf;p=platform%2Fupstream%2Fgcc.git PR c++/91845 - ICE with invalid pointer-to-member. * expr.c (mark_use): Use error_operand_p. * typeck2.c (build_m_component_ref): Check error_operand_p after calling mark_[lr]value_use. * g++.dg/cpp1y/pr91845.C: New test. From-SVN: r276102 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5b561e6..1cd2a63 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-09-24 Marek Polacek + + PR c++/91845 - ICE with invalid pointer-to-member. + * expr.c (mark_use): Use error_operand_p. + * typeck2.c (build_m_component_ref): Check error_operand_p after + calling mark_[lr]value_use. + 2019-09-23 Paolo Carlini * pt.c (check_explicit_specialization): Use cp_expr_loc_or_input_loc. diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index 212a7f9..d488912 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -96,7 +96,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p, { #define RECUR(t) mark_use ((t), rvalue_p, read_p, loc, reject_builtin) - if (expr == NULL_TREE || expr == error_mark_node) + if (expr == NULL_TREE || error_operand_p (expr)) return expr; if (reject_builtin && reject_gcc_builtin (expr, loc)) diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index d5098fa..58fa54f 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -2068,12 +2068,12 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) tree binfo; tree ctype; - if (error_operand_p (datum) || error_operand_p (component)) - return error_mark_node; - datum = mark_lvalue_use (datum); component = mark_rvalue_use (component); + if (error_operand_p (datum) || error_operand_p (component)) + return error_mark_node; + ptrmem_type = TREE_TYPE (component); if (!TYPE_PTRMEM_P (ptrmem_type)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55b3bab..a38a057 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-24 Marek Polacek + + PR c++/91845 - ICE with invalid pointer-to-member. + * g++.dg/cpp1y/pr91845.C: New test. + 2019-09-24 Kyrylo Tkachov * gcc.target/aarch64/nosplit-di-const-volatile_1.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1y/pr91845.C b/gcc/testsuite/g++.dg/cpp1y/pr91845.C new file mode 100644 index 0000000..cb80dd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr91845.C @@ -0,0 +1,14 @@ +// PR c++/91845 - ICE with invalid pointer-to-member. +// { dg-do compile { target c++14 } } + +void non_const_mem_ptr() { + struct A { + }; + constexpr A a = {1, 2}; // { dg-error "too many initializers" } + struct B { + int A::*p; + constexpr int g() const { + return a.*p; // { dg-error "use of local variable" } + }; + }; +}