decl2.c (mark_used): Don't instantiate anything if skip_evaluation.
authorJason Merrill <jason@redhat.com>
Tue, 15 Apr 2003 16:26:03 +0000 (12:26 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 15 Apr 2003 16:26:03 +0000 (12:26 -0400)
        * decl2.c (mark_used): Don't instantiate anything if
        skip_evaluation.

From-SVN: r65642

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.dg/template/sizeof3.C [new file with mode: 0644]

index 281f83a1cd0828d8ef873c6bcba4bf2c677442cc..3c1055b345ec787a7cf37bbf6f9c7df3927f447b 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-15  Jason Merrill  <jason@redhat.com>
+
+       * decl2.c (mark_used): Don't instantiate anything if
+       skip_evaluation.
+
 2003-04-14  Ziemowit Laski  <zlaski@apple.com>
 
        * tree.c (build_cplus_array_type_1): Do not call
index 57050d782af2f4b096c09e6e01df31e37234887b..80c756144558a70e7b5edb66f3646a86764af03c 100644 (file)
@@ -4536,16 +4536,15 @@ void
 mark_used (tree decl)
 {
   TREE_USED (decl) = 1;
-  if (processing_template_decl)
+  if (processing_template_decl || skip_evaluation)
     return;
 
   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)
       && !TREE_ASM_WRITTEN (decl))
     /* Remember it, so we can check it was defined.  */
     defer_fn (decl);
-  
-  if (!skip_evaluation)
-    assemble_external (decl);
+
+  assemble_external (decl);
 
   /* Is it a synthesized method that needs to be synthesized?  */
   if (TREE_CODE (decl) == FUNCTION_DECL
diff --git a/gcc/testsuite/g++.dg/template/sizeof3.C b/gcc/testsuite/g++.dg/template/sizeof3.C
new file mode 100644 (file)
index 0000000..a98bbc3
--- /dev/null
@@ -0,0 +1,13 @@
+// The call to f is not potentially evaluated (3.2), so f<int> is not used,
+// so it should not be instantiated.
+
+template <class T>
+T f (T)
+{
+  typename T::X x;
+}
+
+int main()
+{
+  int i = sizeof (f(0));
+}