Commit 05bf54c3 by Marek Polacek Committed by Marek Polacek

re PR c++/69379 (ICE in fold_convert_loc, at fold-const.c:2366)

	PR c++/69379
	* constexpr.c (cxx_eval_constant_expression): Handle PTRMEM_CSTs
	wrapped in NOP_EXPRs.

	* g++.dg/pr69379.C: New test.

From-SVN: r232882
parent 60214d0d
2016-01-27 Marek Polacek <polacek@redhat.com>
PR c++/69379
* constexpr.c (cxx_eval_constant_expression): Handle PTRMEM_CSTs
wrapped in NOP_EXPRs.
2016-01-27 Martin Sebor <msebor@redhat.com>
PR c++/69317
......
......@@ -3659,6 +3659,20 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (TREE_CODE (op) == PTRMEM_CST
&& !TYPE_PTRMEM_P (type))
op = cplus_expand_constant (op);
if (TREE_CODE (op) == PTRMEM_CST && tcode == NOP_EXPR)
{
if (same_type_ignoring_top_level_qualifiers_p (type,
TREE_TYPE (op)))
STRIP_NOPS (t);
else
{
if (!ctx->quiet)
error_at (EXPR_LOC_OR_LOC (t, input_location),
"a reinterpret_cast is not a constant-expression");
*non_constant_p = true;
return t;
}
}
if (POINTER_TYPE_P (type)
&& TREE_CODE (op) == INTEGER_CST
&& !integer_zerop (op))
......
2016-01-27 Marek Polacek <polacek@redhat.com>
PR c++/69379
* g++.dg/pr69379.C: New test.
2016-01-27 Martin Sebor <msebor@redhat.com>
PR c++/69317
......
// PR c++/69379
// { dg-do compile }
// { dg-options "-Wformat" }
typedef int T;
class A {
public:
template <class D> A(const char *, D);
template <class Fn, class A1, class A2>
void m_fn1(const char *, Fn, A1 const &, A2);
};
struct Dict {
void m_fn2();
};
void fn1() {
A a("", "");
typedef void *Get;
typedef void (Dict::*d)(T);
a.m_fn1("", Get(), d(&Dict::m_fn2), "");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment