OSDN Git Service

PR c++/13478
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Jan 2004 16:59:30 +0000 (16:59 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Jan 2004 16:59:30 +0000 (16:59 +0000)
* call.c (convert_like_real): Do not perform an additional
direct-initialization when binding to a reference.

PR c++/13478
* g++.dg/init/ref10.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75979 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/ref10.C [new file with mode: 0644]

index a902c25..3c41c9a 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13478
+       * call.c (convert_like_real): Do not perform an additional
+       direct-initialization when binding to a reference.
+
 2004-01-15  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/13407
index 26ca488..74878fd 100644 (file)
@@ -4068,8 +4068,7 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
           conversion, but is not considered during overload resolution.
 
           If the target is a class, that means call a ctor.  */
-       if (IS_AGGR_TYPE (totype)
-           && (inner >= 0 || !lvalue_p (expr)))
+       if (IS_AGGR_TYPE (totype) && inner >= 0)
          {
            expr = (build_temp 
                    (expr, totype, 
index 3136eda..a9f2858 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13478
+       * g++.dg/init/ref10.C: New test.
+
 2004-01-15  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/13407
diff --git a/gcc/testsuite/g++.dg/init/ref10.C b/gcc/testsuite/g++.dg/init/ref10.C
new file mode 100644 (file)
index 0000000..73fd6de
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/13478
+
+struct A {};
+struct B : protected A {
+    B() {};
+    B(const A& ) {};
+private:
+    B(const B& ) {};
+};
+
+void foo(const A* ap)
+{
+  const B& br = *ap;
+}