[clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.
authorAlexander Kornienko <alexfh@google.com>
Wed, 28 Feb 2018 10:30:25 +0000 (10:30 +0000)
committerAlexander Kornienko <alexfh@google.com>
Wed, 28 Feb 2018 10:30:25 +0000 (10:30 +0000)
llvm-svn: 326314

clang-tools-extra/test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp

index 13524de..c50b798 100644 (file)
@@ -12,6 +12,7 @@ int* functionReturningPointer();
 
 struct Struct {
   int member;
+  unsigned bitfield : 1;
 };
 
 
@@ -23,6 +24,11 @@ void regularImplicitConversionIntegerToBoolIsNotIgnored() {
 }
 
 void implicitConversionIntegerToBoolInConditionalsIsAllowed() {
+  Struct s = {};
+  if (s.member) {}
+  if (!s.member) {}
+  if (s.bitfield) {}
+  if (!s.bitfield) {}
   if (functionReturningInt()) {}
   if (!functionReturningInt()) {}
   if (functionReturningInt() && functionReturningPointer()) {}