OSDN Git Service

PR c++/3471
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Nov 2001 20:19:41 +0000 (20:19 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Nov 2001 20:19:41 +0000 (20:19 +0000)
* call.c (convert_like_real): Do not build additional temporaries
for rvalues of class type.

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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.old-deja/g++.law/cvt7.C
gcc/testsuite/g++.old-deja/g++.mike/p5469.C
gcc/testsuite/g++.old-deja/g++.other/copy3.C [new file with mode: 0644]

index 029b0e8..8885245 100644 (file)
@@ -1,3 +1,9 @@
+2001-11-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/3471
+       * call.c (convert_like_real): Do not build additional temporaries
+       for rvalues of class type.
+
 2001-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * cp-tree.h (UNIQUELY_DERIVED_FROM_P): Use lookup base.
index fc1395c..e4256b6 100644 (file)
@@ -3820,7 +3820,7 @@ convert_like_real (convs, expr, fn, argnum, inner)
 
           If the target is a class, that means call a ctor.  */
        if (IS_AGGR_TYPE (totype)
-           && (inner >= 0 || !real_lvalue_p (expr)))
+           && (inner >= 0 || !lvalue_p (expr)))
          {
            savew = warningcount, savee = errorcount;
            expr = build_new_method_call
index 7529bc2..0ea1d55 100644 (file)
@@ -10,8 +10,8 @@
 class A
 {
 public:
-    A(int j) { i = j; }                // ERROR - candidate
-    A(A& a) { i = a.i; }       // ERROR - candidate
+    A(int j) { i = j; }
+    A(A& a) { i = a.i; }
     operator int() { return i; }
 
     void assign(int v) { i = v; }
@@ -37,10 +37,10 @@ B::run()
     // Replacing above with "switch (int(in))" removes the error.
     {
     case 0:
-        out = 1;               // ERROR - no usable copy ctor
+        out = 1;
         break;
     default:
-        out = 0;               // ERROR - no usable copy ctor
+        out = 0;
         break;
     }
 }
index 9e5250e..9af2010 100644 (file)
@@ -4,7 +4,7 @@ int count;
 
 class A {
   A();
-  A(const A&);                 // ERROR - referenced below
+  A(const A&);
 public:
   A(int) { ++count; }
   ~A() { --count; }
@@ -14,7 +14,7 @@ public:
 int main() {
   {
     A a (1);
-    if (a == 2 && a == 1)      // ERROR - private copy ctor
+    if (a == 2 && a == 1)
       ;
   }
   return count;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/copy3.C b/gcc/testsuite/g++.old-deja/g++.other/copy3.C
new file mode 100644 (file)
index 0000000..aa2c905
--- /dev/null
@@ -0,0 +1,23 @@
+// Build don't run:
+// Origin: ericp@mit.edu
+
+class bar {
+};
+
+class foo {  
+  foo (const foo &f);
+
+public:
+  
+  foo (bar x) {}
+  foo () {}
+  
+  void test (const foo &f) {}
+};
+
+int main (void) {
+  foo f;
+  bar b;
+
+  f.test (b);
+}