Skip to content

Commit 32d03f3

Browse files
authored
[Clang][Sema] Fix crash in CheckUsingDeclQualifier due to diagnostic missing an argument (#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: #161072
1 parent a3594cd commit 32d03f3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

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

1366113661
if (Cxx20Enumerator) {
1366213662
Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
13663-
<< SS.getRange();
13663+
<< SS.getScopeRep() << SS.getRange();
1366413664
return false;
1366513665
}
1366613666

clang/test/SemaCXX/cxx98-compat.cpp

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

56
namespace std {
67
struct type_info;
@@ -226,7 +227,8 @@ void TrivialButNonPODThroughEllipsis() {
226227
}
227228

228229
struct HasExplicitConversion {
229-
explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
230+
// FIXME I think we should generate this diagnostic in C++20
231+
explicit operator bool(); // not-cpp20-warning {{explicit conversion functions are incompatible with C++98}}
230232
};
231233

232234
struct Struct {};
@@ -430,3 +432,12 @@ void ctad_test() {
430432
CTAD t = s; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}}
431433
}
432434
#endif
435+
436+
namespace GH161702 {
437+
struct S {
438+
enum E { A };
439+
using E::A; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
440+
// not-cpp20-error@-1 {{using declaration refers to its own class}}
441+
// cpp20-warning@-2 {{member using declaration naming non-class ''E'' enumerator is incompatible with C++ standards before C++20}}
442+
};
443+
}

0 commit comments

Comments
 (0)