From 77dfc3dd7538dcd1d544b64eb347a9aa861e1b83 Mon Sep 17 00:00:00 2001 From: David Dight Date: Sun, 9 Jun 2024 08:23:56 +1000 Subject: [PATCH] msvc type fix 3 --- examples/srcloctest.cpp | 82 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/examples/srcloctest.cpp b/examples/srcloctest.cpp index 4e65e3fa..0835b9fc 100644 --- a/examples/srcloctest.cpp +++ b/examples/srcloctest.cpp @@ -35,6 +35,7 @@ #include #include #include +#include //----------------------------------------------------------------------------------------- enum class Namespace_Enum_Type : int { Value }; @@ -74,6 +75,28 @@ class conjure_type using UType = std::vector>; +namespace +{ + enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + namespace TEST1 + { + enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + } +} + +namespace TEST +{ + enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + namespace TEST1 + { + enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine }; + } +} + //----------------------------------------------------------------------------------------- // pass -m to generate markdown version //----------------------------------------------------------------------------------------- @@ -114,20 +137,48 @@ int main(int argc, char **argv) conjure_type::tpeek(), conjure_type::tpeek(), }; - const bool md { argc > 1 && std::string_view(argv[1]) == "-m" }; - if (md) - std::cout << "# "; - std::cout << "Compiler: " + + static constexpr const char *optstr{"emch"}; + bool md{}, ext{}, comp{true}; + for (int opt; (opt = getopt(argc, argv, optstr)) != -1;) + { + switch (opt) + { + case 'm': md = true; break; + case 'c': comp = false; break; + case 'e': ext = true; break; + case ':': case '?': std::cout << '\n'; + [[fallthrough]]; + case 'h': + std::cout << "Usage: " << argv[0] << " [-" << optstr << "]" << R"( + -e run extended enum test + -c show compiler (default true) + -m output using markdown + -h help +)"; + exit(1); + default: + break; + } + } + + if (comp) + { + if (md) + std::cout << "# "; + std::cout << "Compiler: " #if defined __clang__ - "Clang" ": " __VERSION__ + "Clang" ": " __VERSION__ #elif defined __GNUC__ - "GCC" ": " __VERSION__ + "GCC" ": " __VERSION__ #elif defined _MSC_VER - "MSVC" ": " << _MSC_VER << + "MSVC" ": " << _MSC_VER << #else # error "Not Supported" #endif - "\n"; + "\n"; + } + for (const auto *pp : srclocstrs) { if (md && std::isdigit(pp[0])) @@ -143,5 +194,20 @@ int main(int argc, char **argv) } if (md) std::cout << "```\n"; + + if (ext) + { + std::cout << "\n9. edge enum types\n" + << conjure_type::tpeek() << '\n' + << conjure_type::tpeek() << '\n' + << conjure_type::tpeek() << '\n' + << conjure_type::tpeek() << '\n'; + + std::cout << conjure_type::tpeek() << '\n' + << conjure_type::tpeek() << '\n' + << conjure_type::tpeek() << '\n' + << conjure_type::tpeek() << '\n'; + } + return 0; }