Summary: Makes functions with implicit calling convention compatible with function types with a matching explicit calling convention. This fixes things like calls to qsort(), which has an explicit __cdecl attribute on the comparator in Windows headers. Clang will now infer the calling convention from the declarator. There are two cases when the CC must be adjusted during redeclaration: 1. When defining a non-inline static method. 2. When redeclaring a function with an implicit or mismatched convention. Fixes PR13457, and allows clang to compile CommandLine.cpp for the Microsoft C++ ABI. Excellent test cases provided by Alexander Zinenko! Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1231 llvm-svn: 189412
27 lines
707 B
C
27 lines
707 B
C
// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s | FileCheck %s
|
|
|
|
void baz(int arg);
|
|
|
|
// CHECK: define x86_stdcallcc void @foo(i32 %arg) [[NUW:#[0-9]+]]
|
|
void foo(int arg) {
|
|
// CHECK: call x86_stdcallcc i32 bitcast (i32 (...)* @bar to i32 (i32)*)(
|
|
bar(arg);
|
|
// CHECK: call x86_stdcallcc void @baz(i32
|
|
baz(arg);
|
|
}
|
|
|
|
// CHECK: declare x86_stdcallcc i32 @bar(...)
|
|
|
|
// CHECK: declare x86_stdcallcc void @baz(i32)
|
|
|
|
void qux(int arg, ...) { }
|
|
// CHECK: define void @qux(i32 %arg, ...)
|
|
|
|
void quux(int a1, int a2, int a3) {
|
|
qux(a1, a2, a3);
|
|
}
|
|
// CHECK-LABEL: define x86_stdcallcc void @quux
|
|
// CHECK: call void (i32, ...)* @qux
|
|
|
|
// CHECK: attributes [[NUW]] = { nounwind{{.*}} }
|