[libcxx-commits] [PATCH] D86055: [libc++] Fix the wrong usage of __STDC_HOSTED__
hyd-dev via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 31 04:31:06 PDT 2020
hyd-dev updated this revision to Diff 288919.
hyd-dev edited the summary of this revision.
hyd-dev added a comment.
Add a test (`libcxx/test/libcxx/libcpp_freestanding.sh.cpp`).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86055/new/
https://reviews.llvm.org/D86055
Files:
libcxx/include/__config
libcxx/test/libcxx/libcpp_freestanding.sh.cpp
Index: libcxx/test/libcxx/libcpp_freestanding.sh.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/libcpp_freestanding.sh.cpp
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Test that _LIBCPP_FREESTANDING is not defined when -ffreestanding is not passed
+// to the compiler but defined when -ffreestanding is passed to the compiler.
+
+// RUN: %{cxx} %{flags} %{compile_flags} -E -dM %s | FileCheck %s
+// RUN: %{cxx} %{flags} %{compile_flags} -E -dM -ffreestanding %s | FileCheck -check-prefix=CHECK-FREESTANDING %s
+
+#include <__config>
+
+// CHECK-NOT: #define _LIBCPP_FREESTANDING
+// CHECK-FREESTANDING: #define _LIBCPP_FREESTANDING
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -38,10 +38,10 @@
# define _LIBCPP_ABI_VERSION 1
#endif
-#ifndef __STDC_HOSTED__
+#if __STDC_HOSTED__ == 0
# define _LIBCPP_FREESTANDING
#endif
#ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86055.288919.patch
Type: text/x-patch
Size: 1462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200831/4241f0af/attachment.bin>
More information about the libcxx-commits
mailing list