aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/conversion-function.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-18 05:02:21 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-18 05:02:21 +0000
commit18ef5e28a9a2677f8b1dce1fb2638d66e0a1621f (patch)
tree099eb0daae418a43deff778586109048be09bd88 /test/SemaCXX/conversion-function.cpp
parentf2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26e (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91669 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/conversion-function.cpp')
-rw-r--r--test/SemaCXX/conversion-function.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 997e19c388..fca5a4a72a 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -99,7 +99,7 @@ class AutoPtrRef { };
class AutoPtr {
// FIXME: Using 'unavailable' since we do not have access control yet.
// FIXME: The error message isn't so good.
- AutoPtr(AutoPtr &) __attribute__((unavailable));
+ AutoPtr(AutoPtr &) __attribute__((unavailable)); // expected-note{{explicitly marked}}
public:
AutoPtr();
@@ -115,9 +115,19 @@ AutoPtr test_auto_ptr(bool Cond) {
AutoPtr p;
if (Cond)
- return p; // expected-error{{incompatible type returning}}
+ return p; // expected-error{{call to deleted constructor}}
return AutoPtr();
}
+struct A1 {
+ A1(const char *);
+ ~A1();
+private:
+ A1(const A1&) __attribute__((unavailable)); // expected-note{{here}}
+};
+
+A1 f() {
+ return "Hello"; // expected-error{{invokes deleted copy constructor}}
+}