Skip to content

Conversation

@mstorsjo
Copy link
Member

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 9eef4d1 ("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.

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 9eef4d1 ("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.
@mstorsjo mstorsjo requested a review from a team as a code owner November 23, 2025 20:32
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 23, 2025

@llvm/pr-subscribers-libcxx

Author: Martin Storsjö (mstorsjo)

Changes

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 9eef4d1 ("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.


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

1 Files Affected:

  • (modified) libcxx/test/std/input.output/file.streams/c.files/gets-removed.verify.cpp (+1-1)
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'}}
 }

@mstorsjo
Copy link
Member Author

This fixes a new issue caught in my weekly testing of libcxx tests with a fresh nightly Clang for llvm-mingw, at https://github.com/mstorsjo/llvm-mingw/actions/runs/19612006242/job/56159201525.

@mstorsjo mstorsjo merged commit 01a98b3 into llvm:main Nov 24, 2025
73 of 74 checks passed
@mstorsjo mstorsjo deleted the libcxx-gets-verify branch November 24, 2025 21:07
aadeshps-mcw pushed a commit to aadeshps-mcw/llvm-project that referenced this pull request Nov 26, 2025
…lvm#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
9eef4d1 ("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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants