xref: /llvm-project/clang/test/Sema/implicit-ms-builtin-decl.c (revision 7d644e1215b376ec5e915df9ea2eeb56e2d94626)
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s -fms-extensions
2 // RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s -fms-extensions
3 
f(void)4 void f(void) {
5   (void)_byteswap_ushort(42); // expected-error{{call to undeclared library function '_byteswap_ushort'}} \
6   // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_ushort'}}
7   (void)_byteswap_uint64(42LL); // expected-error{{call to undeclared library function '_byteswap_uint64'}} \
8   // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_uint64'}}
9 }
10 
11 void _byteswap_ulong(void); // expected-warning{{incompatible redeclaration of library function '_byteswap_ulong'}} \
12 // expected-note{{'_byteswap_ulong' is a builtin}}
13 
14 unsigned short _byteswap_ushort(unsigned short);
15 unsigned long long _byteswap_uint64(unsigned long long);
16 
g(void)17 void g(void) {
18   (void)_byteswap_ushort(42);
19   (void)_byteswap_uint64(42LL);
20 }
21 
22 #if defined(__x86_64__)
h(void)23 void h(void) {
24   (void)__mulh(21, 2);  // expected-error{{call to undeclared library function '__mulh'}} \
25   // expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__mulh'}}
26   (void)__umulh(21, 2); // expected-error{{call to undeclared library function '__umulh'}} \
27   // expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__umulh'}}
28 }
29 
30 long long __mulh(long long, long long);
31 unsigned long long __umulh(unsigned long long, unsigned long long);
32 
i(void)33 void i(void) {
34   (void)__mulh(21, 2);
35   (void)__umulh(21, 2);
36 }
37 #endif
38 
39 #if defined(i386)
h(void)40 void h(void) {
41   (void)__mulh(21LL, 2LL);  // expected-error{{call to undeclared function '__mulh'; ISO C99 and later do not support implicit function declarations}}
42   (void)__umulh(21ULL, 2ULL);  // expected-error{{call to undeclared function '__umulh'; ISO C99 and later do not support implicit function declarations}}
43 }
44 #endif
45