From ac5f3b67630b6d6d70016765d9ad4f1a66815f51 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 15 Apr 2003 12:26:03 -0400 Subject: [PATCH] decl2.c (mark_used): Don't instantiate anything if skip_evaluation. * decl2.c (mark_used): Don't instantiate anything if skip_evaluation. From-SVN: r65642 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl2.c | 7 +++---- gcc/testsuite/g++.dg/template/sizeof3.C | 13 +++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/sizeof3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 281f83a1cd0..3c1055b345e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2003-04-15 Jason Merrill + + * decl2.c (mark_used): Don't instantiate anything if + skip_evaluation. + 2003-04-14 Ziemowit Laski * tree.c (build_cplus_array_type_1): Do not call diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 57050d782af..80c75614455 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 index 00000000000..a98bbc30adc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof3.C @@ -0,0 +1,13 @@ +// The call to f is not potentially evaluated (3.2), so f is not used, +// so it should not be instantiated. + +template +T f (T) +{ + typename T::X x; +} + +int main() +{ + int i = sizeof (f(0)); +}