Enable warnings by default for C++ >= 11 and fix -Wshadow occurances
authorEric Fiselier <eric@efcs.ca>
Sat, 3 Dec 2016 00:27:13 +0000 (00:27 +0000)
committerEric Fiselier <eric@efcs.ca>
Sat, 3 Dec 2016 00:27:13 +0000 (00:27 +0000)
llvm-svn: 288557

libcxx/test/libcxx/test/config.py
libcxx/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp
libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/c_str.pass.cpp
libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/native.pass.cpp
libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/operator_string.pass.cpp
libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
libcxx/test/std/experimental/memory/memory.resource/memory.resource.public/allocate.pass.cpp
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp

index 9449959..4a2c1d7 100644 (file)
@@ -640,8 +640,7 @@ class Configuration(object):
                 '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
                 '-Wall', '-Wextra', '-Werror'
             ]
-            # FIXME turn this back on after fixing potential breakage.
-            #self.cxx.addWarningFlagIfSupported('-Wshadow')
+            self.cxx.addWarningFlagIfSupported('-Wshadow')
             self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
             self.cxx.addWarningFlagIfSupported('-Wno-attributes')
             self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
@@ -649,10 +648,10 @@ class Configuration(object):
             self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
             # TODO(EricWF) Remove the unused warnings once the test suite
             # compiles clean with them.
+            self.cxx.addWarningFlagIfSupported('-Wno-sign-compare')
             self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
             self.cxx.addWarningFlagIfSupported('-Wno-unused-variable')
             self.cxx.addWarningFlagIfSupported('-Wno-unused-parameter')
-            self.cxx.addWarningFlagIfSupported('-Wno-sign-compare')
             std = self.get_lit_conf('std', None)
             if std in ['c++98', 'c++03']:
                 # The '#define static_assert' provided by libc++ in C++03 mode
index a6becb1..830e812 100644 (file)
@@ -87,9 +87,10 @@ TEST_CASE(access_denied_test_case)
     env.create_file(testFile, 42);
 
     // Test that we can iterator over the directory before changing the perms
-    directory_iterator it(testDir);
-    TEST_REQUIRE(it != directory_iterator{});
-
+    {
+        directory_iterator it(testDir);
+        TEST_REQUIRE(it != directory_iterator{});
+    }
     // Change the permissions so we can no longer iterate
     permissions(testDir, perms::none);
 
index 5be9349..7881c97 100644 (file)
@@ -28,7 +28,6 @@ namespace fs = std::experimental::filesystem;
 
 int main() {
   using namespace fs;
-  const path p("/foo/bar/baz");
   {
     path p;
     ASSERT_NOEXCEPT(p.clear());
@@ -37,6 +36,7 @@ int main() {
     assert(p.empty());
   }
   {
+    const path p("/foo/bar/baz");
     path p2(p);
     assert(p == p2);
     p2.clear();
index 7cf3564..7966094 100644 (file)
@@ -30,8 +30,8 @@ int main()
   using namespace fs;
   const char* const value = "hello world";
   const std::string str_value = value;
-  path p(value);
   { // Check signature
+    path p(value);
     ASSERT_SAME_TYPE(path::value_type const*, decltype(p.c_str()));
     ASSERT_NOEXCEPT(p.c_str());
   }
index 7f8df27..db13264 100644 (file)
@@ -28,8 +28,8 @@ int main()
 {
   using namespace fs;
   const char* const value = "hello world";
-  path p(value);
   { // Check signature
+    path p(value);
     ASSERT_SAME_TYPE(path::string_type const&, decltype(p.native()));
     ASSERT_NOEXCEPT(p.native());
   }
index 9ef83f9..013d26c 100644 (file)
@@ -30,8 +30,8 @@ int main()
   using namespace fs;
   using string_type = path::string_type;
   const char* const value = "hello world";
-  path p(value);
   { // Check signature
+    path p(value);
     static_assert(std::is_convertible<path, string_type>::value, "");
     static_assert(std::is_constructible<string_type, path>::value, "");
     ASSERT_SAME_TYPE(string_type, decltype(p.operator string_type()));
index 1cddccd..8f6009d 100644 (file)
@@ -91,8 +91,10 @@ TEST_CASE(access_denied_test_case)
     env.create_file(testFile, 42);
 
     // Test that we can iterator over the directory before changing the perms
-    RDI it(testDir);
-    TEST_REQUIRE(it != RDI{});
+    {
+        RDI it(testDir);
+        TEST_REQUIRE(it != RDI{});
+    }
 
     // Change the permissions so we can no longer iterate
     permissions(testDir, perms::none);
index 26cf903..efb529b 100644 (file)
@@ -73,8 +73,8 @@ int main()
 #ifndef TEST_HAS_NO_EXCEPTIONS
     {
         TestResource R2;
-        auto& P = R2.getController();
-        P.throw_on_alloc = true;
+        auto& P2 = R2.getController();
+        P2.throw_on_alloc = true;
         memory_resource& M2 = R2;
         try {
             M2.allocate(42);
index 928da00..bf7a8e3 100644 (file)
@@ -18,9 +18,7 @@
 
 #include <iterator>
 #include <cassert>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #include <memory>
-#endif
 
 #include "test_macros.h"
 #include "test_iterators.h"
@@ -36,29 +34,28 @@ test(It i, typename std::iterator_traits<It>::difference_type n,
     assert(rr == x);
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 struct do_nothing
 {
     void operator()(void*) const {}
 };
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 int main()
 {
-    char s[] = "1234567890";
-    test(random_access_iterator<char*>(s+5), 4, '0');
-    test(s+5, 4, '0');
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    int i[5];
-    typedef std::unique_ptr<int, do_nothing> Ptr;
-    Ptr p[5];
-    for (unsigned j = 0; j < 5; ++j)
-        p[j].reset(i+j);
-    test(p, 3, Ptr(i+3));
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
+    {
+        char s[] = "1234567890";
+        test(random_access_iterator<char*>(s+5), 4, '0');
+        test(s+5, 4, '0');
+    }
+#if TEST_STD_VER >= 11
+    {
+        int i[5];
+        typedef std::unique_ptr<int, do_nothing> Ptr;
+        Ptr p[5];
+        for (unsigned j = 0; j < 5; ++j)
+            p[j].reset(i+j);
+        test(p, 3, Ptr(i+3));
+    }
+#endif
 #if TEST_STD_VER > 14
     {
     constexpr const char *p = "123456789";
index 5665cb8..4c5d816 100644 (file)
@@ -17,9 +17,7 @@
 
 #include <iterator>
 #include <cassert>
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #include <memory>
-#endif
 
 #include "test_macros.h"
 
@@ -44,25 +42,25 @@ test(It i, typename std::iterator_traits<It>::value_type x)
     assert(x2 == x);
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 struct do_nothing
 {
     void operator()(void*) const {}
 };
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 int main()
 {
-    A a;
-    test(&a, A());
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-    int i;
-    std::unique_ptr<int, do_nothing> p(&i);
-    test(&p, std::unique_ptr<int, do_nothing>(&i));
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
+    {
+        A a;
+        test(&a, A());
+    }
+#if TEST_STD_VER >= 11
+    {
+        int i;
+        std::unique_ptr<int, do_nothing> p(&i);
+        test(&p, std::unique_ptr<int, do_nothing>(&i));
+    }
+#endif
 #if TEST_STD_VER > 14
     {
     constexpr const char *p = "123456789";