diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp b/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp index 6cc3435b9b8..aac6ab62bd2 100644 --- a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp @@ -138,3 +138,35 @@ void f(std::initializer_list<int> list) { E<decltype(list)> e(list); E<int> e2(list); } + +template <typename T> +struct F {}; + +template<typename T> +struct G { + operator bool() const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator bool' must be marked + // CHECK-FIXES: {{^}} explicit operator bool() const; + operator F<T>() const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator F<type-parameter-0-0>' must be marked + // CHECK-FIXES: {{^}} explicit operator F<T>() const; + template<typename U> + operator F<U>*() const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator F<type-parameter-1-0> *' must be marked + // CHECK-FIXES: {{^}} explicit operator F<U>*() const; +}; + +void f2() { + G<int> a; + (void)(F<int>)a; + if (a) {} + (void)(F<int>*)a; + (void)(F<int*>*)a; + + G<double> b; + (void)(F<double>)b; + if (b) {} + (void)(F<double>*)b; + (void)(F<double*>*)b; + +} |