59 lines · c
1// RUN: %clang_cc1 -E -fms-compatibility %s -o %t2// RUN: FileCheck %s < %t3 4# define M2(x, y) x + y5# define P(x, y) {x, y}6# define M(x, y) M2(x, P(x, y))7M(a, b) // CHECK: a + {a, b}8 9// Regression test for PR1392410#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)11#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar12 13#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P214 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)\19class GMOCK_ACTION_CLASS_(name, value_params) {\20}21 22ACTION_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 unpack27// __VA_ARGS__ unless forwarded through another macro.28#define THIRD_ARGUMENT(A, B, C, ...) C29#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 forwarded33// through another macro34auto packed = TEST(,);35auto 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 VS201240// Test based on _VARIADIC_EXPAND_0X macros in xstddef of VS201241#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 48MAKE_FUNC(MAK, ER, int a, _COMMA, int b);49// CHECK: void func(int a , int b) {}50 51#define macro(a, b) (a - b)52void function(int a);53#define COMMA_ELIDER(...) \54 macro(x, __VA_ARGS__); \55 function(x, __VA_ARGS__);56COMMA_ELIDER();57// CHECK: (x - );58// CHECK: function(x);59