re PR c++/62129 (internal compiler error: in output_constant, at varasm.c:4755)
authorJason Merrill <jason@redhat.com>
Fri, 22 Aug 2014 18:49:18 +0000 (14:49 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 22 Aug 2014 18:49:18 +0000 (14:49 -0400)
PR c++/62129
* class.c (outermost_open_class): Fix logic.
* decl.c (complete_vars): Fix logic.

From-SVN: r214353

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c

index 8102054c622f40a0477d44b4d05cc82db22e6143..649941c7b54aef14d5d71b41bd641eae74b57a89 100644 (file)
@@ -1,3 +1,9 @@
+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
index fd22930ffe131778a72083db87e8a1301d707d02..5c9a9a72dcd862d9620450620fde2c309d2ce740 100644 (file)
@@ -7141,7 +7141,9 @@ outermost_open_class (void)
   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;
index 2e4e7f87d6f6089c957c5cca6914a59d9e56d0b6..35ede7a0d8109a0c48f30d9ffdcffd6c91dc0539 100644 (file)
@@ -14367,9 +14367,8 @@ complete_vars (tree type)
          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.  */
@@ -14377,6 +14376,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);
        }