Commit b67db529 by Mark Mitchell Committed by Mark Mitchell

re PR c++/3471 (gcc 3.01 reports error about a private copy constructor that shouldn't get called.)

	PR c++/3471
	* call.c (convert_like_real): Do not build additional temporaries
	for rvalues of class type.

From-SVN: r47451
parent 00424999
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> 2001-11-28 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (UNIQUELY_DERIVED_FROM_P): Use lookup base. * cp-tree.h (UNIQUELY_DERIVED_FROM_P): Use lookup base.
......
...@@ -3820,7 +3820,7 @@ convert_like_real (convs, expr, fn, argnum, inner) ...@@ -3820,7 +3820,7 @@ convert_like_real (convs, expr, fn, argnum, inner)
If the target is a class, that means call a ctor. */ If the target is a class, that means call a ctor. */
if (IS_AGGR_TYPE (totype) if (IS_AGGR_TYPE (totype)
&& (inner >= 0 || !real_lvalue_p (expr))) && (inner >= 0 || !lvalue_p (expr)))
{ {
savew = warningcount, savee = errorcount; savew = warningcount, savee = errorcount;
expr = build_new_method_call expr = build_new_method_call
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
class A class A
{ {
public: public:
A(int j) { i = j; } // ERROR - candidate A(int j) { i = j; }
A(A& a) { i = a.i; } // ERROR - candidate A(A& a) { i = a.i; }
operator int() { return i; } operator int() { return i; }
void assign(int v) { i = v; } void assign(int v) { i = v; }
...@@ -37,10 +37,10 @@ B::run() ...@@ -37,10 +37,10 @@ B::run()
// Replacing above with "switch (int(in))" removes the error. // Replacing above with "switch (int(in))" removes the error.
{ {
case 0: case 0:
out = 1; // ERROR - no usable copy ctor out = 1;
break; break;
default: default:
out = 0; // ERROR - no usable copy ctor out = 0;
break; break;
} }
} }
......
...@@ -4,7 +4,7 @@ int count; ...@@ -4,7 +4,7 @@ int count;
class A { class A {
A(); A();
A(const A&); // ERROR - referenced below A(const A&);
public: public:
A(int) { ++count; } A(int) { ++count; }
~A() { --count; } ~A() { --count; }
...@@ -14,7 +14,7 @@ public: ...@@ -14,7 +14,7 @@ public:
int main() { int main() {
{ {
A a (1); A a (1);
if (a == 2 && a == 1) // ERROR - private copy ctor if (a == 2 && a == 1)
; ;
} }
return count; return count;
......
// 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment