summaryrefslogtreecommitdiffstats
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
commit18bc3bf830a88fc7d745a97c2e9ff5288628da5c (patch)
treea52bcaf1c604bc0ef853b5b03505acbfe7e8dbc1
parenta96f235c157c40b58e12e813faf97d8bc1004aa2 (diff)
downloadbcm5719-llvm-18bc3bf830a88fc7d745a97c2e9ff5288628da5c.tar.gz
bcm5719-llvm-18bc3bf830a88fc7d745a97c2e9ff5288628da5c.zip
[clang-tidy] More tests for the google-explicit-constructor check
llvm-svn: 222924
-rw-r--r--clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp31
1 files changed, 26 insertions, 5 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 7866df61720..fec8debd436 100644
--- a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp
+++ b/clang-tools-extra/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) {}
+};
OpenPOWER on IntegriCloud