summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp2
-rw-r--r--clang/test/SemaCXX/exceptions.cpp21
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c78f214fbca..4b635c0ed79 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11933,7 +11933,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S,
//
// 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);
diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp
index 5f4ff23eb77..6ac51b32e48 100644
--- a/clang/test/SemaCXX/exceptions.cpp
+++ b/clang/test/SemaCXX/exceptions.cpp
@@ -146,7 +146,7 @@ namespace Decay {
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}}
@@ -158,3 +158,22 @@ void f() {
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}}
+ }
+}
+}
OpenPOWER on IntegriCloud