Skip to content

[Sema] Fix format-strings test on AIX#180566

Merged
luporl merged 2 commits intollvm:mainfrom
luporl:luporl-fix-fstrs-test-aix
Feb 9, 2026
Merged

[Sema] Fix format-strings test on AIX#180566
luporl merged 2 commits intollvm:mainfrom
luporl:luporl-fix-fstrs-test-aix

Conversation

@luporl
Copy link
Copy Markdown
Contributor

@luporl luporl commented Feb 9, 2026

Simplify the conditional compilation and skip the problematic warnings only on 32-bit Arm.

On AIX, long has the same size as int.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Feb 9, 2026
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Feb 9, 2026

@llvm/pr-subscribers-clang

Author: Leandro Lupori (luporl)

Changes

On AIX, long has the same size as int.


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

1 Files Affected:

  • (modified) clang/test/Sema/format-strings.c (+4-2)
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index 3a2c2701cfcfc..0c13a70fa32eb 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -988,12 +988,14 @@ void test_promotion(void) {
 
 void test_bool(_Bool b, _Bool* bp)
 {
-#if SIZE_MAX != UINT_MAX
+  // Expect a warning if size_t/ptrdiff_t size is greater than a _Bool promoted
+  // to an int or if it might be a long int, with the same size of an int.
+#if SIZE_MAX > UINT_MAX || UINT_MAX == ULONG_MAX
   printf("%zu", b); // expected-warning-re{{format specifies type 'size_t' (aka '{{.+}}') but the argument has type '_Bool'}}
 #else
   printf("%zu", b); // no-warning
 #endif
-#if PTRDIFF_MAX != INT_MAX
+#if PTRDIFF_MAX > INT_MAX || INT_MAX == LONG_MAX
   printf("%td", b); // expected-warning-re{{format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type '_Bool'}}
 #else
   printf("%td", b); // no-warning

The last change breaks ARMv7. Simplify things by skipping the
problematic warnings only on 32-bit Arm.
@luporl
Copy link
Copy Markdown
Contributor Author

luporl commented Feb 9, 2026

The code formatting failure is a GitHub issue:
github.GithubException.GithubException: 429 {"message": "This endpoint is temporarily being throttled." ... }

Copy link
Copy Markdown
Contributor

@azhan92 azhan92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@luporl luporl merged commit 8f37bf6 into llvm:main Feb 9, 2026
9 of 10 checks passed
@luporl luporl deleted the luporl-fix-fstrs-test-aix branch February 9, 2026 21:42
tbaederr added a commit to tbaederr/llvm-project that referenced this pull request Feb 17, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
```
tbaederr added a commit to tbaederr/llvm-project that referenced this pull request Feb 17, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
```
tbaederr added a commit to tbaederr/llvm-project that referenced this pull request Feb 17, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
```
tbaederr added a commit to tbaederr/llvm-project that referenced this pull request Feb 17, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
```
tbaederr added a commit to tbaederr/llvm-project that referenced this pull request Feb 17, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
```
@amy-kwan amy-kwan added this to the LLVM 22.x Release milestone Feb 22, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Feb 22, 2026
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in LLVM Release Status Feb 22, 2026
@amy-kwan
Copy link
Copy Markdown
Member

Caught this failure a bit late for the release, so I will attempt to cherry-pick it.
/cherry-pick 8f37bf6

@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Feb 22, 2026

/pull-request #182755

@mgorny
Copy link
Copy Markdown
Member

mgorny commented Feb 23, 2026

Sorry to be late to the party but this change breaks tests on 32-bit x86 Linux:

FAIL: Clang :: Sema/format-strings.c (19698 of 24038)
******************** TEST 'Clang :: Sema/format-strings.c' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/var/tmp/portage/llvm-core/clang-23.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/clang -cc1 -internal-isystem /var/tmp/portage/llvm-core/
clang-23.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/23/include -nostdsysteminc -fblocks -fsyntax-only -verify -Wf
ormat-nonliteral -isystem /var/tmp/portage/llvm-core/clang-23.0.0.9999/work/clang/test/Sema/Inputs /var/tmp/portage/llvm-core/clang-23.
0.0.9999/work/clang/test/Sema/format-strings.c
# executed command: /var/tmp/portage/llvm-core/clang-23.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/clang -cc1 -internal-isystem /var/tm
p/portage/llvm-core/clang-23.0.0.9999/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/23/include -nostdsysteminc -fblocks -fsyn
tax-only -verify -Wformat-nonliteral -isystem /var/tmp/portage/llvm-core/clang-23.0.0.9999/work/clang/test/Sema/Inputs /var/tmp/portage
/llvm-core/clang-23.0.0.9999/work/clang/test/Sema/format-strings.c
# .---command stderr------------
# | error: 'expected-warning' diagnostics expected but not seen: 
# |   File /var/tmp/portage/llvm-core/clang-23.0.0.9999/work/clang/test/Sema/format-strings.c Line 990: format specifies type 'size_t' 
(aka '{{.+}}') but the argument has type '_Bool'
# |   File /var/tmp/portage/llvm-core/clang-23.0.0.9999/work/clang/test/Sema/format-strings.c Line 991: format specifies type 'ptrdiff_
t' (aka '{{.+}}') but the argument has type '_Bool'
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

--

********************

@nikic
Copy link
Copy Markdown
Contributor

nikic commented Feb 23, 2026

Can you please explain what the issue on AIX actually was?

@nikic
Copy link
Copy Markdown
Contributor

nikic commented Feb 23, 2026

@mgorny There is a PR to fix i686 at #181800.

@mgorny
Copy link
Copy Markdown
Member

mgorny commented Feb 23, 2026

@mgorny There is a PR to fix i686 at #181800.

… which pretty much reverts the change here, except for using another define.

@luporl
Copy link
Copy Markdown
Contributor Author

luporl commented Feb 23, 2026

Can you please explain what the issue on AIX actually was?

The issue on AIX was reported here: #178450 (comment)

File /home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/Sema/format-strings.c Line 994: format specifies type 'size_t' (aka 'unsigned long') but the argument has type '_Bool'
File /home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/Sema/format-strings.c Line 999: format specifies type 'ptrdiff_t' (aka 'long') but the argument has type '_Bool'

AFAIK, the problem is that on PPC64 AIX both integers and longs have 64 bits and size_t/ptrdiff_t are long.
Because of this the warnings still occur after _Bool is promoted to int. It has the same size as long, but it's still a different type.

@nikic
Copy link
Copy Markdown
Contributor

nikic commented Feb 23, 2026

Looking at that buildbot, the triple it actually uses is powerpc-ibm-aix, even though the buildbot name is clang-ppc64-aix. And yes, for 32-bit AIX we have that size_t is long, which is the same size as int.

I think the right fix for the issue is to just drop the no-warning lines, as I've suggested here: https://github.com/llvm/llvm-project/pull/181800/changes#r2840874528 If the sizes don't match there should definitely be a warning. If they do match, then it depends on the exact type definitions, and we shouldn't test either way.

(Though at a higher level, if we ignore the immediate test issue here, IMHO, for this specific case of _Bool we should really be always warning regardless of what the underlying type definitions are. Using _Bool with %zu is both non-sensical and non-portable.)

tbaederr added a commit to tbaederr/llvm-project that referenced this pull request Feb 23, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
```
tbaederr added a commit that referenced this pull request Feb 23, 2026
#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
# .---command stderr------------
# | error: 'expected-warning' diagnostics expected but not seen: 
# |   File /builddir/build/BUILD/llvm-project/clang/test/Sema/format-strings.c Line 990: format specifies type 'size_t' (aka '{{.+}}') but the argument has type '_Bool'
# |   File /builddir/build/BUILD/llvm-project/clang/test/Sema/format-strings.c Line 991: format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type '_Bool'
# | 2 errors generated.
# `-----------------------------
```
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 23, 2026
…81800)

llvm/llvm-project#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
# .---command stderr------------
# | error: 'expected-warning' diagnostics expected but not seen:
# |   File /builddir/build/BUILD/llvm-project/clang/test/Sema/format-strings.c Line 990: format specifies type 'size_t' (aka '{{.+}}') but the argument has type '_Bool'
# |   File /builddir/build/BUILD/llvm-project/clang/test/Sema/format-strings.c Line 991: format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type '_Bool'
# | 2 errors generated.
# `-----------------------------
```
HendrikHuebner pushed a commit to HendrikHuebner/llvm-project that referenced this pull request Mar 10, 2026
llvm#180566 did this for 32bit arm,
but this still breaks for us downstream on i686 with:
```
# .---command stderr------------
# | error: 'expected-warning' diagnostics expected but not seen: 
# |   File /builddir/build/BUILD/llvm-project/clang/test/Sema/format-strings.c Line 990: format specifies type 'size_t' (aka '{{.+}}') but the argument has type '_Bool'
# |   File /builddir/build/BUILD/llvm-project/clang/test/Sema/format-strings.c Line 991: format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type '_Bool'
# | 2 errors generated.
# `-----------------------------
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

Development

Successfully merging this pull request may close these issues.

6 participants