2014-08-22 Jason Merrill <jason@redhat.com>
PR c++/62129
+ * class.c (outermost_open_class): Fix logic.
+ * decl.c (complete_vars): Fix logic.
+
+2014-08-22 Jason Merrill <jason@redhat.com>
+
+ PR c++/62129
* class.c (outermost_open_class): New.
* cp-tree.h: Declare it.
* decl.c (maybe_register_incomplete_var): Use it.
if (!current_class_type)
return NULL_TREE;
tree r = NULL_TREE;
- for (int i = current_class_depth; i > 0; --i)
+ if (TYPE_BEING_DEFINED (current_class_type))
+ r = current_class_type;
+ for (int i = current_class_depth - 1; i > 0; --i)
{
if (current_class_stack[i].hidden)
break;
tree var = iv->decl;
tree type = TREE_TYPE (var);
- if (decl_constant_var_p (var))
- 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. */
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);
}