[libcxx-commits] [libcxx] [libcxx] [test] Fix the gets-removed.verify.cpp test with Clang 21 (PR #169235)

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Sun Nov 23 12:33:04 PST 2025


https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/169235

This fixes test errors like this, at least for a mingw target, if building with Clang 21 instead of Clang 20, as in the CI environment:

    # .---command stderr------------
    # | error: 'expected-error' diagnostics seen but not expected:
    # |   File C:\a\llvm-mingw\llvm-mingw\llvm-project\libcxx\test\std\input.output\file.streams\c.files\gets-removed.verify.cpp Line 16: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
    # | 1 error generated.
    # `-----------------------------
    # error: command failed with exit status: 1

This extra, unexpected diagnostic appears in Clang 21, since commit 9eef4d1c5fa6b1bcbbe675c14ca8301d5d346f7b ("Remove delayed typo expressions"). Before this, we got the expected diagnostic `error: no member named 'gets' in namespace 'std'`, with the typo correction hint `did you mean 'puts'?`. After this change, we get the typo correction hint `did you mean simply 'gets'?` instead. And with the typo correction finding `::gets`, it goes on to produce a second diagnostic about mismatched parameter for that function.

Avoid these unexpected diagnostics by passing the right type of parameter to the gets function.

>From 887ae4242dfc467df405b437d58fe163ec77294b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Sun, 23 Nov 2025 22:23:27 +0200
Subject: [PATCH] [libcxx] [test] Fix the gets-removed.verify.cpp test with
 Clang 21

This fixes test errors like this, at least for a mingw target,
if building with Clang 21 instead of Clang 20, as in the CI
environment:

    # .---command stderr------------
    # | error: 'expected-error' diagnostics seen but not expected:
    # |   File C:\a\llvm-mingw\llvm-mingw\llvm-project\libcxx\test\std\input.output\file.streams\c.files\gets-removed.verify.cpp Line 16: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
    # | 1 error generated.
    # `-----------------------------
    # error: command failed with exit status: 1

This extra, unexpected diagnostic appears in Clang 21, since
commit 9eef4d1c5fa6b1bcbbe675c14ca8301d5d346f7b ("Remove delayed
typo expressions"). Before this, we got the expected diagnostic
`error: no member named 'gets' in namespace 'std'`, with the
typo correction hint `did you mean 'puts'?`. After this change,
we get the typo correction hint `did you mean simply 'gets'?`
instead. And with the typo correction finding `::gets`, it goes on
to produce a second diagnostic about mismatched parameter for
that function.

Avoid these unexpected diagnostics by passing the right type of
parameter to the gets function.
---
 .../input.output/file.streams/c.files/gets-removed.verify.cpp   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/std/input.output/file.streams/c.files/gets-removed.verify.cpp b/libcxx/test/std/input.output/file.streams/c.files/gets-removed.verify.cpp
index 281ef37e92d27..fb49375a21baa 100644
--- a/libcxx/test/std/input.output/file.streams/c.files/gets-removed.verify.cpp
+++ b/libcxx/test/std/input.output/file.streams/c.files/gets-removed.verify.cpp
@@ -12,6 +12,6 @@
 
 #include <cstdio>
 
-void f(char const* str) {
+void f(char* str) {
   (void)std::gets(str); // expected-error {{no member named 'gets' in namespace 'std'}}
 }



More information about the libcxx-commits mailing list