diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp index 055ad76d09b..06fdc6080c0 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp @@ -59,7 +59,7 @@ private: const int anotherConstant; }; -int ValueArray[] = {3, 5}; +int ValueArray[] = {3, 5, 0, 0, 0}; // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers] // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers] @@ -183,7 +183,7 @@ struct Rectangle { const geometry::Rectangle<double> mandelbrotCanvas{geometry::Point<double>{-2.5, -1}, geometry::Dimension<double>{3.5, 2}}; -// Simulate the macro magic in Google Test internal headers +// Simulate the macro magic in Google Test internal headers. class AssertionHelper { public: AssertionHelper(const char *Message, int LineNumber) : Message(Message), LineNumber(LineNumber) {} @@ -201,7 +201,7 @@ void FunctionWithCompilerDefinedSymbol(void) { ASSERTION_HELPER("here and now"); } -// prove that integer literals introduced by the compiler are accepted silently +// Prove that integer literals introduced by the compiler are accepted silently. extern int ConsumeString(const char *Input); const char *SomeStrings[] = {"alpha", "beta", "gamma"}; @@ -215,3 +215,14 @@ int TestCheckerOverreach() { return Total; } + +// Prove that using enumerations values don't produce warnings. +enum class Letter : unsigned { + A, B, C, D, E, F, G, H, I, J +}; + +template<Letter x> struct holder { Letter letter = x; }; +template<Letter x> struct wrapper { using h_type = holder<x>; }; + +template struct wrapper<Letter::A>; +template struct wrapper<Letter::J>; |