https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/95497
Also drop irrelevant function attributes from tests. >From c4e8968197c401f03baaed904d07a5ce77c19ace Mon Sep 17 00:00:00 2001 From: Roland McGrath <mcgra...@google.com> Date: Thu, 13 Jun 2024 20:25:24 -0700 Subject: [PATCH] [clang][Fuchsia] Use unsigned int for wint_t on *-fuchsia targets 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. --- clang/lib/Basic/Targets/OSTargets.h | 1 + clang/test/Preprocessor/init-x86.c | 1 + clang/test/Preprocessor/init.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 4366c1149e405..5f27c3469f861 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -868,6 +868,7 @@ class LLVM_LIBRARY_VISIBILITY FuchsiaTargetInfo : public OSTargetInfo<Target> { public: FuchsiaTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { + this->WIntType = TargetInfo::UnsignedInt; this->MCountName = "__mcount"; this->TheCXXABI.set(TargetCXXABI::Fuchsia); } diff --git a/clang/test/Preprocessor/init-x86.c b/clang/test/Preprocessor/init-x86.c index 1268419e18a5c..6f5aa5674e48e 100644 --- a/clang/test/Preprocessor/init-x86.c +++ b/clang/test/Preprocessor/init-x86.c @@ -999,6 +999,7 @@ // X32:#define __x86_64__ 1 // 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 +// 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 // // X86_64-LINUX:#define _LP64 1 // X86_64-LINUX:#define __BIGGEST_ALIGNMENT__ 16 diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 2641fee940231..6e7c0ea5c730b 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -2527,6 +2527,8 @@ // RUN: | FileCheck -match-full-lines -check-prefix=RISCV64 %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv64-unknown-linux < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=RISCV64,RISCV64-LINUX %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv64-unknown-fuchsia < /dev/null \ +// RUN: | FileCheck -match-full-lines -check-prefixes=RISCV64 %s // RISCV64: #define _LP64 1 // RISCV64: #define __ATOMIC_ACQUIRE 2 // RISCV64: #define __ATOMIC_ACQ_REL 4 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits