47 lines · cpp
1// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-11 -fexceptions -fcxx-exceptions -pedantic-errors2// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-11 -fexceptions -fcxx-exceptions -pedantic-errors3// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors4// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors5// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors6// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors7// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors8 9// cxx98-11-no-diagnostics10 11namespace cwg2335 { // cwg2335: no drafting 2018-0612// FIXME: current consensus is that the examples are well-formed.13#if __cplusplus >= 201402L14namespace ex1 {15template <class...> struct partition_indices {16 static auto compute_right() {}17 static constexpr auto right = compute_right;18};19template struct partition_indices<int>;20} // namespace ex121 22namespace ex2 {23template <int> struct X {};24template <class T> struct partition_indices {25 static auto compute_right() { return X<I>(); }26 // since-cxx14-error@-1 {{no member 'I' in 'cwg2335::ex2::partition_indices<int>'; it has not yet been instantiated}}27 // since-cxx14-note@#cwg2335-ex2-right {{in instantiation of member function 'cwg2335::ex2::partition_indices<int>::compute_right' requested here}}28 // since-cxx14-note@#cwg2335-ex2-inst {{in instantiation of template class 'cwg2335::ex2::partition_indices<int>' requested here}}29 // since-cxx14-note@#cwg2335-ex2-I {{not-yet-instantiated member is declared here}}30 static constexpr auto right = compute_right; // #cwg2335-ex2-right31 static constexpr int I = sizeof(T); // #cwg2335-ex2-I32};33template struct partition_indices<int>; // #cwg2335-ex2-inst34} // namespace ex235 36namespace ex3 {37struct partition_indices {38 static auto compute_right() {} // #cwg2335-compute_right39 static constexpr auto right = compute_right; // #cwg2335-ex3-right40 // since-cxx14-error@-1 {{function 'compute_right' with deduced return type cannot be used before it is defined}}41 // since-cxx14-note@#cwg2335-compute_right {{'compute_right' declared here}}42 // since-cxx14-error@#cwg2335-ex3-right {{declaration of variable 'right' with deduced type 'const auto' requires an initializer}}43};44} // namespace ex345#endif46} // namespace cwg233547