Skip to content

Conversation

shafik
Copy link
Collaborator

@shafik shafik commented Sep 29, 2025

Crash report came in and it was pretty obvious the diagnostic line was just missing an argument. I supplied the argument and added a test.

Fixes: #161072

…missing an argument

Crash report came in and it was pretty obvious the diagnostic line was just
missing an argument. I supplied the argument and added a test.

Fixes: llvm#161072
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

Crash report came in and it was pretty obvious the diagnostic line was just missing an argument. I supplied the argument and added a test.

Fixes: #161072


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

2 Files Affected:

  • (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1)
  • (modified) clang/test/SemaCXX/cxx98-compat.cpp (+4)
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 63ce87b9b0607..7fa411fd817ae 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -13643,7 +13643,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
 
     if (Cxx20Enumerator) {
       Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
-          << SS.getRange();
+          << SS.getScopeRep() << SS.getRange();
       return false;
     }
 
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
index 8e7acf73923e5..5651eee5a5c41 100644
--- a/clang/test/SemaCXX/cxx98-compat.cpp
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify %s -DCXX14COMPAT
 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-compat -verify %s -DCXX14COMPAT -DCXX17COMPAT
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++98-compat -verify %s -DCXX14COMPAT -DCXX17COMPAT -DCXX20COMPAT
 
 namespace std {
   struct type_info;
@@ -225,9 +226,12 @@ void TrivialButNonPODThroughEllipsis() {
   Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}}
 }
 
+// FIXME I think we generate this diagnostic in C++20
+#ifndef CXX20COMPAT
 struct HasExplicitConversion {
   explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
 };
+#endif
 
 struct Struct {};
 enum Enum { enum_val = 0 };

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

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

Did you forget the test? Ingeneral I don't mind this, but the only test changes are a weird C++98 compat one.

@shafik
Copy link
Collaborator Author

shafik commented Sep 29, 2025

Did you forget the test? Ingeneral I don't mind this, but the only test changes are a weird C++98 compat one.

Oppss, yeah I did.

@shafik shafik merged commit 32d03f3 into llvm:main Oct 2, 2025
9 checks passed
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…missing an argument (llvm#161277)

Crash report came in and it was pretty obvious the diagnostic line was
just missing an argument. I supplied the argument and added a test.

Fixes: llvm#161072
@shafik shafik deleted the fix_cxx_compat_diag_using_decl_non_member_missing_arg branch October 3, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[clang] Assertion `Idx < getNumArgs() && "Argument index out of range!"' failed.
3 participants