diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2005-01-06 15:22:11 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2005-01-06 15:22:11 +0000 |
commit | d8987adb29b6d98c923d93fcc29ab4d8d47e8a1a (patch) | |
tree | 2d74b6ffa665ac63661c4f1445afe2b590ad5c6b /gcc | |
parent | 9acf766fe1b9fbdda3e7997f408912bfccfaf5fd (diff) | |
download | gcc-d8987adb29b6d98c923d93fcc29ab4d8d47e8a1a.zip gcc-d8987adb29b6d98c923d93fcc29ab4d8d47e8a1a.tar.gz gcc-d8987adb29b6d98c923d93fcc29ab4d8d47e8a1a.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/pt.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/array10.C | 20 |
4 files changed, 42 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4f3e210..fb98595 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f24865e..e6f4b51 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 63b3ac1..139d695 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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, diff --git a/gcc/testsuite/g++.dg/template/array10.C b/gcc/testsuite/g++.dg/template/array10.C new file mode 100644 index 0000000..81aac84 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array10.C @@ -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]; +} |