1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // This test relies on `typeid` and thus requires `-frtti`. 10 // UNSUPPORTED: no-rtti 11 12 // XFAIL: FROZEN-CXX03-HEADERS-FIXME 13 14 // Make sure that we don't get ODR violations with __exception_guard when 15 // linking together TUs compiled with different values of -f[no-]exceptions. 16 17 // RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.except.o -O1 -fexceptions 18 // RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.noexcept.o -O1 -fno-exceptions 19 // RUN: %{cxx} %{flags} %{link_flags} -o %t.exe %t.except.o %t.noexcept.o 20 // RUN: %{run} 21 22 #include <__utility/exception_guard.h> 23 #include <cassert> 24 #include <cstring> 25 #include <typeinfo> 26 27 struct Rollback { 28 void operator()() {} 29 }; 30 31 #if defined(__cpp_exceptions) && __cpp_exceptions >= 199711L 32 33 const char* func(); 34 35 int main(int, char**) { 36 assert(std::strcmp(typeid(std::__exception_guard<Rollback>).name(), func()) != 0); 37 38 return 0; 39 } 40 41 #else 42 43 const char* func() { return typeid(std::__exception_guard<Rollback>).name(); } 44 45 #endif 46