re PR c++/19270 (ice on valid template code)

cp:
	PR c++/19270
	* pt.c (tsubst_copy) <ARRAY_REF case>: Handle separately.
	(tsubst_copy_and_build) <ARRAY_REF case>: Remove obsolete
	array-new handling code.  Use build_x_binary_op.
testsuite:
	PR c++/19270
	* g++.dg/template/array10.C: New.

From-SVN: r92992
This commit is contained in:
Nathan Sidwell 2005-01-06 15:22:11 +00:00 committed by Nathan Sidwell
parent 9acf766fe1
commit d8987adb29
4 changed files with 42 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2005-01-06 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19270
* pt.c (tsubst_copy) <ARRAY_REF case>: Handle separately.
(tsubst_copy_and_build) <ARRAY_REF case>: Remove obsolete
array-new handling code. Use build_x_binary_op.
2005-01-05 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19030

View File

@ -7869,7 +7869,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case GE_EXPR:
case LT_EXPR:
case GT_EXPR:
case ARRAY_REF:
case COMPOUND_EXPR:
case SCOPE_REF:
case DOTSTAR_EXPR:
@ -7882,6 +7881,13 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
(code, tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl),
tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl));
case ARRAY_REF:
return build_nt
(ARRAY_REF,
tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl),
tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl),
NULL_TREE, NULL_TREE);
case CALL_EXPR:
return build_nt (code,
tsubst_copy (TREE_OPERAND (t, 0), args,
@ -8526,21 +8532,12 @@ tsubst_copy_and_build (tree t,
case SCOPE_REF:
return tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,
/*address_p=*/false);
case ARRAY_REF:
if (tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl)
== NULL_TREE)
/* new-type-id */
return build_nt (ARRAY_REF, NULL_TREE, RECUR (TREE_OPERAND (t, 1)),
NULL_TREE, NULL_TREE);
op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
args, complain, in_decl);
/* Remember that there was a reference to this entity. */
if (DECL_P (op1))
mark_used (op1);
return grok_array_decl (op1, RECUR (TREE_OPERAND (t, 1)));
return build_x_binary_op (ARRAY_REF, op1, RECUR (TREE_OPERAND (t, 1)),
/*overloaded_p=*/NULL);
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
op1 = TREE_OPERAND (t, 0);

View File

@ -1,3 +1,8 @@
2005-01-06 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19270
* g++.dg/template/array10.C: New.
2005-01-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* g++.old-deja/g++.pt/asm1.C, g++.old-deja/g++.pt/asm2.C,

View File

@ -0,0 +1,20 @@
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 Jan 2005 <nathan@codesourcery.com>
// PR 19270: ICE
// Origin: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
template<class T> struct Vec {
T* data;
T& operator[](int i) const;
};
template<class T> inline T& Vec<T>::operator[](int i) const
{
return (&data[0])[i];
}
inline double foo(Vec<double> v)
{
return v[0];
}