Skip to content

Commit 227d45e

Browse files
committed
[Clang][Sema] Fix crash in CheckUsingDeclQualifier due to diagnostic 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: #161072
1 parent 0dbea52 commit 227d45e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13643,7 +13643,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
1364313643

1364413644
if (Cxx20Enumerator) {
1364513645
Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
13646-
<< SS.getRange();
13646+
<< SS.getScopeRep() << SS.getRange();
1364713647
return false;
1364813648
}
1364913649

clang/test/SemaCXX/cxx98-compat.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
22
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify %s -DCXX14COMPAT
33
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-compat -verify %s -DCXX14COMPAT -DCXX17COMPAT
4+
// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++98-compat -verify %s -DCXX14COMPAT -DCXX17COMPAT -DCXX20COMPAT
45

56
namespace std {
67
struct type_info;
@@ -225,9 +226,12 @@ void TrivialButNonPODThroughEllipsis() {
225226
Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}}
226227
}
227228

229+
// FIXME I think we generate this diagnostic in C++20
230+
#ifndef CXX20COMPAT
228231
struct HasExplicitConversion {
229232
explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
230233
};
234+
#endif
231235

232236
struct Struct {};
233237
enum Enum { enum_val = 0 };

0 commit comments

Comments
 (0)