File indexing completed on 2024-05-19 15:23:18
0001 #pragma once 0002 0003 #include <cassert> 0004 #include <assert.h> 0005 #include "assert.h" 0006 #include "assert.hpp" // abc 0007 #include "path/assert.hpp" 0008 #include "assert.h"a 0009 #include "assert.h" a 0010 #include <cassert>a 0011 #include <cassert> a 0012 #include FOO() error 0013 #include_next <cassert> a 0014 #include_next <cassert> /* a 0015 */ b 0016 #include PATH_IN_MACRO 0017 #include PATH_IN_MACRO() 0018 #include PATH_IN_MACRO(a, b) 0019 0020 #define SOME_VAR 1 0021 #ifdef SOME_VAR 0022 0023 #define MULTILINE_MACRO one \ 0024 two \ 0025 three 0026 0027 # define MULTILINE_MACRO_TEXT \ 0028 /* NOTE The contents of macro is too green :D */ \ 0029 char const s[] = "a\\b" \ 0030 "c\nd" 0031 0032 # define VARIADIC(a, ...) \ 0033 f(a##a) \ 0034 f(__VA_ARGS__) \ 0035 f(#__VA_ARGS__) \ 0036 f(__VA_ARGS__) \ 0037 f(0 __VA_OPT__(,) __VA_ARGS__) \ 0038 x __VA_OPT__(= { __VA_ARGS__ }) 0039 0040 # define MACRO() BAD \ ESCAPED 0041 0042 # error dds 0043 # warning dds 0044 # line 2 "file.cpp" 0045 # define A(x, y) x##y x#y 0046 // OK(L, a) -> L"a" 0047 # define OK(x, y) x###y 0048 # define BAD(x, y) x####y 0049 # define A /* multi line 0050 with comment */ expr 0051 # define A /* multi line 0052 with comment */ 0053 23 0054 #else // x 0055 #42 // gcc extension = #line 42 0056 0057 // error 0058 #wrong 0059 # wrong 0060 #endif x 0061 #if DS() 0062 #else x 0063 #else /* */x 0064 #else /* x 0065 y */ z 0066 #endif 0067 0068 // check that _XXX defines work, bug 397766 0069 #ifndef _HEADER_GUARD 0070 #define _HEADER_GUARD 1 0071 #endif 0072 #ifdef _HEADER_GUARD 0073 #if (_HEADER_GUARD >= 1) 0074 #endif 0075 #endif 0076 0077 static int g_global; 0078 0079 template<class T, typename U, template<class> class = std::is_pointer> 0080 struct class1 0081 : private std::vector<T>, public U 0082 { 0083 class1() 0084 try 0085 : _member1(xxx) 0086 {} 0087 catch(...) 0088 {} 0089 0090 class1(class1&&) = default; 0091 0092 ~class1() 0093 {} 0094 0095 void foo() { return; } 0096 void foo() const { return; } 0097 void foo() noexcept { return; } 0098 void foo() const noexcept { return; } 0099 virtual void foo() const noexcept { return; } 0100 static void foo() { return; } 0101 constexpr static void foo() const 0102 noexcept(noexcept(std::is_pointer<U>::value)) override 0103 { 0104 xxx::template ttt<U>::type {}; 0105 xxx.template get<U>(); 0106 xxx.std::rdbuf(); 0107 auto x = C<'a'> + y; 0108 } 0109 0110 int operator->*(T (C::*m)(int)); 0111 operator value_t (); 0112 0113 private: 0114 protected: 0115 public: 0116 value_type _member1; // NOTE internal ? 0117 value_type __internal; 0118 value_type internal__; 0119 value_type _M_internal; 0120 value_t member2_; 0121 value_type m_member3; 0122 0123 static int s_static; 0124 static constexpr int s_static; 0125 static inline int s_static; 0126 static inline constexpr int s_static; 0127 }; 0128 0129 constexpr struct : xyz 0130 { 0131 using xyz::xyz; 0132 using xyz::operator=; 0133 0134 int a : 1; 0135 int b : 7; 0136 } x {}; 0137 0138 template<class T> 0139 using is_pointer = std::is_pointer<T>::type; 0140 0141 template<class T> 0142 constexpr auto is_pointer_v = std::is_pointer<T>::value; 0143 0144 uint64_t namespaces() 0145 { 0146 std::vector<T>; 0147 boost::vector<T>; 0148 detail::vector<T>; 0149 details::vector<T>; 0150 aux::vector<T>; 0151 internals::vector<T>; 0152 other::vector<T>; 0153 } 0154 0155 task<> tcp_echo_server() { 0156 char data[1024]; 0157 for (;;) { 0158 size_t n = co_await socket.async_read_some(buffer(data)); 0159 co_await async_write(socket, buffer(data, n)); 0160 } 0161 } 0162 0163 #if 1 0164 double foo(const A); 0165 #else // else 0166 double foo(const A); 0167 #endif // end 0168 0169 #if 0 0170 double foo(const A); 0171 #else // else 0172 double foo(const A); 0173 #endif // end 0174 0175 #if 1 0176 double foo(const A); 0177 #elif 1 0178 double foo(const A); 0179 #elif 0 0180 double foo(const A); 0181 #endif // end 0182 0183 #if 0 0184 double foo(const A); 0185 #elif 1 0186 double foo(const A); 0187 #elif 0 0188 double foo(const A); 0189 #endif // end 0190 0191 #if 0 0192 double foo(const A); 0193 #elif a 0194 double foo(const A); 0195 #elif 0 0196 double foo(const A); 0197 #elif a 0198 double foo(const A); 0199 #else // else 0200 double foo(const A); 0201 #endif // end 0202 0203 #if 0 // blah blah 0204 double foo(const A); 0205 #elif 1 // blah blah 0206 double foo(const A); 0207 #else // else 0208 double foo(const A); 0209 #endif // end 0210 0211 #if 0 || a 0212 double foo(const A); 0213 #else // else 0214 double foo(const A); 0215 #endif // end 0216 0217 #if 1 || a 0218 double foo(const A); 0219 #else // else 0220 double foo(const A); 0221 #endif // end 0222 0223 #if 0 && a 0224 double foo(const A); 0225 #else // else 0226 double foo(const A); 0227 #endif // end 0228 0229 #if 1 && a 0230 double foo(const A); 0231 #else // else 0232 double foo(const A); 0233 #endif // end 0234 0235 #if a 0236 double foo(const A); 0237 #elif 0 0238 double foo(const A); 0239 #endif // end 0240 0241 #if a 0242 double foo(const A); 0243 #elif 1 0244 double foo(const A); 0245 #endif // end 0246 0247 #if a 0248 double foo(const A); 0249 #elif a 0250 double foo(const A); 0251 #endif // end 0252 0253 int bar(void*p, void * pp) 0254 { 0255 # if 0 0256 double foo(); 0257 # else // else 0258 double foo(); 0259 # endif // end 0260 } 0261 0262 #if abc 0 0263 double foo(); 0264 #endif // end 0265 0266 #if xxx 0267 double foo(); 0268 #else 0269 double foo(); 0270 #endif // end 0271 0272 #if xxx 0273 double foo(); 0274 #elif xxx // elseif 0275 double foo(); 0276 #elif xxx // elseif 0277 double foo(); 0278 #endif // end 0279 0280 // error 0281 0282 "># 0283 #d 0284 # d 0285 #if 0286 #elif 0287 #endif 0288 #ifndef 0289 #endif 0290 #ifdef 0 0291 #endif // end 0292 0293 static uint64_t intWithSuffix = 42ull; 0294 static long intWithSuffixAndPrefix = 0b0101L; 0295 static int octNum = 07232; 0296 static int invalidOctNum = 09231; 0297 static uint64_t hexNum = 0xDEADBEEF42; 0298 static uint64_t invalidHexNum = 0xGLDFKG; 0299 static char binNum = 0b0101010; 0300 0301 static int64_t intWithSuffix = -42LL; 0302 static long intWithSuffixAndPrefix = -0b0101L; 0303 static int octNum = -07232; 0304 static int invalidOctNum = -09231; 0305 static int64_t hexNum = -0xDEADBEEF42; 0306 static int64_t invalidHexNum = -0xGLDFKG; 0307 static char binNum = -0b0101010; 0308 0309 static uint64_t intWithSuffixWithSep = 4'2ull; 0310 static long intWithSuffixAndPrefixWithSep = 0b0'10'1L; 0311 static int octNumWithSep = 07'232; 0312 static int invalidOctNumWithSep = 09'23'1; 0313 static uint64_t hexNumWithSep = 0xD'EAD'BE'EF'42; 0314 static uint64_t invalidHexNumWithSep = 0xGLD'FKG; 0315 static char binNumWithSep = 0b0'1010'10; 0316 0317 static uint64_t invalidSep = 42'ull; 0318 static uint64_t invalidSep = 42'; 0319 0320 static double d1 = 42.; 0321 static double d2 = .42; 0322 static double d2a = -0.49; 0323 static double d2b = -0.09; 0324 static double d3 = 42.3e1; 0325 static double d4 = .2e-12; 0326 static double d5 = 32.e+12; 0327 static double invalidD1 = 32.e+a12; 0328 static float floatQualifier = 23.123f; 0329 // Hexadecimal floating point (c++17) 0330 static double d6 = 0x1ffp10; 0331 static double d7 = 0X0p-1; 0332 static double d8 = 0x1.p0; 0333 static double d9 = 0xf.p-1L; 0334 static double d10 = 0x0.123p-1; 0335 static double d11 = 0xa.bp10l; 0336 static double invalidD2 = 0x0.123p-a; 0337 static float floatQualifier = 0xf.p-1f; 0338 0339 60min; // c++17 0340 60.min; 0341 60.3min; 0342 0x1ffp10min; 0343 2us 0344 2d; // c++20 0345 23._f 0346 23._fd 0347 2.3_f 0348 2.3_fd 0349 2._f 0350 2._fd 0351 2e4_f 0352 2e4_fd 0353 0354 // error 0355 23.fd 0356 2e_fd 0357 2e 0358 1.y 0359 1.0_E+2.0 0360 1.0_E +2.0 // ok 0361 1_p+2 0362 1_p +2 // ok 0363 4s.count() 0364 4s. count() 0365 4s .count() // ok 0366 0367 static bool yes = true; 0368 static bool no = false; 0369 0370 // *char* 0371 static const char c1 = 'c'; 0372 static const char c1a = u8'c'; // utf-8 char (c++17) 0373 static const char16_t c1b = u'c'; 0374 static const char32_t c1c = U'c'; 0375 static const wchar_t c1d = L'c'; 0376 static const char c2 = '\n'; 0377 static const char c2a = '\120'; // octal 0378 static const char c2b = '\x1f'; // hex 0379 static const char c2c = '\''; 0380 static const char c2d = '\\'; 0381 static const wchar_t c2e = L'\x1ff'; // hex 0382 static const wchar_t c2e = U'\x1fffffff'; // hex 0383 // error 0384 '\x123'; 0385 '\u1234'; 0386 '\U12345678'; 0387 U'\u12345'; 0388 u'\u123'; 0389 U'\U1234567'; 0390 U'\U123456789'; 0391 U'\x123456789'; 0392 0393 // string 0394 static const char* c3 = "string"; 0395 static const char* c4 = "\"string\n\t\012\x12\""; 0396 static const char* c5 = "multiline \ 0397 string"; 0398 static const char* c6 = "multifragment" "other""string"; 0399 static const char* c6a = u8"string"; 0400 static const char16_t* c6b = u"string"; 0401 static const char32_t* c6c = U"string"; 0402 static const wchar_t* c6d = L"string"; 0403 static const char* rawString1 = R"(string)"; 0404 static const char* rawString1a = u8R"(string)"; 0405 static const char16_t* rawString1b = uR"(string)"; 0406 static const char32_t* rawString1c = UR"(string)"; 0407 static const wchar_t* rawString1d = LR"(string\nstring)"; 0408 static const char* rawString2 = R"ab(string\nstring%s)ab ")ab"; 0409 static const char* rawString3 = R"ab(string 0410 string%)ab"; 0411 " %d %df fd" U"ds %d" R"(a%d)"; 0412 "\x123xsk"; 0413 u"\x123xsk"; 0414 // error 0415 u8"\x123xsk"; 0416 0417 // printf format 0418 "a%10sa%-10sa%*sa%-10.*sa%-*.*sa" 0419 "a%ca%*ca%%a%ia%da%.6ia%.0ia%+ia%ia%xa%#xa" 0420 "a%.0fa%.32fa%05.2fa%.2fa%5.2fa%Ea%aa" 0421 // std::format 0422 "a{{:6}}a{}a{:6}a{:*<6}a{:6d}a" 0423 "a{0:}a{0:+}a{0:-}a{0: }a" 0424 "a{:+06d}a{:#06x}a{:<06}a" 0425 "a{:{}}a{0:{1}.{2}f}a" 0426 ; 0427 0428 // UDL (c++11) 0429 0430 operator""_a(const char*); 0431 operator ""_a(const char*); 0432 operator "" _a(const char*); 0433 // invalid suffix 0434 operator "" a(const char*); 0435 operator ""a(const char*); 0436 operator""a(const char*); 0437 0438 "string"_s; // user 0439 "string"s; // standard 0440 "string"_s-b; // -b is not part of the string 0441 0442 // Macro 0443 0444 MY_XXX; 0445 BOOST_XXX; 0446 __STDC_VERSION__; 0447 __TIME__; 0448 __cplusplus; 0449 0450 // Attributes 0451 0452 [[noreturn]] void foo(); 0453 [[deprecated]] void foo(); 0454 [[deprecated("because")]] void foo(); 0455 void foo([[carries_dependency]] int); 0456 0457 [[opt(1), debug]] 0458 [[using CC: opt(1), debug]] // c++17 0459 [[using CC: CC::opt(1)]] // c++17 0460 0461 [[gnu::assume_aligned(3'2l,2)]] void* f(); 0462 [[using gnu: assume_aligned(3)]] 0463 [[clang::assume_aligned(3)]] 0464 0465 void f([[maybe_unused]] int val) 0466 { 0467 [[maybe_unused]] int x; 0468 switch (x = foo(); x) { 0469 case 1: 0470 [[fallthrough]]; 0471 case XXX: 0472 case Class::foo(): 0473 [[fallthrough]]; 0474 default: 0475 ; 0476 } 0477 0478 // c++17: fold expression 0479 (args + ... + (1 * 2)); 0480 (v.push_back(args), ...); 0481 0482 [[omp::parallel]] for (auto&& x : v) 0483 x; 0484 for (auto&& [first,second] : mymap) { 0485 } 0486 0487 auto [x, y] = foo(); 0488 0489 [x = 1, =y](){}; 0490 0491 decltype((auto)) x = foo(); 0492 } 0493 0494 auto f() -> decltype(foo()); 0495 0496 __attribute__((pure)) void f(); 0497 0498 label: 0499 goto label; 0500 0501 0502 //BEGIN region 0503 // TODO comment FIXME comment ### comment BUG comment 0504 //END region 0505 0506 // \brief blah blah 0507 /// \brief blah blah 0508 0509 /** 0510 * Doxygen 0511 * @param p1 text 0512 * \brief <b>bold text</b> 0513 * \dot 0514 * a -> b 0515 * \enddot 0516 * 0517 * \verbatim 0518 * <dummy> 0519 * \endverbatim 0520 * <html>text</html> 0521 */ 0522 0523 #endif 0524 0525 // Some GNU macros, cross-referenced from gcc.xml to isocpp.xml 0526 __GCC_ATOMIC_CHAR16_T_LOCK_FREE 0527 __GNUC__ 0528 __linux__ 0529 0530 // Digraphs (see bug #411508) 0531 %:include <stdio.h> 0532 int main() 0533 <% 0534 [](){%>(); 0535 } 0536 <:<:fallthrough]] 0537 0538 /** 0539 * multi-line comment 0540 */ 0541 0542 /* comment */ 0543 { { } { 0544 //BEGIN 0545 } 0546 //END 0547 } 0548 0549 #if 0 0550 #elif 1 0551 #else 0552 #endif 0553 0554 #if 1 0555 int x; // variable shall not be grey 0556 #endif 0557 #if defined (A) 0558 int y; // variable shall not be grey 0559 #elif defined (B) 0560 int z; // variable shall not be grey 0561 #endif 0562 0563 /*! 0564 * formula @f$a+b@f$ inside a block comment 0565 */ 0566 0567 //! formula @f$a+b@f$ inside a inline comment 0568 // formula @f$a+b@f$ inside a normal comment 0569 0570 /// \b sa