re PR c++/40013 (ICE when creating a local array with size from the return value of a member function of an object in a nested class in a template class)

PR c++/40013
	* pt.c (tsubst): If magic NOP_EXPR with side-effects has no type,
	set it from its operand's type after tsubst_expr.

	* g++.dg/ext/vla7.C: New test.

From-SVN: r147120
This commit is contained in:
Jakub Jelinek 2009-05-05 08:41:33 +02:00 committed by Jakub Jelinek
parent c2fa1710aa
commit af52aef013
4 changed files with 49 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-05-05 Jakub Jelinek <jakub@redhat.com>
PR c++/40013
* pt.c (tsubst): If magic NOP_EXPR with side-effects has no type,
set it from its operand's type after tsubst_expr.
2009-04-23 Dodji Seketeli <dodji@redhat.com>
PR c++/38228

View File

@ -9144,6 +9144,14 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
max = tsubst_expr (omax, args, complain, in_decl,
/*integral_constant_expression_p=*/false);
/* Fix up type of the magic NOP_EXPR with TREE_SIDE_EFFECTS if
needed. */
if (TREE_CODE (max) == NOP_EXPR
&& TREE_SIDE_EFFECTS (omax)
&& !TREE_TYPE (max))
TREE_TYPE (max) = TREE_TYPE (TREE_OPERAND (max, 0));
max = fold_decl_constant_value (max);
/* If we're in a partial instantiation, preserve the magic NOP_EXPR

View File

@ -1,3 +1,8 @@
2009-05-05 Jakub Jelinek <jakub@redhat.com>
PR c++/40013
* g++.dg/ext/vla7.C: New test.
2009-04-30 Janis Johnson <janis187@us.ibm.com>
PR testsuite/39776

View File

@ -0,0 +1,30 @@
// PR c++/40013
// { dg-options "" }
template <class T>
struct A
{
struct B
{
struct
{
int fn () { return 0; }
} b;
};
void test ();
};
template <class T>
void
A <T>::test ()
{
B a;
int vla[a.b.fn ()];
}
int
main ()
{
A <char> a;
a.test ();
}