Skip to content

[libc++][modules] Don't error when including <wchar.h> or <wctype.h> without wide character support #108639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Sep 13, 2024

Instead, make the headers empty like we do for all the other carve-outs.

@ldionne ldionne requested a review from a team as a code owner September 13, 2024 19:55
@ldionne ldionne changed the title [libc++] Don't error when including <wchar.h> or <wctype.h> without wide character support [libc++][modules] Don't error when including <wchar.h> or <wctype.h> without wide character support Sep 13, 2024
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

Instead, make the headers empty like we do for all the other carve-outs.


Full diff: https://github.com/llvm/llvm-project/pull/108639.diff

4 Files Affected:

  • (modified) libcxx/include/wchar.h (+6-9)
  • (modified) libcxx/include/wctype.h (-5)
  • (modified) libcxx/test/std/depr/depr.c.headers/wctype_h.compile.pass.cpp (+1-1)
  • (modified) libcxx/test/std/strings/c.strings/cwctype.pass.cpp (+1-1)
diff --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h
index d4268c6d2c2442..c965b28e57c6c7 100644
--- a/libcxx/include/wchar.h
+++ b/libcxx/include/wchar.h
@@ -108,11 +108,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
 #  include <__config>
 #  include <stddef.h>
 
-#  if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-#    error                                                                                                             \
-        "The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
-#  endif
-
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #    pragma GCC system_header
 #  endif
@@ -142,7 +137,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
 #    endif
 #  endif
 
-#  if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
+#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#    if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
 extern "C++" {
 inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {
   return (wchar_t*)wcschr(__s, __c);
@@ -197,15 +193,16 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD wchar_t* wmemchr(wchar_t
   return __libcpp_wmemchr(__s, __c, __n);
 }
 }
-#  endif
+#    endif
 
-#  if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
+#    if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
 extern "C" {
 size_t mbsnrtowcs(
     wchar_t* __restrict __dst, const char** __restrict __src, size_t __nmc, size_t __len, mbstate_t* __restrict __ps);
 size_t wcsnrtombs(
     char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps);
 } // extern "C"
-#  endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
+#    endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
+#  endif   // !_LIBCPP_HAS_NO_WIDE_CHARACTERS
 
 #endif // _LIBCPP_WCHAR_H
diff --git a/libcxx/include/wctype.h b/libcxx/include/wctype.h
index c76ec5a3f06085..9f378eaf8202a1 100644
--- a/libcxx/include/wctype.h
+++ b/libcxx/include/wctype.h
@@ -46,11 +46,6 @@ wctrans_t wctrans(const char* property);
 
 #include <__config>
 
-#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-#  error                                                                                                               \
-      "The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
diff --git a/libcxx/test/std/depr/depr.c.headers/wctype_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/wctype_h.compile.pass.cpp
index 094f7713bb365c..35b294532b2bd2 100644
--- a/libcxx/test/std/depr/depr.c.headers/wctype_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/wctype_h.compile.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: no-wide-characters
+// UNSUPPORTED: no-wide-characters
 
 // <wctype.h>
 
diff --git a/libcxx/test/std/strings/c.strings/cwctype.pass.cpp b/libcxx/test/std/strings/c.strings/cwctype.pass.cpp
index d421bea5a5672a..5bc2531d6f6ac7 100644
--- a/libcxx/test/std/strings/c.strings/cwctype.pass.cpp
+++ b/libcxx/test/std/strings/c.strings/cwctype.pass.cpp
@@ -8,7 +8,7 @@
 
 // <cwctype>
 
-// XFAIL: no-wide-characters
+// UNSUPPORTED: no-wide-characters
 
 #include <cwctype>
 #include <type_traits>

…ide character support

Instead, make the headers empty like we do for all the other carve-outs.
@ldionne ldionne force-pushed the review/modularization-no-wide-chars branch from 53e43a5 to dc7bfaa Compare September 16, 2024 12:26
@ldionne ldionne merged commit 165f0e8 into llvm:main Sep 16, 2024
58 of 60 checks passed
@ldionne ldionne deleted the review/modularization-no-wide-chars branch September 16, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants