aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2014-11-28 17:31:51 +0000
committerAlexander Kornienko <alexfh@google.com>2014-11-28 17:31:51 +0000
commitc80d8ec73c6d48fb2001b13b3c81d816c54d334e (patch)
tree5b08dda58f32ca951919acf3f3a0bc4072c8f0b7
parent9ebe7231d473693491efda4c7914afc87ae98348 (diff)
[clang-tidy] More tests for the google-explicit-constructor check
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@222924 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/clang-tidy/google-explicit-constructor.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/test/clang-tidy/google-explicit-constructor.cpp b/test/clang-tidy/google-explicit-constructor.cpp
index 7866df61..fec8debd 100644
--- a/test/clang-tidy/google-explicit-constructor.cpp
+++ b/test/clang-tidy/google-explicit-constructor.cpp
@@ -36,7 +36,6 @@ namespace std {
struct A {
A() {}
A(int x, int y) {}
- A(std::initializer_list<int> list1) {}
explicit A(void *x) {}
explicit A(void *x, void *y) {}
@@ -45,10 +44,6 @@ struct A {
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: copy constructor should not be declared explicit [google-explicit-constructor]
// CHECK-FIXES: {{^ }}A(const A& a) {}
- explicit A(std::initializer_list<double> list2) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
- // CHECK-FIXES: {{^ }}A(std::initializer_list<double> list2) {}
-
A(int x1) {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: single-argument constructors must be explicit [google-explicit-constructor]
// CHECK-FIXES: {{^ }}explicit A(int x1) {}
@@ -57,3 +52,29 @@ struct A {
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: single-argument constructors must be explicit
// CHECK-FIXES: {{^ }}explicit A(double x2, double y = 3.14) {}
};
+
+struct B {
+ B(std::initializer_list<int> list1) {}
+ B(const std::initializer_list<unsigned> &list2) {}
+ B(std::initializer_list<unsigned> &&list3) {}
+
+ explicit B(::std::initializer_list<double> list4) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
+ // CHECK-FIXES: {{^ }}B(::std::initializer_list<double> list4) {}
+
+ explicit B(const ::std::initializer_list<char> &list5) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
+ // CHECK-FIXES: {{^ }}B(const ::std::initializer_list<char> &list5) {}
+
+ explicit B(::std::initializer_list<char> &&list6) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
+ // CHECK-FIXES: {{^ }}B(::std::initializer_list<char> &&list6) {}
+};
+
+using namespace std;
+
+struct C {
+ C(initializer_list<int> list1) {}
+ C(const initializer_list<unsigned> &list2) {}
+ C(initializer_list<unsigned> &&list3) {}
+};