mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 17:46:40 +00:00
[libc++] Fix incorrect usage of __STDC_HOSTED__
D56913 introduced the _LIBCPP_FREESTANDING macro and guarded its definition by: #ifndef __STDC_HOSTED__ # define _LIBCPP_FREESTANDING #endif However, __STDC_HOSTED__ is defined as 0 in freestanding implementations instead of undefined, which means that _LIBCPP_FREESTANDING would never get defined. This patch corrects the above as: #if __STDC_HOSTED__ == 0 # define _LIBCPP_FREESTANDING #endif Differential Revision: https://reviews.llvm.org/D86055
This commit is contained in:
parent
5201b962e8
commit
44cc78da05
@ -38,7 +38,7 @@
|
||||
# define _LIBCPP_ABI_VERSION 1
|
||||
#endif
|
||||
|
||||
#ifndef __STDC_HOSTED__
|
||||
#if __STDC_HOSTED__ == 0
|
||||
# define _LIBCPP_FREESTANDING
|
||||
#endif
|
||||
|
||||
|
21
libcxx/test/libcxx/libcpp_freestanding.sh.cpp
Normal file
21
libcxx/test/libcxx/libcpp_freestanding.sh.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- 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} -fsyntax-only %s
|
||||
// RUN: %{cxx} %{flags} %{compile_flags} -fsyntax-only -ffreestanding -DFREESTANDING %s
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if defined(FREESTANDING) != defined(_LIBCPP_FREESTANDING)
|
||||
#error _LIBCPP_FREESTANDING should be defined in freestanding mode and not \
|
||||
defined in non-freestanding mode
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user