summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/decl-microsoft-call-conv.cpp28
-rw-r--r--clang/test/SemaTemplate/instantiate-function-params.cpp9
2 files changed, 33 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/decl-microsoft-call-conv.cpp b/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
index 3175af7f1b0..9e85e62cf88 100644
--- a/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
+++ b/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -29,6 +29,8 @@ void __cdecl free_func_default(int *);
void __thiscall free_func_cdecl(char *);
void __cdecl free_func_cdecl(double);
+typedef void void_fun_t();
+typedef void __cdecl cdecl_fun_t();
// Pointers to member functions
struct S {
@@ -38,7 +40,13 @@ struct S {
void __cdecl member_cdecl2(); // expected-note {{previous declaration is here}}
void __thiscall member_thiscall1();
void __thiscall member_thiscall2(); // expected-note {{previous declaration is here}}
-
+
+ // Unless attributed, typedefs carry no calling convention and use the default
+ // based on context.
+ void_fun_t member_typedef_default; // expected-note {{previous declaration is here}}
+ cdecl_fun_t member_typedef_cdecl; // expected-note {{previous declaration is here}}
+ __stdcall void_fun_t member_typedef_stdcall;
+
// Static member functions can't be __thiscall
static void static_member_default1();
static void static_member_default2(); // expected-note {{previous declaration is here}}
@@ -58,6 +66,10 @@ struct S {
void __cdecl S::member_default1() {} // expected-error {{function declared 'cdecl' here was previously declared without calling convention}}
void __thiscall S::member_default2() {}
+void __cdecl S::member_typedef_default() {} // expected-error {{function declared 'cdecl' here was previously declared without calling convention}}
+void __thiscall S::member_typedef_cdecl() {} // expected-error {{function declared 'thiscall' here was previously declared 'cdecl'}}
+void __stdcall S::member_typedef_stdcall() {}
+
void S::member_cdecl1() {}
void __thiscall S::member_cdecl2() {} // expected-error {{function declared 'thiscall' here was previously declared 'cdecl'}}
@@ -84,3 +96,17 @@ void S::static_member_variadic_cdecl(int x, ...) {
(void)x;
}
+// Declare a template using a calling convention.
+template <class CharT> inline int __cdecl mystrlen(const CharT *str) {
+ int i;
+ for (i = 0; str[i]; i++) { }
+ return i;
+}
+extern int sse_strlen(const char *str);
+template <> inline int __cdecl mystrlen(const char *str) {
+ return sse_strlen(str);
+}
+void use_tmpl(const char *str, const int *ints) {
+ mystrlen(str);
+ mystrlen(ints);
+}
diff --git a/clang/test/SemaTemplate/instantiate-function-params.cpp b/clang/test/SemaTemplate/instantiate-function-params.cpp
index 7ab21c7d7ed..5bfae537c04 100644
--- a/clang/test/SemaTemplate/instantiate-function-params.cpp
+++ b/clang/test/SemaTemplate/instantiate-function-params.cpp
@@ -81,18 +81,21 @@ namespace InstantiateFunctionTypedef {
template<typename T>
struct X {
typedef int functype(int, int);
- functype func;
+ functype func1;
+ __attribute__((noreturn)) functype func2;
typedef int stdfunctype(int, int) __attribute__((stdcall));
__attribute__((stdcall)) functype stdfunc1;
stdfunctype stdfunc2;
- // FIXME: Test a calling convention not supported by this target.
+ __attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{calling convention 'pcs' ignored for this target}}
};
void f(X<int> x) {
- (void)x.func(1, 2);
+ (void)x.func1(1, 2);
+ (void)x.func2(1, 2);
(void)x.stdfunc1(1, 2);
(void)x.stdfunc2(1, 2);
+ (void)x.pcsfunc(1, 2);
}
}
OpenPOWER on IntegriCloud