2014-10-10 08:05:45 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-windows-msvc | FileCheck %s --check-prefix=WINDOWS
|
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s --check-prefix=LINUX
|
|
|
|
|
|
|
|
// Make it possible to pass NULL through variadic functions on platforms where
|
|
|
|
// NULL has an integer type that is more narrow than a pointer. On such
|
[Win64] Don't widen integer literal zero arguments to unprototyped function calls
The special case to widen the integer literal zero when passed to
variadic function calls should only apply to variadic functions, not
unprototyped functions. This is consistent with what MSVC does. In this
test case, MSVC uses a 4-byte store to pass the 5th argument to 'kr' and
an 8-byte store to pass the zero to 'v':
void v(int, ...);
void kr();
void f(void) {
v(1, 2, 3, 4, 0);
kr(1, 2, 3, 4, 0);
}
Aaron Ballman discovered this issue in https://reviews.llvm.org/D28166
llvm-svn: 290906
2017-01-04 05:23:35 +08:00
|
|
|
// platforms we widen null pointer constants passed to variadic functions to a
|
|
|
|
// pointer-sized integer. We don't apply this special case to K&R-style
|
|
|
|
// unprototyped functions, because MSVC doesn't either.
|
2014-10-10 08:05:45 +08:00
|
|
|
|
|
|
|
#define NULL 0
|
|
|
|
|
|
|
|
void v(const char *f, ...);
|
[Win64] Don't widen integer literal zero arguments to unprototyped function calls
The special case to widen the integer literal zero when passed to
variadic function calls should only apply to variadic functions, not
unprototyped functions. This is consistent with what MSVC does. In this
test case, MSVC uses a 4-byte store to pass the 5th argument to 'kr' and
an 8-byte store to pass the zero to 'v':
void v(int, ...);
void kr();
void f(void) {
v(1, 2, 3, 4, 0);
kr(1, 2, 3, 4, 0);
}
Aaron Ballman discovered this issue in https://reviews.llvm.org/D28166
llvm-svn: 290906
2017-01-04 05:23:35 +08:00
|
|
|
void kr();
|
2014-10-10 08:05:45 +08:00
|
|
|
void f(const char *f) {
|
|
|
|
v(f, 1, 2, 3, NULL);
|
[Win64] Don't widen integer literal zero arguments to unprototyped function calls
The special case to widen the integer literal zero when passed to
variadic function calls should only apply to variadic functions, not
unprototyped functions. This is consistent with what MSVC does. In this
test case, MSVC uses a 4-byte store to pass the 5th argument to 'kr' and
an 8-byte store to pass the zero to 'v':
void v(int, ...);
void kr();
void f(void) {
v(1, 2, 3, 4, 0);
kr(1, 2, 3, 4, 0);
}
Aaron Ballman discovered this issue in https://reviews.llvm.org/D28166
llvm-svn: 290906
2017-01-04 05:23:35 +08:00
|
|
|
kr(f, 1, 2, 3, 0);
|
2014-10-10 08:05:45 +08:00
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// WINDOWS: define dso_local void @f(i8* %f)
|
2015-04-17 07:25:00 +08:00
|
|
|
// WINDOWS: call void (i8*, ...) @v(i8* {{.*}}, i32 1, i32 2, i32 3, i64 0)
|
[Win64] Don't widen integer literal zero arguments to unprototyped function calls
The special case to widen the integer literal zero when passed to
variadic function calls should only apply to variadic functions, not
unprototyped functions. This is consistent with what MSVC does. In this
test case, MSVC uses a 4-byte store to pass the 5th argument to 'kr' and
an 8-byte store to pass the zero to 'v':
void v(int, ...);
void kr();
void f(void) {
v(1, 2, 3, 4, 0);
kr(1, 2, 3, 4, 0);
}
Aaron Ballman discovered this issue in https://reviews.llvm.org/D28166
llvm-svn: 290906
2017-01-04 05:23:35 +08:00
|
|
|
// WINDOWS: call void bitcast (void (...)* @kr to void (i8*, i32, i32, i32, i32)*)(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
|
2014-10-10 08:05:45 +08:00
|
|
|
// LINUX: define void @f(i8* %f)
|
2015-04-17 07:25:00 +08:00
|
|
|
// LINUX: call void (i8*, ...) @v(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
|
2017-01-04 05:29:51 +08:00
|
|
|
// LINUX: call void (i8*, i32, i32, i32, i32, ...) bitcast (void (...)* @kr to void (i8*, i32, i32, i32, i32, ...)*)(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
|