xref: /llvm-project/clang/test/Sema/alias-unused-win.cpp (revision 0665669876cd7f51f7572cff3bb97485d78f5de5)
1 // RUN: %clang_cc1 -triple %ms_abi_triple -Wunused -x c -verify %s
2 // RUN: %clang_cc1 -triple %ms_abi_triple -Wunused -verify=expected,cxx %s
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
f(void)7 static int f(void) { return 42; } // cxx-warning{{unused function 'f'}}
8 int g(void) __attribute__((alias("f")));
9 
10 static int foo [] = { 42, 0xDEAD };
11 extern typeof(foo) bar __attribute__((unused, alias("foo")));
12 
f0(int x)13 static int __attribute__((overloadable)) f0(int x) { return x; } // expected-warning{{unused function 'f0'}}
f0(float x)14 static float __attribute__((overloadable)) f0(float x) { return x; } // expected-warning{{unused function 'f0'}}
15 int g0(void) __attribute__((alias("?f0@@YAHH@Z")));
16 
17 #ifdef __cplusplus
18 /// https://github.com/llvm/llvm-project/issues/88593
19 /// We report a warning in C++ mode because the internal linkage `resolver` gets
20 /// mangled as it does not have a language linkage. GCC does not mangle
21 /// `resolver` or report a warning.
f1()22 static int f1() { return 42; } // cxx-warning{{unused function 'f1'}}
23 int g1(void) __attribute__((alias("?f1@@YAHXZ")));
24 }
25 
26 namespace ns {
f3(int)27 static int f3(int) { return 42; } // cxx-warning{{unused function 'f3'}}
f3()28 static int f3() { return 42; } // cxx-warning{{unused function 'f3'}}
29 int g3() __attribute__((alias("?f3@ns@@YAHXZ")));
30 }
31 #endif
32