Clang Project

clang_source_code/test/Sema/implicit-ms-builtin-decl.c
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
4void f() {
5  (void)_byteswap_ushort(42); // expected-warning{{implicitly declaring 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-warning{{implicitly declaring library function '_byteswap_uint64'}} \
8  // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_uint64'}}
9}
10
11void _byteswap_ulong(); // expected-warning{{incompatible redeclaration of library function '_byteswap_ulong'}} \
12// expected-note{{'_byteswap_ulong' is a builtin}}
13
14unsigned short _byteswap_ushort(unsigned short);
15unsigned long long _byteswap_uint64(unsigned long long);
16
17void g() {
18  (void)_byteswap_ushort(42);
19  (void)_byteswap_uint64(42LL);
20}
21
22#if defined(__x86_64__)
23void h() {
24  (void)__mulh(21, 2);  // expected-warning{{implicitly declaring library function '__mulh'}} \
25  // expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__mulh'}}
26  (void)__umulh(21, 2); // expected-warning{{implicitly declaring library function '__umulh'}} \
27  // expected-note{{include the header <intrin.h> or explicitly provide a declaration for '__umulh'}}
28}
29
30long long __mulh(long long, long long);
31unsigned long long __umulh(unsigned long long, unsigned long long);
32
33void i() {
34  (void)__mulh(21, 2);
35  (void)__umulh(21, 2);
36}
37#endif
38
39#if defined(i386)
40void h() {
41  (void)__mulh(21LL, 2LL);  // expected-warning{{implicit declaration of function '__mulh' is invalid}}
42  (void)__umulh(21ULL, 2ULL);  // expected-warning{{implicit declaration of function '__umulh' is invalid}}
43}
44#endif
45