diff --git a/compiler-rt/test/ubsan/TestCases/Misc/inline.c b/compiler-rt/test/ubsan/TestCases/Misc/inline.c new file mode 100644 --- /dev/null +++ b/compiler-rt/test/ubsan/TestCases/Misc/inline.c @@ -0,0 +1,19 @@ +// RUN: %clang -fsanitize=undefined -O3 %s -o %t0 +// RUN: %run %t0 2> %t1 +// RUN: FileCheck --allow-empty %s < %t1 + +// Test that no_sanitize("undefined") attribute applies even when the +// function is inlined. + +// CHECK-NOT: runtime error: signed integer overflow + +__attribute__((always_inline, no_sanitize("undefined"))) +int f(int p) { + return p+1; +} + +int main() { + volatile int x = 0x7FFFFFFF; + volatile int res = f(x); + return 0; +}