File indexing completed on 2024-05-12 04:02:10

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