aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/cp/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/cp/decl.c')
-rw-r--r--gcc-4.9/gcc/cp/decl.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc-4.9/gcc/cp/decl.c b/gcc-4.9/gcc/cp/decl.c
index 4dd0ec09f..df4813deb 100644
--- a/gcc-4.9/gcc/cp/decl.c
+++ b/gcc-4.9/gcc/cp/decl.c
@@ -14211,8 +14211,8 @@ grokmethod (cp_decl_specifier_seq *declspecs,
/* VAR is a VAR_DECL. If its type is incomplete, remember VAR so that
we can lay it out later, when and if its type becomes complete.
- Also handle constexpr pointer to member variables where the initializer
- is an unlowered PTRMEM_CST because the class isn't complete yet. */
+ Also handle constexpr variables where the initializer involves
+ an unlowered PTRMEM_CST because the class isn't complete yet. */
void
maybe_register_incomplete_var (tree var)
@@ -14237,12 +14237,13 @@ maybe_register_incomplete_var (tree var)
incomplete_var iv = {var, inner_type};
vec_safe_push (incomplete_vars, iv);
}
- else if (TYPE_PTRMEM_P (inner_type)
- && DECL_INITIAL (var)
- && TREE_CODE (DECL_INITIAL (var)) == PTRMEM_CST)
+ else if (!(DECL_LANG_SPECIFIC (var) && DECL_TEMPLATE_INFO (var))
+ && decl_constant_var_p (var)
+ && (TYPE_PTRMEM_P (inner_type) || CLASS_TYPE_P (inner_type)))
{
- tree context = TYPE_PTRMEM_CLASS_TYPE (inner_type);
- gcc_assert (TYPE_BEING_DEFINED (context));
+ /* When the outermost open class is complete we can resolve any
+ pointers-to-members. */
+ tree context = outermost_open_class ();
incomplete_var iv = {var, context};
vec_safe_push (incomplete_vars, iv);
}
@@ -14266,9 +14267,8 @@ complete_vars (tree type)
tree var = iv->decl;
tree type = TREE_TYPE (var);
- if (TYPE_PTRMEM_P (type))
- DECL_INITIAL (var) = cplus_expand_constant (DECL_INITIAL (var));
- else
+ if (TYPE_MAIN_VARIANT (strip_array_types (type))
+ == iv->incomplete_type)
{
/* Complete the type of the variable. The VAR_DECL itself
will be laid out in expand_expr. */
@@ -14276,6 +14276,10 @@ complete_vars (tree type)
cp_apply_type_quals_to_decl (cp_type_quals (type), var);
}
+ if (DECL_INITIAL (var)
+ && decl_constant_var_p (var))
+ DECL_INITIAL (var) = cplus_expand_constant (DECL_INITIAL (var));
+
/* Remove this entry from the list. */
incomplete_vars->unordered_remove (ix);
}