From 8b6a662e3ee24778eb7bf9556cd807e10f996cee Mon Sep 17 00:00:00 2001 From: "Jeffrey D. Oldham" Date: Mon, 24 Feb 2003 20:39:38 +0000 Subject: [PATCH] re PR c++/9778 (ICE with sizeof(expr) in non-type template arg) 2003-02-24 Jeffrey D. Oldham PR c++/9778 * cp/pt.c (tsubst_copy_and_build): For a templated function inside a scope, process template arguments. * testsuite/g++.dg/parse/template6.C: New test case. From-SVN: r63379 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/parse/template6.C | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/parse/template6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cfdaac850d8..dff7c4f667d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-02-24 Jeffrey D. Oldham + + PR c++/9778 + * pt.c (tsubst_copy_and_build): For a templated function inside a + scope, process template arguments. + 2003-02-24 Kriang Lerdsuwanakij PR c++/9602 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 36ae04d14d9..053a9670779 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8137,7 +8137,7 @@ tsubst_copy_and_build (t, args, complain, in_decl) if (TREE_CODE (name) == TEMPLATE_ID_EXPR) name = build_nt (TEMPLATE_ID_EXPR, TREE_OPERAND (name, 0), - TREE_OPERAND (name, 1)); + build_expr_from_tree (TREE_OPERAND (name, 1))); function = resolve_scoped_fn_name (TREE_OPERAND (function, 0), name); diff --git a/gcc/testsuite/g++.dg/parse/template6.C b/gcc/testsuite/g++.dg/parse/template6.C new file mode 100644 index 00000000000..a83c313d026 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template6.C @@ -0,0 +1,20 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Wolfgang Bangerth 20 Feb 2003. + +// PR c++/9778. Ensure templated functions in other namespaces are +// correctly instantiated. + +namespace NS { + template void foo (); +} + +template struct X { + int m; + void g () { + NS::foo(); + } +}; + +template class X<2>;