45 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// ADDITIONAL_COMPILE_FLAGS: -fvisibility-inlines-hidden10 11// When there is a weak hidden symbol in user code and a strong definition12// in the library, we test that the linker relies on the library version,13// as the default weak resolution semantics don't favour weak local definitions14// for XCOFF. This creates a conflict on std::bad_function_call, which is used15// by the std::function template instantiated in main.16#include <functional>17#include "test_macros.h"18#include "assert.h"19 20void foo() {}21 22void test_call() {23 std::function<void()> r(foo);24 r();25}26 27void test_throw() {28#ifndef TEST_HAS_NO_EXCEPTIONS29 std::function<int()> f;30 try {31 f();32 assert(false);33 } catch (const std::bad_function_call&) {34 return;35 }36 assert(false);37#endif // TEST_HAS_NO_EXCEPTIONS38}39 40int main(int, char**) {41 test_call();42 test_throw();43 return 0;44}45