blob: da216ae5cc7936e90d9c0244f910fd16a8b35989 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// { dg-do assemble }
class X // Indentation has been done so to see the similarities.
{
public:
X() {} // { dg-message "note" } referenced below
X(X& x) {x.i=7;} // { dg-message "note" } Both functions modify the
void bar(X& x) {x.i=7;} // { dg-message "note" } reference parameter x.
int i;
};
X foo() { X x; return x; }
int main()
{
X x(foo()); // { dg-error "no match" } Compiler doesn't warn about temporary reference.
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
x.bar(foo()); // { dg-error "no match" } The same mistake is warned about in this case.
// { dg-message "candidate" "candidate note" { target *-*-* } 17 }
}
|