• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -E -fms-compatibility %s -o %t
2 // RUN: FileCheck %s < %t
3 
4 # define M2(x, y) x + y
5 # define P(x, y) {x, y}
6 # define M(x, y) M2(x, P(x, y))
7 M(a, b) // CHECK: a + {a, b}
8 
9 // Regression test for PR13924
10 #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
11 #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
12 
13 #define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
14 
15 #define GMOCK_ACTION_CLASS_(name, value_params)\
16     GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
17 
18 #define ACTION_TEMPLATE(name, template_params, value_params)\
19 class GMOCK_ACTION_CLASS_(name, value_params) {\
20 }
21 
22 ACTION_TEMPLATE(InvokeArgument,
23                 HAS_1_TEMPLATE_PARAMS(int, k),
24                 AND_2_VALUE_PARAMS(p0, p1));
25 
26 // Regression test for PR43282; check that we match MSVC's failure to unpack
27 // __VA_ARGS__ unless forwarded through another macro.
28 #define THIRD_ARGUMENT(A, B, C, ...) C
29 #define TEST(...) THIRD_ARGUMENT(__VA_ARGS__, 1, 2)
30 #define COMBINE(...) __VA_ARGS__
31 #define WRAPPED_TEST(...) COMBINE(THIRD_ARGUMENT(__VA_ARGS__, 1, 2))
32 // Check that we match MSVC's failure to unpack __VA_ARGS__, unless forwarded
33 // through another macro
34 auto packed = TEST(,);
35 auto unpacked = WRAPPED_TEST(,);
36 // CHECK: auto packed = 2;
37 // CHECK: auto unpacked = 1;
38 
39 // This tests compatibility with behaviour needed for type_traits in VS2012
40 // Test based on _VARIADIC_EXPAND_0X macros in xstddef of VS2012
41 #define _COMMA ,
42 
43 #define MAKER(_arg1, _comma, _arg2)                                            \
44   void func(_arg1 _comma _arg2) {}
45 #define MAKE_FUNC(_makerP1, _makerP2, _arg1, _comma, _arg2)                    \
46   _makerP1##_makerP2(_arg1, _comma, _arg2)
47 
48 MAKE_FUNC(MAK, ER, int a, _COMMA, int b);
49 // CHECK: void func(int a , int b) {}
50 
51 #define macro(a, b) (a - b)
52 void function(int a);
53 #define COMMA_ELIDER(...) \
54   macro(x, __VA_ARGS__); \
55   function(x, __VA_ARGS__);
56 COMMA_ELIDER();
57 // CHECK: (x - );
58 // CHECK: function(x);
59