+2005-09-08 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/23691
+ * decl2.c (mark_used): Instantiate static data members initialized
+ by constants, even in a template.
+
2005-09-08 Andrew Pinski <pinskia@physics.uc.edu>
PR obj-c++/16816
}
}
+/* Mark DECL as "used" in the program. If DECL is a specialization or
+ implicitly declared class member, generate the actual definition. */
+
void
mark_used (tree decl)
{
+ HOST_WIDE_INT saved_processing_template_decl = 0;
+
TREE_USED (decl) = 1;
- if (processing_template_decl || skip_evaluation)
+ /* If we don't need a value, then we don't need to synthesize DECL. */
+ if (skip_evaluation)
return;
+ /* Normally, we can wait until instantiation-time to synthesize
+ DECL. However, if DECL is a static data member initialized with
+ a constant, we need the value right now because a reference to
+ such a data member is not value-dependent. */
+ if (processing_template_decl)
+ {
+ if (TREE_CODE (decl) == VAR_DECL
+ && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)
+ && DECL_CLASS_SCOPE_P (decl)
+ && !dependent_type_p (DECL_CONTEXT (decl)))
+ {
+ /* Pretend that we are not in a template so that the
+ initializer for the static data member will be full
+ simplified. */
+ saved_processing_template_decl = processing_template_decl;
+ processing_template_decl = 0;
+ }
+ else
+ return;
+ }
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)
&& !TREE_ASM_WRITTEN (decl))
need. */
instantiate_decl (decl, /*defer_ok=*/true,
/*expl_inst_class_mem_p=*/false);
+
+ processing_template_decl = saved_processing_template_decl;
}
#include "gt-cp-decl2.h"