// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s // PR5908 template void Test(Iterator it) { *(it += 1); } namespace PR6045 { template class A { static const unsigned int member = r; void f(); }; template const unsigned int A::member; template void A::f() { unsigned k; (void)(k % member); } } namespace PR7198 { struct A { ~A() { } }; template struct B { struct C : A {}; void f() { C c = C(); } }; } namespace PR7724 { template int myMethod() { return 2 && sizeof(OT); } } namespace test4 { template T *addressof(T &v) { return reinterpret_cast( &const_cast(reinterpret_cast(v))); } } namespace test5 { template class chained_map { int k; void lookup() const { int &v = (int &)k; } }; } namespace test6 { template T f() { const T &v(0); return v; } int use = f(); } namespace PR8795 { template int test(_CharT t) { int data [] = { sizeof(_CharT) > sizeof(char) }; return data[0]; } } template struct CastDependentIntToPointer { static void* f() { T *x; return ((void*)(((unsigned long)(x)|0x1ul))); } }; // Regression test for crasher in r194540. namespace PR10837 { typedef void t(int); template struct A { void f(); static t g; }; t *p; template void A::f() { p = g; } template struct A; } namespace PR18152 { template struct A { static const int n = {N}; }; template struct A<0>; } template void stmt_expr_1() { static_assert( ({ false; }), "" ); } void stmt_expr_2() { static_assert( ({ false; }), "" ); // expected-error {{failed}} } namespace PR45083 { struct A { bool x; }; template struct B : A { void f() { const int n = ({ if (x) {} 0; }); } }; template void B::f(); template void f() { decltype(({})) x; // expected-error {{incomplete type}} } template void f(); // expected-note {{instantiation of}} template auto g() { auto c = [](auto, int) -> decltype(({})) {}; using T = decltype(c(0.0, 0)); using T = void; return c(0, 0); } using U = decltype(g()); // expected-note {{previous}} using U = float; // expected-error {{different types ('float' vs 'decltype(g())' (aka 'void'))}} void h(auto a, decltype(g())*) {} // expected-note {{previous}} void h(auto a, void*) {} // expected-error {{redefinition}} void i(auto a) { [](auto a, int = ({decltype(a) i; i * 2;})){}(a); // expected-error {{invalid operands to binary expression ('decltype(a)' (aka 'void *') and 'int')}} expected-note {{in instantiation of}} } void use_i() { i(0); i((void*)0); // expected-note {{instantiation of}} } } namespace BindingInStmtExpr { template struct overload : Ts... { overload(Ts ...ts) : Ts(decltype(ts)(ts))... {} using Ts::operator()...; }; template struct N {}; template auto num_bindings() { auto f0 = [](auto t, unsigned) { return N<0>(); }; auto f1 = [](auto t, int) -> decltype(({ auto [_1] = t; N<1>(); })) { return {}; }; auto f2 = [](auto t, int) -> decltype(({ auto [_1, _2] = t; N<2>(); })) { return {}; }; auto f3 = [](auto t, int) -> decltype(({ auto [_1, _2, _3] = t; N<3>(); })) { return {}; }; return decltype(overload(f0, f1, f2, f3)(T(), 0))(); } struct T { int a; int b; }; // Make sure we get a correct, non-dependent type back. using U = decltype(num_bindings()); // expected-note {{previous}} using U = N<3>; // expected-error-re {{type alias redefinition with different types ('N<3>' vs {{.*}}N<2>}} }