* decl.c (cp_finish_decl): Don't change init for auto deduction.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Sep 2010 04:49:24 +0000 (04:49 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Sep 2010 04:49:24 +0000 (04:49 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163896 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto19.C [new file with mode: 0644]

index 9fe9ef0..58bcab4 100644 (file)
@@ -1,5 +1,7 @@
 2010-09-06  Jason Merrill  <jason@redhat.com>
 
+       * decl.c (cp_finish_decl): Don't change init for auto deduction.
+
        * pt.c (fold_non_dependent_expr_sfinae): Split out from...
        (fold_non_dependent_expr): ...here.
        (convert_nontype_argument): Use it.  Take complain parm.
index 75fd9f7..409836c 100644 (file)
@@ -5681,18 +5681,21 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
   auto_node = type_uses_auto (type);
   if (auto_node)
     {
+      tree d_init;
       if (init == NULL_TREE)
        {
          error ("declaration of %q#D has no initializer", decl);
          TREE_TYPE (decl) = error_mark_node;
          return;
        }
-      if (TREE_CODE (init) == TREE_LIST)
-       init = build_x_compound_expr_from_list (init, ELK_INIT,
-                                               tf_warning_or_error);
-      if (describable_type (init))
+      d_init = init;
+      if (TREE_CODE (d_init) == TREE_LIST)
+       d_init = build_x_compound_expr_from_list (d_init, ELK_INIT,
+                                                 tf_warning_or_error);
+      if (describable_type (d_init))
        {
-         type = TREE_TYPE (decl) = do_auto_deduction (type, init, auto_node);
+         type = TREE_TYPE (decl) = do_auto_deduction (type, d_init,
+                                                      auto_node);
          if (type == error_mark_node)
            return;
        }
index 8cfc06e..2cfe379 100644 (file)
@@ -1,5 +1,7 @@
 2010-09-06  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/auto19.C: New.
+
        * g++.dg/template/sfinae25.C: New.
        * g++.dg/template/char1.C: Expect warning.
        * g++.dg/template/nontype10.C: Likewise.
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto19.C b/gcc/testsuite/g++.dg/cpp0x/auto19.C
new file mode 100644 (file)
index 0000000..f709902
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-options -std=c++0x }
+
+struct Explicit {
+  Explicit() = default;  // Line 2
+  explicit Explicit(const Explicit&){}
+} ex;
+
+auto ex2(ex); // Line 6