OSDN Git Service

PR c++/25811
[pf3gnuchains/gcc-fork.git] / gcc / cp / init.c
index 70e3d38..cb56d9c 100644 (file)
@@ -522,7 +522,8 @@ perform_member_init (tree member, tree init)
              && (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type)
                  || CLASSTYPE_REF_FIELDS_NEED_INIT (core_type)))
            diagnose_uninitialized_cst_or_ref_member (core_type,
-                                                     /*using_new=*/false);
+                                                     /*using_new=*/false,
+                                                     /*complain=*/true);
        }
       else if (TREE_CODE (init) == TREE_LIST)
        /* There was an explicit member initialization.  Do some work
@@ -1779,9 +1780,6 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin,
 {
   tree field;
 
-  if (type_has_user_provided_constructor (type))
-    return;
-
   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
     {
       tree field_type;
@@ -1794,8 +1792,8 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin,
       if (TREE_CODE (field_type) == REFERENCE_TYPE)
        {
          if (using_new)
-           error ("uninitialized reference member in %q#T "
-                  "using %<new%> without new-initializer", origin);
+           error ("uninitialized reference member in %q#T using %<new%>",
+                  origin);
          else
            error ("uninitialized reference member in %q#T", origin);
          inform (DECL_SOURCE_LOCATION (field),
@@ -1805,8 +1803,8 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin,
       if (CP_TYPE_CONST_P (field_type))
        {
          if (using_new)
-           error ("uninitialized const member in %q#T "
-                  "using %<new%> without new-initializer", origin);
+           error ("uninitialized const member in %q#T using %<new%>",
+                  origin);
          else
            error ("uninitialized const member in %q#T", origin);
          inform (DECL_SOURCE_LOCATION (field),
@@ -1911,13 +1909,13 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
 
   is_initialized = (TYPE_NEEDS_CONSTRUCTING (elt_type) || *init != NULL);
 
-  if (*init == NULL)
+  if (*init == NULL && !type_has_user_provided_constructor (elt_type))
     {
-      bool maybe_uninitialized_error = false;
+      bool uninitialized_error = false;
       /* A program that calls for default-initialization [...] of an
         entity of reference type is ill-formed. */
       if (CLASSTYPE_REF_FIELDS_NEED_INIT (elt_type))
-       maybe_uninitialized_error = true;
+       uninitialized_error = true;
 
       /* A new-expression that creates an object of type T initializes
         that object as follows:
@@ -1932,9 +1930,9 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
           const-qualified type, the program is ill-formed; */
 
       if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (elt_type))
-       maybe_uninitialized_error = true;
+       uninitialized_error = true;
 
-      if (maybe_uninitialized_error)
+      if (uninitialized_error)
        {
          if (complain & tf_error)
            diagnose_uninitialized_cst_or_ref_member (elt_type,
@@ -2465,6 +2463,7 @@ build_new (VEC(tree,gc) **placement, tree type, tree nelts,
           else
             return error_mark_node;
         }
+      nelts = mark_rvalue_use (nelts);
       nelts = cp_save_expr (cp_convert (sizetype, nelts));
     }
 
@@ -3120,6 +3119,8 @@ build_delete (tree type, tree addr, special_function_kind auto_delete,
 
   type = TYPE_MAIN_VARIANT (type);
 
+  addr = mark_rvalue_use (addr);
+
   if (TREE_CODE (type) == POINTER_TYPE)
     {
       bool complete_p = true;