re PR c++/50024 ([C++0x] [4.7 Regression] crash when using braced initialization in member function of template)

PR c++/50024
	* semantics.c (maybe_constant_value): Don't try to fold { }.
	* pt.c (build_non_dependent_expr): Don't wrap { }.
	* init.c (build_value_init): Allow scalar value-init in templates.

From-SVN: r177994
This commit is contained in:
Jason Merrill 2011-08-23 12:03:01 -04:00 committed by Jason Merrill
parent 7a74aa7f4a
commit 2787914706
6 changed files with 33 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2011-08-23 Jason Merrill <jason@redhat.com>
PR c++/50024
* semantics.c (maybe_constant_value): Don't try to fold { }.
* pt.c (build_non_dependent_expr): Don't wrap { }.
* init.c (build_value_init): Allow scalar value-init in templates.
2011-08-23 Jason Merrill <jason@redhat.com>
* semantics.c (potential_constant_expression_1): Allow 'this'.

View File

@ -330,7 +330,7 @@ build_value_init (tree type, tsubst_flags_t complain)
constructor. */
/* The AGGR_INIT_EXPR tweaking below breaks in templates. */
gcc_assert (!processing_template_decl);
gcc_assert (!processing_template_decl || SCALAR_TYPE_P (type));
if (CLASS_TYPE_P (type))
{

View File

@ -19669,6 +19669,10 @@ build_non_dependent_expr (tree expr)
if (TREE_CODE (expr) == THROW_EXPR)
return expr;
/* Don't wrap an initializer list, we need to be able to look inside. */
if (BRACE_ENCLOSED_INITIALIZER_P (expr))
return expr;
if (TREE_CODE (expr) == COND_EXPR)
return build3 (COND_EXPR,
TREE_TYPE (expr),

View File

@ -7542,6 +7542,7 @@ maybe_constant_value (tree t)
if (type_dependent_expression_p (t)
|| type_unknown_p (t)
|| BRACE_ENCLOSED_INITIALIZER_P (t)
|| !potential_constant_expression (t)
|| value_dependent_expression_p (t))
{

View File

@ -1,3 +1,8 @@
2011-08-23 Jason Merrill <jason@redhat.com>
PR c++/50024
* g++.dg/cpp0x/constexpr-initlist5.C: New.
2011-08-23 Jakub Jelinek <jakub@redhat.com>
PR c++/50158

View File

@ -0,0 +1,15 @@
// PR c++/50024
// { dg-options -std=c++0x }
template< class T >
struct Container
{
Container(){
int* ptr = new int{};
}
};
int main() {
Container< int > c;
}