2016-12-27 08:31:34 +08:00
|
|
|
// REQUIRES: x86-registered-target
|
|
|
|
//
|
2009-11-08 09:45:36 +08:00
|
|
|
// RUN: echo "GNU89 tests:"
|
2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu89 | FileCheck %s --check-prefix=CHECK1
|
2016-12-27 08:13:09 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu89 | FileCheck %s --check-prefix=CHECK1
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK1-LABEL: define i32 @foo()
|
|
|
|
// CHECK1-LABEL: define i32 @bar()
|
|
|
|
// CHECK1-LABEL: define void @unreferenced1()
|
2013-01-06 02:22:42 +08:00
|
|
|
// CHECK1-NOT: unreferenced2
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK1-LABEL: define void @gnu_inline()
|
|
|
|
// CHECK1-LABEL: define i32 @test1
|
|
|
|
// CHECK1-LABEL: define i32 @test2
|
|
|
|
// CHECK1-LABEL: define void @test3()
|
|
|
|
// CHECK1-LABEL: define available_externally i32 @test4
|
|
|
|
// CHECK1-LABEL: define available_externally i32 @test5
|
|
|
|
// CHECK1-LABEL: define i32 @test6
|
|
|
|
// CHECK1-LABEL: define void @test7
|
2013-01-06 02:22:42 +08:00
|
|
|
// CHECK1: define i{{..}} @strlcpy
|
|
|
|
// CHECK1-NOT: test9
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK1-LABEL: define void @testA
|
|
|
|
// CHECK1-LABEL: define void @testB
|
|
|
|
// CHECK1-LABEL: define void @testC
|
|
|
|
// CHECK1-LABEL: define available_externally i32 @ei()
|
2015-01-22 08:24:57 +08:00
|
|
|
// CHECK1-LABEL: define available_externally void @gnu_ei_inline()
|
2012-02-07 11:50:18 +08:00
|
|
|
|
|
|
|
// RUN: echo "C99 tests:"
|
2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu99 | FileCheck %s --check-prefix=CHECK2
|
2016-12-27 08:13:09 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu99 | FileCheck %s --check-prefix=CHECK2
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK2-LABEL: define i32 @ei()
|
|
|
|
// CHECK2-LABEL: define i32 @bar()
|
2013-01-06 02:22:42 +08:00
|
|
|
// CHECK2-NOT: unreferenced1
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK2-LABEL: define void @unreferenced2()
|
|
|
|
// CHECK2-LABEL: define void @gnu_inline()
|
|
|
|
// CHECK2-LABEL: define i32 @test1
|
|
|
|
// CHECK2-LABEL: define i32 @test2
|
|
|
|
// CHECK2-LABEL: define void @test3
|
|
|
|
// CHECK2-LABEL: define available_externally i32 @test4
|
|
|
|
// CHECK2-LABEL: define available_externally i32 @test5
|
|
|
|
// CHECK2-LABEL: define i32 @test6
|
|
|
|
// CHECK2-LABEL: define void @test7
|
2013-01-06 02:22:42 +08:00
|
|
|
// CHECK2: define available_externally i{{..}} @strlcpy
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK2-LABEL: define void @test9
|
|
|
|
// CHECK2-LABEL: define void @testA
|
|
|
|
// CHECK2-LABEL: define void @testB
|
|
|
|
// CHECK2-LABEL: define void @testC
|
|
|
|
// CHECK2-LABEL: define available_externally i32 @foo()
|
2015-01-22 08:24:57 +08:00
|
|
|
// CHECK2-LABEL: define available_externally void @gnu_ei_inline()
|
2009-04-14 14:27:57 +08:00
|
|
|
|
2012-02-07 11:50:18 +08:00
|
|
|
// RUN: echo "C++ tests:"
|
2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ %s -triple i386-unknown-unknown -O1 -disable-llvm-passes -emit-llvm -o - -std=c++98 | FileCheck %s --check-prefix=CHECK3
|
2016-12-27 08:13:09 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ %s -triple i386-unknown-unknown -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=c++98 | FileCheck %s --check-prefix=CHECK3
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK3-LABEL: define i32 @_Z3barv()
|
|
|
|
// CHECK3-LABEL: define linkonce_odr i32 @_Z3foov()
|
2013-01-06 02:22:42 +08:00
|
|
|
// CHECK3-NOT: unreferenced
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK3-LABEL: define void @_Z10gnu_inlinev()
|
|
|
|
// CHECK3-LABEL: define available_externally void @_Z13gnu_ei_inlinev()
|
2015-05-14 06:07:22 +08:00
|
|
|
// CHECK3-NOT: @_Z5testCv
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK3-LABEL: define linkonce_odr i32 @_Z2eiv()
|
2009-04-14 14:27:57 +08:00
|
|
|
|
2013-08-02 01:26:42 +08:00
|
|
|
// RUN: echo "MS C Mode tests:"
|
2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i386-pc-win32 -O1 -disable-llvm-passes -emit-llvm -o - -std=c99 | FileCheck %s --check-prefix=CHECK4
|
2016-12-27 08:13:09 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i386-pc-win32 -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=c99 | FileCheck %s --check-prefix=CHECK4
|
2015-07-11 04:55:38 +08:00
|
|
|
// CHECK4-NOT: define weak_odr void @_Exit(
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK4-LABEL: define weak_odr dso_local i32 @ei()
|
|
|
|
// CHECK4-LABEL: define dso_local i32 @bar()
|
2014-04-03 07:17:29 +08:00
|
|
|
// CHECK4-NOT: unreferenced1
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK4-LABEL: define weak_odr dso_local void @unreferenced2()
|
|
|
|
// CHECK4-LABEL: define dso_local void @gnu_inline()
|
|
|
|
// CHECK4-LABEL: define linkonce_odr dso_local i32 @foo()
|
|
|
|
// CHECK4-LABEL: define available_externally dso_local void @gnu_ei_inline()
|
2013-08-02 01:26:42 +08:00
|
|
|
|
2015-07-11 04:55:38 +08:00
|
|
|
__attribute__((noreturn)) void __cdecl _exit(int _Code);
|
|
|
|
__inline void __cdecl _Exit(int status) { _exit(status); }
|
|
|
|
|
2009-04-28 11:13:54 +08:00
|
|
|
extern __inline int ei() { return 123; }
|
2009-04-14 14:27:57 +08:00
|
|
|
|
2009-04-28 11:13:54 +08:00
|
|
|
__inline int foo() {
|
2009-04-14 14:27:57 +08:00
|
|
|
return ei();
|
|
|
|
}
|
|
|
|
|
|
|
|
int bar() { return foo(); }
|
|
|
|
|
|
|
|
|
2009-04-28 11:13:54 +08:00
|
|
|
__inline void unreferenced1() {}
|
|
|
|
extern __inline void unreferenced2() {}
|
2009-04-14 14:27:57 +08:00
|
|
|
|
2009-04-21 03:12:28 +08:00
|
|
|
__inline __attribute((__gnu_inline__)) void gnu_inline() {}
|
2009-04-22 08:03:30 +08:00
|
|
|
|
|
|
|
// PR3988
|
2009-04-28 11:13:54 +08:00
|
|
|
extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {}
|
2009-04-22 08:03:30 +08:00
|
|
|
void (*P)() = gnu_ei_inline;
|
|
|
|
|
2009-04-24 02:22:55 +08:00
|
|
|
// <rdar://problem/6818429>
|
|
|
|
int test1();
|
2009-04-28 11:13:54 +08:00
|
|
|
__inline int test1() { return 4; }
|
|
|
|
__inline int test2() { return 5; }
|
|
|
|
__inline int test2();
|
2009-04-24 02:22:55 +08:00
|
|
|
int test2();
|
|
|
|
|
|
|
|
void test_test1() { test1(); }
|
|
|
|
void test_test2() { test2(); }
|
|
|
|
|
|
|
|
// PR3989
|
2009-04-28 11:13:54 +08:00
|
|
|
extern __inline void test3() __attribute__((gnu_inline));
|
2009-09-13 15:46:26 +08:00
|
|
|
__inline void __attribute__((gnu_inline)) test3() {}
|
2009-04-28 14:37:30 +08:00
|
|
|
|
|
|
|
extern int test4(void);
|
|
|
|
extern __inline __attribute__ ((__gnu_inline__)) int test4(void)
|
|
|
|
{
|
2009-07-22 04:52:43 +08:00
|
|
|
return 0;
|
2009-04-28 14:37:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_test4() { test4(); }
|
|
|
|
|
2009-09-13 15:46:26 +08:00
|
|
|
extern __inline int test5(void) __attribute__ ((__gnu_inline__));
|
2009-04-28 14:37:30 +08:00
|
|
|
extern __inline int __attribute__ ((__gnu_inline__)) test5(void)
|
|
|
|
{
|
2009-07-22 04:52:43 +08:00
|
|
|
return 0;
|
2009-04-28 14:37:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_test5() { test5(); }
|
2011-07-18 13:26:13 +08:00
|
|
|
|
|
|
|
// PR10233
|
|
|
|
|
|
|
|
__inline int test6() { return 0; }
|
|
|
|
extern int test6();
|
2011-07-18 15:11:55 +08:00
|
|
|
|
2012-02-02 14:06:34 +08:00
|
|
|
|
|
|
|
// No PR#, but this once crashed clang in C99 mode due to buggy extern inline
|
|
|
|
// redeclaration detection.
|
|
|
|
void test7() { }
|
2011-07-18 15:11:55 +08:00
|
|
|
void test7();
|
2011-10-12 06:09:24 +08:00
|
|
|
|
|
|
|
// PR11062; the fact that the function is named strlcpy matters here.
|
|
|
|
inline __typeof(sizeof(int)) strlcpy(char *dest, const char *src, __typeof(sizeof(int)) size) { return 3; }
|
|
|
|
void test8() { strlcpy(0,0,0); }
|
2012-02-07 11:50:18 +08:00
|
|
|
|
|
|
|
// PR10657; the test crashed in C99 mode
|
|
|
|
extern inline void test9() { }
|
|
|
|
void test9();
|
|
|
|
|
|
|
|
inline void testA() {}
|
|
|
|
void testA();
|
|
|
|
|
|
|
|
void testB();
|
|
|
|
inline void testB() {}
|
|
|
|
extern void testB();
|
|
|
|
|
|
|
|
extern inline void testC() {}
|
|
|
|
inline void testC();
|