From de36e8ce2265867c8ad28cc103a4c3d75f5753e4 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 9 Jul 2013 17:50:44 +0000 Subject: [PATCH] PR c++/57545 * pt.c (convert_nontype_argument) [INTEGER_CST]: Force the argument to have the exact type of the parameter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@200831 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 4 ++++ gcc/testsuite/g++.dg/debug/template2.C | 14 ++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/template2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f11ad34bc70..a9abf59eb70 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-07-09 Jason Merrill + PR c++/57545 + * pt.c (convert_nontype_argument) [INTEGER_CST]: Force the + argument to have the exact type of the parameter. + PR c++/57551 * semantics.c (cxx_eval_indirect_ref): Don't try to look through a POINTER_PLUS_EXPR for type punning diagnostic. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7b94e417351..4fbf9d5b985 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5521,6 +5521,10 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) else return NULL_TREE; } + + /* Avoid typedef problems. */ + if (TREE_TYPE (expr) != type) + expr = fold_convert (type, expr); } /* [temp.arg.nontype]/5, bullet 2 diff --git a/gcc/testsuite/g++.dg/debug/template2.C b/gcc/testsuite/g++.dg/debug/template2.C new file mode 100644 index 00000000000..9f5bcd9b101 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/template2.C @@ -0,0 +1,14 @@ +// PR c++/57545 + +template +struct array { + T data[N]; +}; + +template +struct derived { + typedef long unsigned int size_type; + static const size_type n = 42; + + array a; +}; -- 2.11.0