llvm_unreachable("Invalid EntityKind!");
}
-/// \brief Whether we should binding a created object as a temporary when
+/// \brief Whether we should bind a created object as a temporary when
/// initializing the given entity.
static bool shouldBindAsTemporary(const InitializedEntity &Entity) {
switch (Entity.getKind()) {
/// created for that initialization, requires destruction.
static bool shouldDestroyTemporary(const InitializedEntity &Entity) {
switch (Entity.getKind()) {
- case InitializedEntity::EK_Member:
case InitializedEntity::EK_Result:
case InitializedEntity::EK_New:
case InitializedEntity::EK_Base:
case InitializedEntity::EK_LambdaCapture:
return false;
+ case InitializedEntity::EK_Member:
case InitializedEntity::EK_Variable:
case InitializedEntity::EK_Parameter:
case InitializedEntity::EK_Temporary:
} catch(...) {
}
}
+
+namespace PR14838 {
+ struct base { ~base() {} };
+ class function : base {
+ ~function() {} // expected-note {{implicitly declared private here}}
+ public:
+ function(...) {}
+ };
+ struct thing {};
+ struct another {
+ another() : r(thing()) {}
+ // expected-error@-1 {{temporary of type 'const PR14838::function' has private destructor}}
+ // expected-warning@-2 {{binding reference member 'r' to a temporary value}}
+ const function &r; // expected-note {{reference member declared here}}
+ } af;
+}