Files
TheRock/compiler/amd-llvm/clang/test/CXX/drs/cwg12xx.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

167 lines
5.6 KiB
C++

// RUN: %clang_cc1 -std=c++98 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,cxx98-14,cxx98
// RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,cxx98-14,since-cxx11
// RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,cxx98-14,since-cxx14,since-cxx11
// RUN: %clang_cc1 -std=c++17 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx17,since-cxx14,since-cxx11
// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx17,since-cxx14,since-cxx11
// RUN: %clang_cc1 -std=c++23 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx17,since-cxx14,since-cxx11,since-cxx23
// RUN: %clang_cc1 -std=c++2c %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx17,since-cxx14,since-cxx11,since-cxx23
// cwg1200: na
namespace cwg1213 { // cwg1213: 7
#if __cplusplus >= 201103L
using T = int[3];
int &&r = T{}[1];
using T = decltype((T{}));
using U = decltype((T{}[2]));
using U = int &&;
// Same thing but in a case where we consider overloaded operator[].
struct ConvertsToInt {
operator int();
};
struct X { int array[1]; };
using U = decltype(X().array[ConvertsToInt()]);
// We apply the same rule to vector subscripting.
typedef int V4Int __attribute__((__vector_size__(sizeof(int) * 4)));
typedef int EV4Int __attribute__((__ext_vector_type__(4)));
using U = decltype(V4Int()[0]);
using U = decltype(EV4Int()[0]);
#endif
} // namespace cwg1213
namespace cwg1223 { // cwg1223: 17
#if __cplusplus >= 201103L
struct M;
template <typename T>
struct V;
struct S {
S* operator()();
int N;
int M;
#if __cplusplus >= 202302L
template <typename T>
static constexpr auto V = 0;
void f(char);
void f(int);
void mem(S s) {
auto(s)()->M;
// since-cxx23-warning@-1 {{expression result unused}}
auto(s)()->V<int>;
// since-cxx23-warning@-1 {{expression result unused}}
auto(s)()->f(0);
}
#endif
};
void f(S s) {
{
#if __cplusplus >= 202302L
auto(s)()->N;
//since-cxx23-warning@-1 {{expression result unused}}
#endif
auto(s)()->M;
}
{
S(s)()->N;
// since-cxx11-warning@-1 {{expression result unused}}
S(s)()->M;
// since-cxx11-warning@-1 {{expression result unused}}
}
}
struct A {
A(int*);
A *operator()();
};
typedef struct BB { int C[2]; } *B, C;
void g() {
A a(B ()->C);
A b(auto ()->C);
static_assert(sizeof(B ()->C[1] == sizeof(int)), "");
sizeof(auto () -> C[1]);
// since-cxx11-error@-1 {{function cannot return array type 'C[1]' (aka 'struct BB[1]')}}
}
#endif
} // namespace cwg1223
namespace cwg1227 { // cwg1227: 3.0
#if __cplusplus >= 201103L
template <class T> struct A { using X = typename T::X; };
// since-cxx11-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
// since-cxx11-note@#cwg1227-g {{in instantiation of template class 'cwg1227::A<int>' requested here}}
// since-cxx11-note@#cwg1227-g-int {{while substituting explicitly-specified template arguments into function template 'g'}}
template <class T> typename T::X f(typename A<T>::X);
template <class T> void f(...) { }
template <class T> auto g(typename A<T>::X) -> typename T::X; // #cwg1227-g
template <class T> void g(...) { }
void h() {
f<int>(0); // OK, substituting return type causes deduction to fail
g<int>(0); // #cwg1227-g-int
}
#endif
} // namespace cwg1227
namespace cwg1250 { // cwg1250: 3.9
struct Incomplete;
struct Base {
virtual const Incomplete *meow() = 0;
};
struct Derived : Base {
virtual Incomplete *meow();
};
} // namespace cwg1250
namespace cwg1265 { // cwg1265: 5
#if __cplusplus >= 201103L
auto a = 0, b() -> int;
// since-cxx11-error@-1 {{declaration with trailing return type must be the only declaration in its group}}
auto b() -> int, d = 0;
// since-cxx11-error@-1 {{declaration with trailing return type must be the only declaration in its group}}
auto e() -> int, f() -> int;
// since-cxx11-error@-1 {{declaration with trailing return type must be the only declaration in its group}}
#endif
#if __cplusplus >= 201402L
auto g(), h = 0;
// since-cxx14-error@-1 {{function with deduced return type must be the only declaration in its group}}
auto i = 0, j();
// since-cxx14-error@-1 {{function with deduced return type must be the only declaration in its group}}
auto k(), l();
// since-cxx14-error@-1 {{function with deduced return type must be the only declaration in its group}}
#endif
} // namespace cwg1265
// cwg1291: na
namespace cwg1295 { // cwg1295: 4
struct X {
unsigned bitfield : 4;
};
X x = {1};
unsigned const &r1 = static_cast<X &&>(x).bitfield;
// cxx98-error@-1 {{rvalue references are a C++11 extension}}
unsigned const &r2 = static_cast<unsigned &&>(x.bitfield);
// cxx98-error@-1 {{rvalue references are a C++11 extension}}
template<unsigned &r> struct Y {}; // #cwg1295-Y
Y<x.bitfield> y; // #cwg1295-y
// cxx98-14-error@-1 {{non-type template argument does not refer to any declaration}}
// cxx98-14-note@#cwg1295-Y {{template parameter is declared here}}
// since-cxx17-error@#cwg1295-y {{reference cannot bind to bit-field in converted constant expression}}
// since-cxx17-note@#cwg1295-Y {{template parameter is declared here}}
#if __cplusplus >= 201103L
const unsigned other = 0;
using T = decltype(true ? other : x.bitfield);
using T = unsigned;
#endif
} // namespace cwg1295