2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
|
2009-09-24 04:55:32 +08:00
|
|
|
|
2010-01-06 17:43:14 +08:00
|
|
|
struct A {}; // expected-note {{candidate is the implicit copy constructor}}
|
2009-09-24 04:55:32 +08:00
|
|
|
|
|
|
|
struct BASE {
|
|
|
|
operator A(); // expected-note {{candidate function}}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BASE1 {
|
|
|
|
operator A(); // expected-note {{candidate function}}
|
|
|
|
};
|
|
|
|
|
|
|
|
class B : public BASE , public BASE1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
B();
|
|
|
|
} b;
|
|
|
|
|
|
|
|
extern B f();
|
|
|
|
|
2009-12-17 00:54:16 +08:00
|
|
|
const int& ri = (void)0; // expected-error {{reference to type 'int const' could not bind to an rvalue of type 'void'}}
|
2009-10-01 05:23:30 +08:00
|
|
|
|
2009-09-24 04:55:32 +08:00
|
|
|
int main() {
|
Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:
- InitializationSequence now has a "C conversion sequence" category
and step kind, which falls back to
- Changed the diagnostics for returns to always have the result type
of the function first and the type of the expression second.
CheckSingleAssignmentConstraints to peform checking in C.
- Improved ASTs for initialization of return values. The ASTs now
capture all of the temporaries we need to create, but
intentionally do not bind the tempoary that is actually returned,
so that it won't get destroyed twice.
- Make sure to perform an (elidable!) copy of the class object that
is returned from a class.
- Fix copy elision in CodeGen to properly see through the
subexpressions that occur with elidable copies.
- Give "new" its own entity kind; as with return values and thrown
objects, we don't bind the expression so we don't call a
destructor for it.
Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.
llvm-svn: 91669
2009-12-18 13:02:21 +08:00
|
|
|
const A& rca = f(); // expected-error {{reference initialization of type 'struct A const &' with initializer of type 'class B' is ambiguous}}
|
2009-12-10 07:02:17 +08:00
|
|
|
A& ra = f(); // expected-error {{non-const lvalue reference to type 'struct A' cannot bind to a temporary of type 'class B'}}
|
2009-09-24 04:55:32 +08:00
|
|
|
}
|
2010-02-09 08:50:06 +08:00
|
|
|
|
2010-02-09 09:02:53 +08:00
|
|
|
struct PR6139 { A (&x)[1]; };
|
|
|
|
PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'struct A [1]' cannot bind to a temporary of type 'struct A'}}
|