mirror of git://gcc.gnu.org/git/gcc.git
constexpr.c (potential_nondependent_constant_expression): New.
* constexpr.c (potential_nondependent_constant_expression): New. (potential_nondependent_static_init_expression): New. (maybe_constant_value_1, fold_non_dependent_expr) (maybe_constant_init): Use them. * pt.c (instantiate_non_dependent_expr_sfinae) (instantiate_non_dependent_or_null, convert_nontype_argument): Use them. * cp-tree.h: Declare them. From-SVN: r234944
This commit is contained in:
parent
3eddc1c971
commit
eb07f187a4
|
|
@ -1,3 +1,14 @@
|
|||
2016-04-13 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* constexpr.c (potential_nondependent_constant_expression): New.
|
||||
(potential_nondependent_static_init_expression): New.
|
||||
(maybe_constant_value_1, fold_non_dependent_expr)
|
||||
(maybe_constant_init): Use them.
|
||||
* pt.c (instantiate_non_dependent_expr_sfinae)
|
||||
(instantiate_non_dependent_or_null, convert_nontype_argument): Use
|
||||
them.
|
||||
* cp-tree.h: Declare them.
|
||||
|
||||
2016-04-13 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/70594
|
||||
|
|
|
|||
|
|
@ -4315,10 +4315,7 @@ maybe_constant_value_1 (tree t, tree decl)
|
|||
{
|
||||
tree r;
|
||||
|
||||
if (instantiation_dependent_expression_p (t)
|
||||
|| type_unknown_p (t)
|
||||
|| BRACE_ENCLOSED_INITIALIZER_P (t)
|
||||
|| !potential_constant_expression (t))
|
||||
if (!potential_nondependent_constant_expression (t))
|
||||
{
|
||||
if (TREE_OVERFLOW_P (t))
|
||||
{
|
||||
|
|
@ -4397,8 +4394,7 @@ fold_non_dependent_expr (tree t)
|
|||
as two declarations of the same function, for example. */
|
||||
if (processing_template_decl)
|
||||
{
|
||||
if (!instantiation_dependent_expression_p (t)
|
||||
&& potential_constant_expression (t))
|
||||
if (potential_nondependent_constant_expression (t))
|
||||
{
|
||||
processing_template_decl_sentinel s;
|
||||
t = instantiate_non_dependent_expr_internal (t, tf_none);
|
||||
|
|
@ -4449,10 +4445,7 @@ maybe_constant_init (tree t, tree decl)
|
|||
t = TREE_OPERAND (t, 0);
|
||||
if (TREE_CODE (t) == INIT_EXPR)
|
||||
t = TREE_OPERAND (t, 1);
|
||||
if (instantiation_dependent_expression_p (t)
|
||||
|| type_unknown_p (t)
|
||||
|| BRACE_ENCLOSED_INITIALIZER_P (t)
|
||||
|| !potential_static_init_expression (t))
|
||||
if (!potential_nondependent_static_init_expression (t))
|
||||
/* Don't try to evaluate it. */;
|
||||
else
|
||||
t = cxx_eval_outermost_constant_expr (t, true, false, decl);
|
||||
|
|
@ -5203,4 +5196,29 @@ require_potential_rvalue_constant_expression (tree t)
|
|||
return potential_constant_expression_1 (t, true, true, tf_warning_or_error);
|
||||
}
|
||||
|
||||
/* Returns true if T is a potential constant expression that is not
|
||||
instantiation-dependent, and therefore a candidate for constant folding even
|
||||
in a template. */
|
||||
|
||||
bool
|
||||
potential_nondependent_constant_expression (tree t)
|
||||
{
|
||||
return (!type_unknown_p (t)
|
||||
&& !BRACE_ENCLOSED_INITIALIZER_P (t)
|
||||
&& potential_constant_expression (t)
|
||||
&& !instantiation_dependent_expression_p (t));
|
||||
}
|
||||
|
||||
/* Returns true if T is a potential static initializer expression that is not
|
||||
instantiation-dependent. */
|
||||
|
||||
bool
|
||||
potential_nondependent_static_init_expression (tree t)
|
||||
{
|
||||
return (!type_unknown_p (t)
|
||||
&& !BRACE_ENCLOSED_INITIALIZER_P (t)
|
||||
&& potential_static_init_expression (t)
|
||||
&& !instantiation_dependent_expression_p (t));
|
||||
}
|
||||
|
||||
#include "gt-cp-constexpr.h"
|
||||
|
|
|
|||
|
|
@ -6884,6 +6884,8 @@ extern tree register_constexpr_fundef (tree, tree);
|
|||
extern bool check_constexpr_ctor_body (tree, tree, bool);
|
||||
extern tree ensure_literal_type_for_constexpr_object (tree);
|
||||
extern bool potential_constant_expression (tree);
|
||||
extern bool potential_nondependent_constant_expression (tree);
|
||||
extern bool potential_nondependent_static_init_expression (tree);
|
||||
extern bool potential_static_init_expression (tree);
|
||||
extern bool potential_rvalue_constant_expression (tree);
|
||||
extern bool require_potential_constant_expression (tree);
|
||||
|
|
|
|||
12
gcc/cp/pt.c
12
gcc/cp/pt.c
|
|
@ -5655,8 +5655,7 @@ instantiate_non_dependent_expr_sfinae (tree expr, tsubst_flags_t complain)
|
|||
|
||||
as two declarations of the same function, for example. */
|
||||
if (processing_template_decl
|
||||
&& !instantiation_dependent_expression_p (expr)
|
||||
&& potential_constant_expression (expr))
|
||||
&& potential_nondependent_constant_expression (expr))
|
||||
{
|
||||
processing_template_decl_sentinel s;
|
||||
expr = instantiate_non_dependent_expr_internal (expr, complain);
|
||||
|
|
@ -5680,8 +5679,7 @@ instantiate_non_dependent_or_null (tree expr)
|
|||
return NULL_TREE;
|
||||
if (processing_template_decl)
|
||||
{
|
||||
if (instantiation_dependent_expression_p (expr)
|
||||
|| !potential_constant_expression (expr))
|
||||
if (!potential_nondependent_constant_expression (expr))
|
||||
expr = NULL_TREE;
|
||||
else
|
||||
{
|
||||
|
|
@ -6240,10 +6238,8 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
|
|||
if (TYPE_REF_OBJ_P (type)
|
||||
&& has_value_dependent_address (expr))
|
||||
/* If we want the address and it's value-dependent, don't fold. */;
|
||||
else if (!type_unknown_p (expr)
|
||||
&& processing_template_decl
|
||||
&& !instantiation_dependent_expression_p (expr)
|
||||
&& potential_constant_expression (expr))
|
||||
else if (processing_template_decl
|
||||
&& potential_nondependent_constant_expression (expr))
|
||||
non_dep = true;
|
||||
if (error_operand_p (expr))
|
||||
return error_mark_node;
|
||||
|
|
|
|||
Loading…
Reference in New Issue