Commit 55e83c66 by Paolo Carlini Committed by Paolo Carlini

re PR c++/51225 ([c++0x] [4.7 Regression] ICE with invalid template parameter)

/cp
2012-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51225
	* typeck2.c (store_init_value): Within a template guard
	cxx_constant_value with require_potential_constant_expression.
	* pt.c (convert_nontype_argument): Likewise.

/testsuite
2012-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51225
	* g++.dg/cpp0x/pr51225.C: New.

From-SVN: r183286
parent 66b432fd
2012-01-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51225
* typeck2.c (store_init_value): Within a template guard
cxx_constant_value with require_potential_constant_expression.
* pt.c (convert_nontype_argument): Likewise.
2012-01-16 Jakub Jelinek <jakub@redhat.com>
PR c++/51854
......
......@@ -5807,6 +5807,9 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
if (complain & tf_error)
{
int errs = errorcount, warns = warningcount;
if (processing_template_decl
&& !require_potential_constant_expression (expr))
return NULL_TREE;
expr = cxx_constant_value (expr);
if (errorcount > errs || warningcount > warns)
inform (EXPR_LOC_OR_HERE (expr),
......
......@@ -718,8 +718,14 @@ store_init_value (tree decl, tree init, VEC(tree,gc)** cleanups, int flags)
value = fold_non_dependent_expr (value);
value = maybe_constant_init (value);
if (DECL_DECLARED_CONSTEXPR_P (decl))
/* Diagnose a non-constant initializer for constexpr. */
value = cxx_constant_value (value);
{
/* Diagnose a non-constant initializer for constexpr. */
if (processing_template_decl
&& !require_potential_constant_expression (value))
value = error_mark_node;
else
value = cxx_constant_value (value);
}
const_init = (reduced_constant_expression_p (value)
|| error_operand_p (value));
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init;
......
2012-01-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51225
* g++.dg/cpp0x/pr51225.C: New.
2012-01-17 Ian Lance Taylor <iant@google.com>
PR go/50656
......
// PR c++/51225
// { dg-options "-std=c++0x" }
template<int> struct A {};
template<typename> void foo()
{
A<int(x)> a; // { dg-error "not declared|invalid type" }
}
template<typename> struct bar
{
static constexpr A<1> b = A<1>(x); // { dg-error "not declared" }
};
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