The exception object should be unqualified. Using a qualified exception
object results in the wrong copy constructor getting called when the
catch handler executes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231054
91177308-0d34-0410-b5e6-
96231b3b80d8
//
// We just pretend to initialize the object with itself, then make sure
// it can be destroyed later.
- QualType initType = ExDeclType;
+ QualType initType = Context.getExceptionObjectType(ExDeclType);
InitializedEntity entity =
InitializedEntity::InitializeVariable(ExDecl);
void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}}
-namespace ConstVolatile {
+namespace ConstVolatileThrow {
struct S {
S() {} // expected-note{{candidate constructor not viable}}
S(const S &s); // expected-note{{candidate constructor not viable}}
throw CVS(); // expected-error{{no matching constructor for initialization}}
}
}
+
+namespace ConstVolatileCatch {
+struct S {
+ S() {}
+ S(const volatile S &s);
+
+private:
+ S(const S &s); // expected-note {{declared private here}}
+};
+
+void f();
+
+void g() {
+ try {
+ f();
+ } catch (volatile S s) { // expected-error {{calling a private constructor}}
+ }
+}
+}