brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 92ec3e9 Raw
44 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// This test relies on `typeid` and thus requires `-frtti`.10// UNSUPPORTED: no-rtti11 12// Make sure that we don't get ODR violations with __exception_guard when13// linking together TUs compiled with different values of -f[no-]exceptions.14 15// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.except.o   -O1 -fexceptions16// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.noexcept.o -O1 -fno-exceptions17// RUN: %{cxx} %{flags} %{link_flags} -o %t.exe %t.except.o %t.noexcept.o18// RUN: %{run}19 20#include <__cxx03/__utility/exception_guard.h>21#include <cassert>22#include <cstring>23#include <typeinfo>24 25struct Rollback {26  void operator()() {}27};28 29#if defined(__cpp_exceptions) && __cpp_exceptions >= 199711L30 31const char* func();32 33int main(int, char**) {34  assert(std::strcmp(typeid(std::__exception_guard<Rollback>).name(), func()) != 0);35 36  return 0;37}38 39#else40 41const char* func() { return typeid(std::__exception_guard<Rollback>).name(); }42 43#endif44