1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++98, c++03 10 11 // <filesystem> 12 13 // enum class perm_options; 14 15 #include "filesystem_include.h" 16 #include <type_traits> 17 #include <cassert> 18 #include <sys/stat.h> 19 20 #include "test_macros.h" 21 #include "check_bitmask_types.h" 22 23 24 constexpr fs::perm_options ME(int val) { 25 return static_cast<fs::perm_options>(val); 26 } 27 28 int main(int, char**) { 29 typedef fs::perm_options E; 30 static_assert(std::is_enum<E>::value, ""); 31 32 // Check that E is a scoped enum by checking for conversions. 33 typedef std::underlying_type<E>::type UT; 34 static_assert(!std::is_convertible<E, UT>::value, ""); 35 36 static_assert(std::is_same<UT, unsigned char >::value, ""); // Implementation detail 37 38 typedef check_bitmask_type<E, E::replace, E::nofollow> BitmaskTester; 39 assert(BitmaskTester::check()); 40 41 static_assert( 42 E::replace == ME(1) && 43 E::add == ME(2) && 44 E::remove == ME(4) && 45 E::nofollow == ME(8), 46 "Expected enumeration values do not match"); 47 48 return 0; 49 } 50