2015-06-02 21:03:17 +08:00
|
|
|
//===------------------- uncaught_exceptions.pass.cpp ---------------------===//
|
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-06-02 21:03:17 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-04-17 22:29:15 +08:00
|
|
|
// UNSUPPORTED: no-exceptions
|
2016-05-31 20:01:32 +08:00
|
|
|
|
2015-06-02 21:03:17 +08:00
|
|
|
#include <cxxabi.h>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
// namespace __cxxabiv1 {
|
2019-04-19 01:18:15 +08:00
|
|
|
// extern unsigned int __cxa_uncaught_exceptions() throw();
|
2015-06-02 21:03:17 +08:00
|
|
|
// }
|
|
|
|
|
|
|
|
struct A {
|
2019-04-19 01:18:15 +08:00
|
|
|
A(unsigned cnt) : data_(cnt) {}
|
|
|
|
~A() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
|
2016-12-11 13:43:20 +08:00
|
|
|
unsigned data_;
|
2019-04-19 01:18:15 +08:00
|
|
|
};
|
2015-06-02 21:03:17 +08:00
|
|
|
|
2019-04-19 01:18:15 +08:00
|
|
|
int main () {
|
|
|
|
try { A a(1); throw 3; assert(false); }
|
2015-06-02 21:03:17 +08:00
|
|
|
catch (int) {}
|
|
|
|
}
|