Skip to content

Commit

Permalink
PR c++/42466
Browse files Browse the repository at this point in the history
	* pt.c (reduce_template_parm_level): Check the type before
	returning cached TEMPLATE_PARM_INDEX.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155411 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jason committed Dec 22, 2009
1 parent 5818492 commit 8a4ad7e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2009-12-22 Jason Merrill <jason@redhat.com>

PR c++/42466
* pt.c (reduce_template_parm_level): Check the type before
returning cached TEMPLATE_PARM_INDEX.

PR c++/42331
* typeck.c (cp_build_modify_expr): Fix thinko.

Expand Down
3 changes: 2 additions & 1 deletion gcc/cp/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3356,7 +3356,8 @@ reduce_template_parm_level (tree index, tree type, int levels, tree args,
{
if (TEMPLATE_PARM_DESCENDANTS (index) == NULL_TREE
|| (TEMPLATE_PARM_LEVEL (TEMPLATE_PARM_DESCENDANTS (index))
!= TEMPLATE_PARM_LEVEL (index) - levels))
!= TEMPLATE_PARM_LEVEL (index) - levels)
|| !same_type_p (type, TREE_TYPE (TEMPLATE_PARM_DESCENDANTS (index))))
{
tree orig_decl = TEMPLATE_PARM_DECL (index);
tree decl, t;
Expand Down
3 changes: 3 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2009-12-22 Jason Merrill <jason@redhat.com>

PR c++/42466
* g++.dg/template/nontype19.C: New.

PR c++/42331
* g++.dg/cpp0x/initlist29.C: New.

Expand Down
19 changes: 19 additions & 0 deletions gcc/testsuite/g++.dg/template/nontype19.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// PR c++/42466

template<class IntT, IntT X>
struct A
{
A();

template<IntT X2>
A(const A<IntT, X2>& other);
};

int main(int argc, char** argv)
{
A<int, 42> a;
A<int, 100> b = a;

A<unsigned, 42u> c;
A<unsigned, 100u> d = c;
}

0 comments on commit 8a4ad7e

Please sign in to comment.