2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
|
2009-10-14 08:52:43 +08:00
|
|
|
|
|
|
|
enum E2 { };
|
|
|
|
|
|
|
|
struct A {
|
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
|
|
|
operator E2&(); // expected-note 3 {{candidate function}}
|
2009-10-14 08:52:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
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
|
|
|
operator E2&(); // expected-note 3 {{candidate function}}
|
2009-10-14 08:52:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct C : B, A {
|
|
|
|
};
|
|
|
|
|
|
|
|
void test(C c) {
|
2010-09-05 08:17:29 +08:00
|
|
|
const E2 &e2 = c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
|
2009-10-14 08:52:43 +08:00
|
|
|
}
|
|
|
|
|
2010-04-22 08:20:18 +08:00
|
|
|
void foo(const E2 &);// expected-note{{passing argument to parameter here}}
|
2009-10-14 08:52:43 +08:00
|
|
|
|
|
|
|
const E2 & re(C c) {
|
2010-09-05 08:17:29 +08:00
|
|
|
foo(c); // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
|
2009-10-14 08:52:43 +08:00
|
|
|
|
2010-09-05 08:17:29 +08:00
|
|
|
return c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
|
2009-10-14 08:52:43 +08:00
|
|
|
}
|
|
|
|
|
2020-01-10 07:31:56 +08:00
|
|
|
namespace CWG2352 {
|
|
|
|
void f(const int * const &) = delete;
|
|
|
|
void f(int *);
|
|
|
|
|
|
|
|
void g(int * &);
|
|
|
|
void g(const int *) = delete;
|
|
|
|
|
|
|
|
void h1(int *const * const &);
|
|
|
|
void h1(const int *const *) = delete;
|
|
|
|
void h2(const int *const * const &) = delete;
|
|
|
|
void h2(int *const *);
|
|
|
|
|
|
|
|
void test() {
|
|
|
|
int *x;
|
|
|
|
// Under CWG2352, this became ambiguous. We order by qualification
|
|
|
|
// conversion even when comparing a reference binding to a
|
|
|
|
// non-reference-binding.
|
|
|
|
f(x);
|
|
|
|
g(x);
|
|
|
|
h1(&x);
|
|
|
|
h2(&x);
|
|
|
|
}
|
|
|
|
}
|