SpecifiedType, MD->getLocation());
}
-void Sema::CheckDelayedExplicitlyDefaultedMemberExceptionSpecs() {
- for (unsigned I = 0, N = DelayedDefaultedMemberExceptionSpecs.size();
- I != N; ++I)
- CheckExplicitlyDefaultedMemberExceptionSpec(
- DelayedDefaultedMemberExceptionSpecs[I].first,
- DelayedDefaultedMemberExceptionSpecs[I].second);
+void Sema::CheckDelayedMemberExceptionSpecs() {
+ // Perform any deferred checking of exception specifications for virtual
+ // destructors.
+ while (!DelayedDestructorExceptionSpecChecks.empty()) {
+ std::pair<const CXXDestructorDecl *, const CXXDestructorDecl *> Check =
+ DelayedDestructorExceptionSpecChecks.pop_back_val();
+ const CXXDestructorDecl *Dtor = Check.first;
+ assert(!Dtor->getParent()->isDependentType() &&
+ "Should not ever add destructors of templates into the list.");
+ CheckOverridingFunctionExceptionSpec(Dtor, Check.second);
+ }
+
+ // Check that any explicitly-defaulted methods have exception specifications
+ // compatible with their implicit exception specifications.
+ while (!DelayedDefaultedMemberExceptionSpecs.empty()) {
+ std::pair<CXXMethodDecl *, const FunctionProtoType *> Spec =
+ DelayedDefaultedMemberExceptionSpecs.pop_back_val();
+ CheckExplicitlyDefaultedMemberExceptionSpec(Spec.first, Spec.second);
+ }
- DelayedDefaultedMemberExceptionSpecs.clear();
+ assert(DelayedDestructorExceptionSpecChecks.empty());
}
namespace {
}
void Sema::ActOnFinishDelayedMemberInitializers(Decl *D) {
- // Check that any explicitly-defaulted methods have exception specifications
- // compatible with their implicit exception specifications.
- CheckDelayedExplicitlyDefaultedMemberExceptionSpecs();
+ // Perform any delayed checks on exception specifications.
+ CheckDelayedMemberExceptionSpecs();
// Once all the member initializers are processed, perform checks to see if
// any unintialized use is happeneing.
// If the context is an invalid C++ class, just suppress these checks.
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
if (Record->isInvalidDecl()) {
+ DelayedDefaultedMemberExceptionSpecs.clear();
DelayedDestructorExceptionSpecChecks.clear();
return;
}
}
-
- // Perform any deferred checking of exception specifications for virtual
- // destructors.
- for (unsigned i = 0, e = DelayedDestructorExceptionSpecChecks.size();
- i != e; ++i) {
- const CXXDestructorDecl *Dtor =
- DelayedDestructorExceptionSpecChecks[i].first;
- assert(!Dtor->getParent()->isDependentType() &&
- "Should not ever add destructors of templates into the list.");
- CheckOverridingFunctionExceptionSpec(Dtor,
- DelayedDestructorExceptionSpecChecks[i].second);
- }
- DelayedDestructorExceptionSpecChecks.clear();
}
void Sema::AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl,
--- /dev/null
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -DCXX_EXCEPTIONS -fsyntax-only -verify %s
+
+template <class _Tp> struct is_nothrow_move_constructible {
+ static const bool value = false;
+};
+
+template <class _Tp>
+class allocator;
+
+template <>
+class allocator<char> {};
+
+template <class _Allocator>
+class basic_string {
+ typedef _Allocator allocator_type;
+ basic_string(basic_string &&__str)
+ noexcept(is_nothrow_move_constructible<allocator_type>::value);
+};
+
+class Foo {
+ Foo(Foo &&) noexcept = default;
+#ifdef CXX_EXCEPTIONS
+// expected-error@-2 {{does not match the calculated}}
+#else
+// expected-no-diagnostics
+#endif
+ Foo &operator=(Foo &&) noexcept = default;
+ basic_string<allocator<char> > vectorFoo_;
+};