blob: 3ee0f251d47ecd1b8c6e7de9bc09c3c26d78f653 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include "compiler.h"
#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TCompilerTest) {
Y_UNIT_TEST(TestPragmaNoWshadow) {
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_WSHADOW
// define two variables with similar names, latest must shadow first
// and there will be no warning for this
for (int i = 0; i < 1; ++i) {
for (int i = 100500; i < 100501; ++i) {
UNIT_ASSERT_EQUAL(i, 100500);
}
}
Y_PRAGMA_DIAGNOSTIC_POP
}
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_UNUSED_PARAMETER
// define function with unused named parameter
// and there will be no warning for this
int Foo(int a) {
return 0;
}
Y_PRAGMA_DIAGNOSTIC_POP
Y_UNIT_TEST(TestPragmaNoUnusedParameter) {
UNIT_ASSERT_EQUAL(Foo(1), 0);
}
Y_UNIT_TEST(TestHaveInt128) {
#ifdef Y_HAVE_INT128
// will be compiled without errors
unsigned __int128 a = 1;
__int128 b = 1;
UNIT_ASSERT_EQUAL(a, 1);
UNIT_ASSERT_EQUAL(b, 1);
UNIT_ASSERT_EQUAL(sizeof(a), sizeof(b));
// and we can set a type alias for __int128 and unsigned __int128 without compiler errors
using TMyInt128 = __int128;
using TMyUnsignedInt128 = unsigned __int128;
TMyInt128 i128value;
TMyUnsignedInt128 ui128value;
Y_UNUSED(i128value);
Y_UNUSED(ui128value);
#endif
}
// define deprecated function
[[deprecated]] void Bar() {
return;
}
Y_UNIT_TEST(TestNoDeprecated) {
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_DEPRECATED
// will be compiled without errors
Bar();
Y_PRAGMA_DIAGNOSTIC_POP
}
} // Y_UNIT_TEST_SUITE(TCompilerTest)
|