]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/54325 (C++11 uniform initialization syntax for argument-less abstract base...
authorJason Merrill <jason@redhat.com>
Wed, 2 Jan 2013 20:54:42 +0000 (15:54 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 2 Jan 2013 20:54:42 +0000 (15:54 -0500)
PR c++/54325
* call.c (build_new_method_call_1): Don't use build_value_init for
user-provided default constructors.

From-SVN: r194820

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/initlist-protected.C [new file with mode: 0644]

index fe0bfe2da08581691c3c7016d3b6ecf99d4896f3..f2148f726676cced0e97a633f3110c9b61e8b913 100644 (file)
@@ -1,5 +1,9 @@
 2013-01-02  Jason Merrill  <jason@redhat.com>
 
+       PR c++/54325
+       * call.c (build_new_method_call_1): Don't use build_value_init for
+       user-provided default constructors.
+
        * decl.c (check_default_argument): Use LOOKUP_IMPLICIT.
 
        PR c++/55032
index bba5d9fdba542f2d23f670b76e38d79ac8814d59..ad39637c8b7a4b1b1b377b95a00831c43e6d58aa 100644 (file)
@@ -7534,6 +7534,9 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
         build_special_member_call.  */
       if (CONSTRUCTOR_NELTS (init_list) == 0
          && TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype)
+         /* For a user-provided default constructor, use the normal
+            mechanisms so that protected access works.  */
+         && !type_has_user_provided_default_constructor (basetype)
          && !processing_template_decl)
        init = build_value_init (basetype, complain);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-protected.C b/gcc/testsuite/g++.dg/cpp0x/initlist-protected.C
new file mode 100644 (file)
index 0000000..fb5cc6a
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/54325
+// { dg-options -std=c++11 }
+
+class base
+{
+    protected:
+        base()
+        {}
+};
+
+class derived : public base
+{
+    public:
+        derived()
+            : base{} // <-- Note the c++11 curly brace syntax
+        {}
+};
+
+int main()
+{
+    derived d1;
+    return 0;
+}
This page took 0.085714 seconds and 5 git commands to generate.