+2011-05-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/47956
+ * decl.c (check_static_variable_definition): Now static.
+ (cp_finish_decl): Call it here.
+ (grokdeclarator): Not here.
+ * pt.c (instantiate_class_template_1): Or here.
+ * cp-tree.h: Don't declare it.
+
2011-05-26 Janis Johnson <janis187@us.ibm.com>
Nathan Froyd <froydnj@codesourcery.com>
extern tree static_fn_type (tree);
extern void revert_static_member_fn (tree);
extern void fixup_anonymous_aggr (tree);
-extern int check_static_variable_definition (tree, tree);
extern tree compute_array_index_type (tree, tree, tsubst_flags_t);
extern tree check_default_argument (tree, tree);
typedef int (*walk_namespaces_fn) (tree, void *);
static tree grok_reference_init (tree, tree, tree, tree *);
static tree grokvardecl (tree, tree, const cp_decl_specifier_seq *,
int, int, tree);
+static int check_static_variable_definition (tree, tree);
static void record_unknown_type (tree, const char *);
static tree builtin_function_1 (tree, tree, bool);
static tree build_library_fn_1 (tree, enum tree_code, tree);
if (current_class_type
&& CP_DECL_CONTEXT (decl) == current_class_type
&& TYPE_BEING_DEFINED (current_class_type)
+ && !CLASSTYPE_TEMPLATE_INSTANTIATION (current_class_type)
&& (DECL_INITIAL (decl) || init))
DECL_INITIALIZED_IN_CLASS_P (decl) = 1;
if (!ensure_literal_type_for_constexpr_object (decl))
DECL_DECLARED_CONSTEXPR_P (decl) = 0;
+ if (TREE_CODE (decl) == VAR_DECL
+ && DECL_CLASS_SCOPE_P (decl)
+ && DECL_INITIALIZED_IN_CLASS_P (decl))
+ check_static_variable_definition (decl, type);
+
if (init && TREE_CODE (decl) == FUNCTION_DECL)
{
tree clone;
messages. Return 1 if the definition is particularly bad, or 0
otherwise. */
-int
+static int
check_static_variable_definition (tree decl, tree type)
{
+ /* Can't check yet if we don't know the type. */
+ if (dependent_type_p (type))
+ return 0;
/* If DECL is declared constexpr, we'll do the appropriate checks
in check_initializer. */
if (DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
staticp = 1;
}
}
-
- if (uses_template_parms (type))
- /* We'll check at instantiation time. */
- ;
- else if (constexpr_p)
- /* constexpr has the same requirements. */
- ;
- else if (check_static_variable_definition (unqualified_id,
- type))
- /* If we just return the declaration, crashes
- will sometimes occur. We therefore return
- void_type_node, as if this was a friend
- declaration, to cause callers to completely
- ignore this declaration. */
- return error_mark_node;
}
if (staticp)