c7558a2c0d
This makes all functions end up in the same text section, which is important for TCling on macOS to catch exceptions from constructors: Stack unwinding requires information about program addresses to find out which objects to destroy and what code should be called to handle the exception. These addresses are relocated against a single __text section when loading the produced MachO binary, which breaks if the call sites of global constructors end up in a separate init section. Fixes ROOT-10703 and ROOT-10962
34 lines
1003 B
C
34 lines
1003 B
C
//------------------------------------------------------------------------------
|
|
// CLING - the C++ LLVM-based InterpreterG :)
|
|
//
|
|
// This file is dual-licensed: you can choose to license it under the University
|
|
// of Illinois Open Source License or the GNU Lesser General Public License. See
|
|
// LICENSE.TXT for details.
|
|
//------------------------------------------------------------------------------
|
|
|
|
// RUN: cat %s | %cling 2>&1 | FileCheck %s
|
|
extern "C" int printf(const char*,...);
|
|
|
|
// When interpreting code, raised exceptions can be catched by the call site.
|
|
|
|
#include "cling/Interpreter/Interpreter.h"
|
|
|
|
try {
|
|
gCling->process("throw 1;");
|
|
} catch (...) {
|
|
// CHECK: Caught exception from throw statement
|
|
printf("Caught exception from throw statement\n");
|
|
}
|
|
|
|
struct ThrowInConstructor {
|
|
ThrowInConstructor() { throw 1; }
|
|
};
|
|
try {
|
|
gCling->process("ThrowInConstructor t;");
|
|
} catch (...) {
|
|
// CHECK: Caught exception from constructor
|
|
printf("Caught exception from constructor\n");
|
|
}
|
|
|
|
.q
|