Skip to content

Commit 4ab37e4

Browse files
authored
[clang][Fuchsia] Use unsigned int for wint_t on *-fuchsia targets (#95499)
This aligns Fuchsia targets with other similar OS targets such as Linux. Fuchsia's libc already uses unsigned rather than the compiler-provided __WINT_TYPE__ macro for its wint_t typedef, so this just makes the compiler consistent with the OS's actual ABI. The only known manifestation of the mismatch is -Wformat warnings for %lc no matching wint_t arguments. The closest thing I could see to existing tests for each target's wint_t type setting was the predefine tests that check various macros including __WINT_TYPE__ on a per-machine and/or per-OS basis. While the setting is done per-OS in most of the target implementations rather than actually varying by machine, the only existing tests for __WINT_TYPE__ are in per-machine checks that are also wholly or partly tagged as per-OS. x86_64 and riscv64 tests for respective *-linux-gnu targets now check for the same definitions in the respective *-fuchsia targets. __WINT_TYPE__ is not among the type checked in the aarch64 tests and those lack a section that's specifically tested for aarch64-linux-gnu; if such is added then it can similarly be made to check for most or all of the same value on aarch64-fuchsia as aarch64-linux-gnu. But since the actual implementation of choosing the type is done per-OS and not per-machine for the three machines with Fuchsia target support, the x86 and riscv64 tests are already redundantly testing that same code and seem sufficient.
1 parent d890dda commit 4ab37e4

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ class LLVM_LIBRARY_VISIBILITY FuchsiaTargetInfo : public OSTargetInfo<Target> {
868868
public:
869869
FuchsiaTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
870870
: OSTargetInfo<Target>(Triple, Opts) {
871+
this->WIntType = TargetInfo::UnsignedInt;
871872
this->MCountName = "__mcount";
872873
this->TheCXXABI.set(TargetCXXABI::Fuchsia);
873874
}

clang/test/Preprocessor/init-x86.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@
999999
// X32:#define __x86_64__ 1
10001000

10011001
// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-LINUX %s
1002+
// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=x86_64-unknown-fuchsia < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-LINUX %s
10021003
//
10031004
// X86_64-LINUX:#define _LP64 1
10041005
// X86_64-LINUX:#define __BIGGEST_ALIGNMENT__ 16

clang/test/Preprocessor/init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,8 @@
25272527
// RUN: | FileCheck -match-full-lines -check-prefix=RISCV64 %s
25282528
// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv64-unknown-linux < /dev/null \
25292529
// RUN: | FileCheck -match-full-lines -check-prefixes=RISCV64,RISCV64-LINUX %s
2530+
// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv64-unknown-fuchsia < /dev/null \
2531+
// RUN: | FileCheck -match-full-lines -check-prefixes=RISCV64 %s
25302532
// RISCV64: #define _LP64 1
25312533
// RISCV64: #define __ATOMIC_ACQUIRE 2
25322534
// RISCV64: #define __ATOMIC_ACQ_REL 4

0 commit comments

Comments
 (0)