re PR c++/9778 (ICE with sizeof(expr) in non-type template arg)
authorJeffrey D. Oldham <oldham@codesourcery.com>
Mon, 24 Feb 2003 20:39:38 +0000 (20:39 +0000)
committerJeffrey D. Oldham <oldham@gcc.gnu.org>
Mon, 24 Feb 2003 20:39:38 +0000 (20:39 +0000)
2003-02-24  Jeffrey D. Oldham  <oldham@codesourcery.com>

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
gcc/cp/pt.c
gcc/testsuite/g++.dg/parse/template6.C [new file with mode: 0644]

index cfdaac850d83756ecef0d356a55b92b8d722b7e5..dff7c4f667dfbd182e58362c10cab7fb1ee66239 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-24  Jeffrey D. Oldham  <oldham@codesourcery.com>
+
+       PR c++/9778
+       * pt.c (tsubst_copy_and_build): For a templated function inside a
+       scope, process template arguments.
+
 2003-02-24  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/9602
index 36ae04d14d9e95ad0673d9102466c65359b691f0..053a9670779894c1bc7a2225890dc6710ca02bc0 100644 (file)
@@ -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 (file)
index 0000000..a83c313
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Wolfgang Bangerth <bangerth@ticam.utexas.edu> 20 Feb 2003.
+
+// PR c++/9778.  Ensure templated functions in other namespaces are
+// correctly instantiated.
+
+namespace NS {
+  template <int N> void foo ();
+}
+
+template <int N> struct X {
+  int m;
+  void g () {
+    NS::foo<sizeof(m)>();
+  }
+};
+
+template class X<2>;