summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/exceptions.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2015-02-15 22:00:28 +0000
committerAaron Ballman <aaron@aaronballman.com>2015-02-15 22:00:28 +0000
commit673476684ee1eb0c58cf51a69ea2eb823132f631 (patch)
tree303adbcf43bef5a2f441c453025f1d23e29cfe64 /clang/test/SemaCXX/exceptions.cpp
parentb46962fe5d9bb4eb8d8de10bb73ca6a11da2926b (diff)
downloadbcm5719-llvm-673476684ee1eb0c58cf51a69ea2eb823132f631.tar.gz
bcm5719-llvm-673476684ee1eb0c58cf51a69ea2eb823132f631.zip
Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; Clang edition.
llvm-svn: 229336
Diffstat (limited to 'clang/test/SemaCXX/exceptions.cpp')
-rw-r--r--clang/test/SemaCXX/exceptions.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp
index 9646a9c3b31..fcf540f3b38 100644
--- a/clang/test/SemaCXX/exceptions.cpp
+++ b/clang/test/SemaCXX/exceptions.cpp
@@ -145,3 +145,81 @@ namespace Decay {
}
void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}}
+
+namespace HandlerInversion {
+// RUN: %clang_cc1 -fcxx-exceptions -analyze -analyzer-checker=cplusplus -verify %s
+
+struct B {};
+struct D : B {};
+struct D2 : D {};
+
+void f1() {
+ try {
+ } catch (B &b) { // expected-note {{for type 'HandlerInversion::B &'}}
+ } catch (D &d) { // expected-warning {{exception of type 'HandlerInversion::D &' will be caught by earlier handler}}
+ }
+}
+
+void f2() {
+ try {
+ } catch (B *b) { // expected-note {{for type 'HandlerInversion::B *'}}
+ } catch (D *d) { // expected-warning {{exception of type 'HandlerInversion::D *' will be caught by earlier handler}}
+ }
+}
+
+void f3() {
+ try {
+ } catch (D &d) { // Ok
+ } catch (B &b) {
+ }
+}
+
+void f4() {
+ try {
+ } catch (B &b) { // Ok
+ }
+}
+
+void f5() {
+ try {
+ } catch (int) {
+ } catch (float) {
+ }
+}
+
+void f6() {
+ try {
+ } catch (B &b) { // expected-note {{for type 'HandlerInversion::B &'}}
+ } catch (D2 &d) { // expected-warning {{exception of type 'HandlerInversion::D2 &' will be caught by earlier handler}}
+ }
+}
+
+void f7() {
+ try {
+ } catch (B *b) { // Ok
+ } catch (D &d) { // Ok
+ }
+
+ try {
+ } catch (B b) { // Ok
+ } catch (D *d) { // Ok
+ }
+}
+
+void f8() {
+ try {
+ } catch (const B &b) { // expected-note {{for type 'const HandlerInversion::B &'}}
+ } catch (D2 &d) { // expected-warning {{exception of type 'HandlerInversion::D2 &' will be caught by earlier handler}}
+ }
+
+ try {
+ } catch (B &b) { // expected-note {{for type 'HandlerInversion::B &'}}
+ } catch (const D2 &d) { // expected-warning {{exception of type 'const HandlerInversion::D2 &' will be caught by earlier handler}}
+ }
+
+ try {
+ } catch (B b) { // expected-note {{for type 'HandlerInversion::B'}}
+ } catch (D &d) { // expected-warning {{exception of type 'HandlerInversion::D &' will be caught by earlier handler}}
+ }
+}
+}
OpenPOWER on IntegriCloud