Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 15 additions & 4 deletions clang/test/SemaCXX/cxx98-compat.cpp
Original file line number Diff line number Diff line change
@@ -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++11 -Wc++98-compat -verify=expected,not-cpp20 %s
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify=expected,not-cpp20 %s -DCXX14COMPAT
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-compat -verify=expected,not-cpp20 %s -DCXX14COMPAT -DCXX17COMPAT
// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wc++98-compat -verify=expected,cpp20 %s -DCXX14COMPAT -DCXX17COMPAT

namespace std {
struct type_info;
Expand Down Expand Up @@ -226,7 +227,8 @@ void TrivialButNonPODThroughEllipsis() {
}

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

struct Struct {};
Expand Down Expand Up @@ -430,3 +432,12 @@ void ctad_test() {
CTAD t = s; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}}
}
#endif

namespace GH161702 {
struct S {
enum E { A };
using E::A; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
// not-cpp20-error@-1 {{using declaration refers to its own class}}
// cpp20-warning@-2 {{member using declaration naming non-class ''E'' enumerator is incompatible with C++ standards before C++20}}
};
}