Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p14-ir.cpp
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - %s | FileCheck %s // Copy constructor struct X0 { X0(); X0(const X0 &) throw(); X0(X0 &); }; struct X1 { X1(); X1(const X1 &) throw(); }; struct X2 : X1 { X2(); }; struct X3 : X0, X1 { X3(); }; struct X4 { X4(X4 &) throw(); }; struct X5 : X0, X4 { }; void test(X2 x2, X3 x3, X5 x5) { // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* %this, %struct.X2* dereferenceable({{[0-9]+}})) unnamed_addr // CHECK: call void @_ZN2X2C2ERKS_({{.*}}) [[NUW:#[0-9]+]] // CHECK-NEXT: ret void // CHECK-NEXT: } X2 x2a(x2); // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* %this, %struct.X3* dereferenceable({{[0-9]+}})) unnamed_addr // CHECK: call void @_ZN2X3C2ERKS_({{.*}}) [[NUW]] // CHECK-NEXT: ret void // CHECK-NEXT: } X3 x3a(x3); // CHECK: define linkonce_odr void @_ZN2X5C1ERS_({{.*}}) unnamed_addr // CHECK-NOT: call void @__cxa_call_unexpected // CHECK: ret void X5 x5a(x5); } // Default constructor struct X6 { X6() throw(); }; struct X7 { X7(); }; struct X8 : X6 { }; struct X9 : X6, X7 { }; void test() { // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X8* %this) unnamed_addr // CHECK: call void @_ZN2X8C2Ev({{.*}}) [[NUW]] // CHECK-NEXT: ret void X8(); // CHECK: define linkonce_odr void @_ZN2X9C1Ev(%struct.X9* %this) unnamed_addr // FIXME: check that this is the end of the line here: // CHECK: call void @_ZN2X9C2Ev({{.*}}) // CHECK-NEXT: ret void X9(); // CHECK: define linkonce_odr void @_ZN2X8C2Ev(%struct.X8* %this) unnamed_addr // CHECK: call void @_ZN2X6C2Ev({{.*}}) [[NUW]] // CHECK-NEXT: ret void // CHECK: define linkonce_odr void @_ZN2X9C2Ev(%struct.X9* %this) unnamed_addr // CHECK: call void @_ZN2X6C2Ev({{.*}}) [[NUW]] // FIXME: and here: // CHECK-NEXT: bitcast // CHECK-NEXT: call void @_ZN2X7C2Ev({{.*}}) // CHECK: ret void } // CHECK: attributes [[NUW]] = { nounwind{{.*}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p15.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // RUN: %clang_cc1 -DUSE -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // Maybe force the implicit declaration of 'operator delete' and 'operator // delete[]'. This should make no difference to anything! #ifdef USE void f(int *p) { delete p; delete [] p; } #endif // Deallocation functions are implicitly noexcept. // Thus, explicit specs aren't allowed to conflict. void operator delete(void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} void operator delete[](void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} static_assert(noexcept(operator delete(0)), ""); static_assert(noexcept(operator delete[](0)), ""); // Same goes for explicit declarations. void operator delete(void*, float); void operator delete[](void*, float); static_assert(noexcept(operator delete(0, 0.f)), ""); static_assert(noexcept(operator delete[](0, 0.f)), ""); // But explicit specs stay. void operator delete(void*, double) throw(int); // expected-note {{previous}} static_assert(!noexcept(operator delete(0, 0.)), ""); void operator delete(void*, double) noexcept; // expected-error {{does not match}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp
// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // Dynamic specifications: valid types. struct Incomplete; // expected-note 3 {{forward declaration}} // Exception spec must not have incomplete types, or pointers to them, except // void. void ic1() throw(void); // expected-error {{incomplete type 'void' is not allowed in exception specification}} void ic2() throw(Incomplete); // expected-error {{incomplete type 'Incomplete' is not allowed in exception specification}} void ic3() throw(void*); void ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'Incomplete' is not allowed in exception specification}} void ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'Incomplete' is not allowed in exception specification}} // Don't suppress errors in template instantiation. template <typename T> struct TEx; // expected-note {{template is declared here}} void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}} // DR 437, class throws itself. struct DR437 { void f() throw(DR437); void g() throw(DR437*); void h() throw(DR437&); }; // DR 437 within a nested class struct DR437_out { struct DR437_in { void f() throw(DR437_out); void g() throw(DR437_out*); void h() throw(DR437_out&); }; };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p5-virtual.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // Compatibility of virtual functions. struct A { }; struct B1 : A { }; struct B2 : A { }; struct D : B1, B2 { }; struct P : private A { }; struct Base { virtual void f1() throw(); virtual void f2() throw(int, float); virtual void f3() throw(int, float); virtual void f4() throw(A); virtual void f5() throw(A, int, float); virtual void f6(); virtual void f7() noexcept; virtual void f8() noexcept; virtual void f9() noexcept(false); virtual void f10() noexcept(false); virtual void f11() throw(); virtual void f12() noexcept; virtual void f13() noexcept(false); virtual void f14() throw(int); virtual void f15(); virtual void f16(); virtual void g1() throw(); // expected-note {{overridden virtual function is here}} virtual void g2() throw(int); // expected-note {{overridden virtual function is here}} virtual void g3() throw(A); // expected-note {{overridden virtual function is here}} virtual void g4() throw(B1); // expected-note {{overridden virtual function is here}} virtual void g5() throw(A); // expected-note {{overridden virtual function is here}} virtual void g6() noexcept; // expected-note {{overridden virtual function is here}} virtual void g7() noexcept; // expected-note {{overridden virtual function is here}} virtual void g8() noexcept; // expected-note {{overridden virtual function is here}} virtual void g9() throw(); // expected-note {{overridden virtual function is here}} virtual void g10() throw(int); // expected-note {{overridden virtual function is here}} }; struct Derived : Base { virtual void f1() throw(); virtual void f2() throw(float, int); virtual void f3() throw(float); virtual void f4() throw(B1); virtual void f5() throw(B1, B2, int); virtual void f6() throw(B2, B2, int, float, char, double, bool); virtual void f7() noexcept; virtual void f8() noexcept(true); virtual void f9() noexcept(true); virtual void f10() noexcept(false); virtual void f11() noexcept; virtual void f12() throw(); virtual void f13() throw(int); virtual void f14() noexcept(true); virtual void f15() noexcept; virtual void f16() throw(); virtual void g1() throw(int); // expected-error {{exception specification of overriding function is more lax}} virtual void g2(); // expected-error {{exception specification of overriding function is more lax}} virtual void g3() throw(D); // expected-error {{exception specification of overriding function is more lax}} virtual void g4() throw(A); // expected-error {{exception specification of overriding function is more lax}} virtual void g5() throw(P); // expected-error {{exception specification of overriding function is more lax}} virtual void g6() noexcept(false); // expected-error {{exception specification of overriding function is more lax}} virtual void g7(); // expected-error {{exception specification of overriding function is more lax}} virtual void g8() throw(int); // expected-error {{exception specification of overriding function is more lax}} virtual void g9() noexcept(false); // expected-error {{exception specification of overriding function is more lax}} virtual void g10() noexcept(false); // expected-error {{exception specification of overriding function is more lax}} };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p3.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // Exception specification compatibility. // We test function pointers, because functions have an extra rule in p4. // Same type is compatible extern void (*r1)() throw(int); extern void (*r1)() throw(int); // Typedefs don't matter. typedef int INT; extern void (*r2)() throw(int); extern void (*r2)() throw(INT); // Order doesn't matter. extern void (*r3)() throw(int, float); extern void (*r3)() throw(float, int); // MS throw-any spec and no spec at all are compatible extern void (*r4)(); extern void (*r4)() throw(...); // throw(X) and no spec are not compatible extern void (*r5)() throw(int); // expected-note {{previous declaration}} extern void (*r5)(); // expected-error {{exception specification in declaration does not match}} // For functions, we accept this with a warning. extern void f5() throw(int); // expected-note {{previous declaration}} extern void f5(); // expected-warning {{missing exception specification}} // Different types are not compatible. extern void (*r7)() throw(int); // expected-note {{previous declaration}} extern void (*r7)() throw(float); // expected-error {{exception specification in declaration does not match}} // Top-level const doesn't matter. extern void (*r8)() throw(int); extern void (*r8)() throw(const int); // Multiple appearances don't matter. extern void (*r9)() throw(int, int); extern void (*r9)() throw(int, int); // noexcept is compatible with itself extern void (*r10)() noexcept; extern void (*r10)() noexcept; // noexcept(true) is compatible with noexcept extern void (*r11)() noexcept; extern void (*r11)() noexcept(true); // noexcept(false) isn't extern void (*r12)() noexcept; // expected-note {{previous declaration}} extern void (*r12)() noexcept(false); // expected-error {{does not match}} // The form of the boolean expression doesn't matter. extern void (*r13)() noexcept(1 < 2); extern void (*r13)() noexcept(2 > 1); // noexcept(false) is incompatible with noexcept(true) extern void (*r14)() noexcept(true); // expected-note {{previous declaration}} extern void (*r14)() noexcept(false); // expected-error {{does not match}} // noexcept(false) is compatible with itself extern void (*r15)() noexcept(false); extern void (*r15)() noexcept(false); // noexcept(false) is compatible with MS throw(...) extern void (*r16)() noexcept(false); extern void (*r16)() throw(...); // noexcept(false) is *not* compatible with no spec extern void (*r17)(); // expected-note {{previous declaration}} extern void (*r17)() noexcept(false); // expected-error {{does not match}} // except for functions void f17(); void f17() noexcept(false); // noexcept(false) is compatible with dynamic specs that throw unless // CWG 1073 resolution is accepted. Clang implements it. //extern void (*r18)() throw(int); //extern void (*r18)() noexcept(false); // noexcept(true) is compatible with dynamic specs that don't throw extern void (*r19)() throw(); extern void (*r19)() noexcept(true); // The other way round doesn't work. extern void (*r20)() throw(); // expected-note {{previous declaration}} extern void (*r20)() noexcept(false); // expected-error {{does not match}} extern void (*r21)() throw(int); // expected-note {{previous declaration}} extern void (*r21)() noexcept(true); // expected-error {{does not match}} // As a very special workaround, we allow operator new to match no spec // with a throw(bad_alloc) spec, because C++0x makes an incompatible change // here. extern "C++" { namespace std { class bad_alloc {}; } } typedef decltype(sizeof(int)) mysize_t; void* operator new(mysize_t) throw(std::bad_alloc); void* operator new(mysize_t); void* operator new[](mysize_t); void* operator new[](mysize_t) throw(std::bad_alloc);
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p1.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // Simple parser tests, dynamic specification. namespace dyn { struct X { }; struct Y { }; void f() throw() { } void g(int) throw(X) { } void h() throw(X, Y) { } class Class { void foo() throw (X, Y) { } }; void (*fptr)() throw(); } // Simple parser tests, noexcept specification. namespace noex { void f1() noexcept { } void f2() noexcept (true) { } void f3() noexcept (false) { } void f4() noexcept (1 < 2) { } class CA1 { void foo() noexcept { } void bar() noexcept (true) { } }; void (*fptr1)() noexcept; void (*fptr2)() noexcept (true); } namespace mix { void f() throw(int) noexcept { } // expected-error {{cannot have both}} void g() noexcept throw(int) { } // expected-error {{cannot have both}} } // Sema tests, noexcept specification namespace noex { struct A {}; void g1() noexcept(A()); // expected-error {{not contextually convertible}} void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}} expected-note {{read of non-const variable 'b'}} expected-note {{here}} } namespace noexcept_unevaluated { template<typename T> bool f(T) { T* x = 1; } template<typename T> void g(T x) noexcept((sizeof(T) == sizeof(int)) || noexcept(f(x))) { } void h() { g(1); } } namespace PR11084 { template<int X> struct A { static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}} }; template<int X> void f() { int (*p)() noexcept(1/X); // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}} }; void g() { A<0>::f(); // expected-note{{in instantiation of exception specification for 'f'}} f<0>(); // expected-note{{in instantiation of function template specialization}} } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p2-places.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // Tests where specs are allowed and where they aren't. namespace dyn { // Straight from the standard: // Plain function with spec void f() throw(int); // Pointer to function with spec void (*fp)() throw (int); // Function taking reference to function with spec void g(void pfa() throw(int)); // Typedef for pointer to function with spec typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}} // Some more: // Function returning function with spec void (*h())() throw(int); // Ultimate parser thrill: function with spec returning function with spec and // taking pointer to function with spec. // The actual function throws int, the return type double, the argument float. void (*i() throw(int))(void (*)() throw(float)) throw(double); // Pointer to pointer to function taking function with spec void (**k)(void pfa() throw(int)); // no-error // Pointer to pointer to function with spec void (**j)() throw(int); // expected-error {{not allowed beyond a single}} // Pointer to function returning pointer to pointer to function with spec void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}} } namespace noex { // These parallel those from above. void f() noexcept(false); void (*fp)() noexcept(false); void g(void pfa() noexcept(false)); typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}} void (*h())() noexcept(false); void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false); void (**k)(void pfa() noexcept(false)); // no-error void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}} void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/canonical.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // expected-no-diagnostics // PR10087: Make sure that we don't conflate exception specifications // from different functions in the canonical type system. namespace std { template <class _Tp> _Tp&& declval() noexcept; template <class _Tp, class... _Args> struct _is_nothrow_constructible { static const bool value = noexcept(_Tp(declval<_Args>()...)); }; template<class, class _Traits, class _Allocator> class basic_string { public: typedef typename _Traits::char_type value_type; typedef _Allocator allocator_type; basic_string() noexcept(_is_nothrow_constructible<allocator_type>::value); }; template <class, class, class _Compare> struct __map_value_compare { public: __map_value_compare() noexcept(_is_nothrow_constructible<_Compare>::value); }; struct less { }; struct map { typedef __map_value_compare<int, short, less> __vc; __vc vc_; }; template<class T, class _Traits, class _Allocator> basic_string<T, _Traits, _Allocator>::basic_string() noexcept(_is_nothrow_constructible<allocator_type>::value) {} template <class T, class Value, class _Compare> __map_value_compare<T, Value, _Compare>::__map_value_compare() noexcept(_is_nothrow_constructible<_Compare>::value) {} } // std
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p11.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // expected-no-diagnostics // This is the "let the user shoot themselves in the foot" clause. void f() noexcept { throw 0; // no-error } void g() throw() { throw 0; // no-error } void h() throw(int) { throw 0.0; // no-error }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/p9-noexcept.cpp
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s void external(); void target() noexcept { // CHECK: invoke void @_Z8externalv() external(); } // CHECK: [[T0:%.*]] = landingpad { i8*, i32 } // CHECK-NEXT: catch i8* null // CHECK-NEXT: [[T1:%.*]] = extractvalue { i8*, i32 } [[T0]], 0 // CHECK-NEXT: call void @__clang_call_terminate(i8* [[T1]]) [[NR_NUW:#[0-9]+]] // CHECK-NEXT: unreachable void reverse() noexcept(false) { // CHECK: call void @_Z8externalv() external(); } // CHECK: attributes [[NR_NUW]] = { noreturn nounwind }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.spec/template.cpp
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s // We use pointer assignment compatibility to test instantiation. template <int N> void f1() throw(int); template <int N> void f2() noexcept(N > 1); void (*t1)() throw(int) = &f1<0>; void (*t2)() throw() = &f1<0>; // expected-error {{not superset}} void (*t3)() noexcept = &f2<2>; // no-error void (*t4)() noexcept = &f2<0>; // expected-error {{not superset}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/except
repos/DirectXShaderCompiler/tools/clang/test/CXX/except/except.handle/p16.cpp
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s // The object declared in an exception-declaration or, if the // exception-declaration does not specify a name, a temporary (12.2) // is copy-initialized (8.5) from the exception object. // template<typename T> class X { T* ptr; public: X(const X<T> &) { int *ip = 0; ptr = ip; // expected-error{{assigning to 'float *' from incompatible type 'int *'}} } ~X() { float *fp = 0; ptr = fp; // expected-error{{assigning to 'int *' from incompatible type 'float *'}} } }; void f() { try { } catch (X<float>) { // expected-note{{instantiation}} // copy constructor } catch (X<int> xi) { // expected-note{{instantiation}} // destructor } } struct Abstract { virtual void f() = 0; // expected-note{{pure virtual}} }; void g() { try { } catch (Abstract) { // expected-error{{variable type 'Abstract' is an abstract class}} } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR10034 struct X {}; void exx(X) {} int test_ptr10034(int argc, char **argv) { if (argc > 3) goto end; X x; X xs[16]; exx(x); end: if (argc > 1) { for (int i = 0; i < argc; ++i) { } } return 0; } struct Y { ~Y(); }; void test_Y() { goto end; // expected-error{{cannot jump from this goto statement to its label}} Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}} end: return; } struct Z { Z operator=(const Z&); }; void test_Z() { goto end; // expected-error{{cannot jump from this goto statement to its label}} Z z; // expected-note{{jump bypasses initialization of non-POD variable}} end: return; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // PR10034 struct X {}; void exx(X) {} int test_ptr10034(int argc, char **argv) { if (argc > 3) goto end; X x; X xs[16]; exx(x); end: if (argc > 1) { for (int i = 0; i < argc; ++i) { } } return 0; } struct Y { ~Y(); }; void f(); void test_Y() { goto end; // expected-error{{cannot jump from this goto statement to its label}} Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}} end: f(); goto inner; // expected-error{{cannot jump from this goto statement to its label}} { Y y2; // expected-note{{jump bypasses variable with a non-trivial destructor}} inner: f(); } return; } struct Z { Z operator=(const Z&); }; void test_Z() { goto end; Z z; end: return; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.label/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s void f() { int x = 0; goto label1; label1: // expected-note{{previous definition is here}} x = 1; goto label2; // expected-error{{use of undeclared label 'label2'}} label1: // expected-error{{redefinition of label 'label1'}} x = 2; } void h() { int x = 0; switch (x) { case 1:; default:; // expected-error{{multiple default labels in one switch}} default:; // expected-note{{previous case defined here}} } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.iter
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s struct pr12960 { int begin; void foo(int x) { for (int& it : x) { // expected-error {{invalid range expression of type 'int'; no viable 'begin' function available}} } } }; struct null_t { operator int*(); }; namespace X { template<typename T> auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 2{{ignored: substitution failure}} template<typename T> auto end(T &&t) -> decltype(t.end()) { return t.end(); } // expected-note {{candidate template ignored: substitution failure [with T = }} template<typename T> auto begin(T &&t) -> decltype(t.alt_begin()) { return t.alt_begin(); } // expected-note {{selected 'begin' template [with T = }} \ expected-note 2{{candidate template ignored: substitution failure [with T = }} template<typename T> auto end(T &&t) -> decltype(t.alt_end()) { return t.alt_end(); } // expected-note {{candidate template ignored: substitution failure [with T = }} namespace inner { // These should never be considered. int begin(int); int end(int); } using namespace inner; struct A { // expected-note 2 {{candidate constructor}} A(); int *begin(); // expected-note 3{{selected 'begin' function with iterator type 'int *'}} expected-note {{'begin' declared here}} int *end(); }; struct B { B(); int *alt_begin(); int *alt_end(); }; struct NoBeginADL { null_t alt_end(); }; struct NoEndADL { null_t alt_begin(); }; struct C { C(); struct It { int val; operator int &() { return val; } }; It begin(); It end(); }; constexpr int operator*(const C::It &) { return 0; } } using X::A; void f(); void f(int); void g() { for (int a : A()) A __begin; for (char *a : A()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}} } for (char *a : X::B()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}} } // FIXME: Terrible diagnostic here. auto deduction should fail, but does not! for (double a : f) { // expected-error {{cannot use type '<overloaded function type>' as a range}} } for (auto a : A()) { } for (auto a : X::B()) { } for (auto *a : A()) { // expected-error {{variable 'a' with type 'auto *' has incompatible initializer of type 'int'}} } // : is not a typo for :: here. for (A NS:A()) { // expected-error {{no viable conversion from 'int' to 'X::A'}} } for (auto not_in_scope : not_in_scope) { // expected-error {{use of undeclared identifier 'not_in_scope'}} } for (auto a : A()) for (auto b : A()) { __range.begin(); // expected-error {{use of undeclared identifier '__range'}} ++__begin; // expected-error {{use of undeclared identifier '__begin'}} --__end; // expected-error {{use of undeclared identifier '__end'}} } for (char c : "test") ; for (auto a : f()) // expected-error {{cannot use type 'void' as a range}} ; extern int incomplete[]; for (auto a : incomplete) // expected-error {{cannot use incomplete type 'int []' as a range}} ; extern struct Incomplete also_incomplete[2]; // expected-note {{forward declaration}} for (auto &a : also_incomplete) // expected-error {{cannot use incomplete type 'struct Incomplete [2]' as a range}} ; struct VoidBegin { void begin(); // expected-note {{selected 'begin' function with iterator type 'void'}} void end(); }; for (auto a : VoidBegin()) // expected-error {{cannot use type 'void' as an iterator}} ; struct Differ { int *begin(); // expected-note {{selected 'begin' function with iterator type 'int *'}} null_t end(); // expected-note {{selected 'end' function with iterator type 'null_t'}} }; for (auto a : Differ()) // expected-error {{'begin' and 'end' must return the same type (got 'int *' and 'null_t')}} ; for (void f() : "error") // expected-error {{for range declaration must declare a variable}} ; for (extern int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'extern'}} for (static int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'static'}} for (register int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'register'}} expected-warning {{deprecated}} for (constexpr int a : X::C()) {} // OK per CWG issue #1204. for (auto u : X::NoBeginADL()) { // expected-error {{invalid range expression of type 'X::NoBeginADL'; no viable 'begin' function available}} } for (auto u : X::NoEndADL()) { // expected-error {{invalid range expression of type 'X::NoEndADL'; no viable 'end' function available}} } struct NoBegin { null_t end(); }; struct NoEnd { null_t begin(); }; for (auto u : NoBegin()) { // expected-error {{range type 'NoBegin' has 'end' member but no 'begin' member}} } for (auto u : NoEnd()) { // expected-error {{range type 'NoEnd' has 'begin' member but no 'end' member}} } struct NoIncr { void *begin(); // expected-note {{selected 'begin' function with iterator type 'void *'}} void *end(); }; for (auto u : NoIncr()) { // expected-error {{arithmetic on a pointer to void}}\ expected-note {{in implicit call to 'operator++' for iterator of type 'NoIncr'}} } struct NoNotEq { NoNotEq begin(); // expected-note {{selected 'begin' function with iterator type 'NoNotEq'}} NoNotEq end(); void operator++(); }; for (auto u : NoNotEq()) { // expected-error {{invalid operands to binary expression}}\ expected-note {{in implicit call to 'operator!=' for iterator of type 'NoNotEq'}} } struct NoDeref { NoDeref begin(); // expected-note {{selected 'begin' function}} NoDeref end(); void operator++(); bool operator!=(NoDeref &); }; for (auto u : NoDeref()) { // expected-error {{indirection requires pointer operand}} \ expected-note {{in implicit call to 'operator*' for iterator of type 'NoDeref'}} } struct NoCopy { NoCopy(); NoCopy(const NoCopy &) = delete; int *begin(); int *end(); }; for (int n : NoCopy()) { // ok } for (int n : 42) { // expected-error {{invalid range expression of type 'int'; no viable 'begin' function available}} } for (auto a : *also_incomplete) { // expected-error {{cannot use incomplete type 'struct Incomplete' as a range}} } } template<typename T, typename U> void h(T t) { for (U u : t) { // expected-error {{no viable conversion from 'X::A' to 'int'}} } for (auto u : t) { } } template void h<A, int>(A); template void h<A(&)[4], A &>(A(&)[4]); template void h<A(&)[13], A>(A(&)[13]); template void h<A(&)[13], int>(A(&)[13]); // expected-note {{requested here}} template<typename T> void i(T t) { for (auto u : t) { // expected-error {{invalid range expression of type 'X::A *'; no viable 'begin' function available}} \ expected-error {{member function 'begin' not viable}} \ expected-note {{when looking up 'begin' function}} } } template void i<A[13]>(A*); // expected-note {{requested here}} template void i<const A>(const A); // expected-note {{requested here}} struct StdBeginEnd {}; namespace std { int *begin(StdBeginEnd); int *end(StdBeginEnd); } void DR1442() { for (auto a : StdBeginEnd()) {} // expected-error {{invalid range expression of type 'StdBeginEnd'; no viable 'begin'}} } namespace NS { class ADL {}; int *begin(ADL); // expected-note {{no known conversion from 'NS::NoADL' to 'NS::ADL'}} int *end(ADL); class NoADL {}; } int *begin(NS::NoADL); int *end(NS::NoADL); struct VoidBeginADL {}; void begin(VoidBeginADL); // expected-note {{selected 'begin' function with iterator type 'void'}} void end(VoidBeginADL); void j() { for (auto u : NS::ADL()) { } for (auto u : NS::NoADL()) { // expected-error {{invalid range expression of type 'NS::NoADL'; no viable 'begin' function available}} } for (auto a : VoidBeginADL()) { // expected-error {{cannot use type 'void' as an iterator}} } } void example() { int array[5] = { 1, 2, 3, 4, 5 }; for (int &x : array) x *= 2; } namespace rdar13712739 { template<typename T> void foo(const T& t) { auto &x = t.get(); // expected-error{{member reference base type 'const int' is not a structure or union}} for (auto &blah : x) { } } template void foo(const int&); // expected-note{{in instantiation of function template specialization}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s struct T { struct x { int m; }; x* operator->(); void operator++(int); void operator<<(int); T(); T(int); T(int, int); }; template<typename A, typename B, typename C, typename D, typename E> void func(A, B, C, D, E); void func(int a, int c) { T(a)->m = 7; T(a)++; T(a,5)<<c; T(*d)(int); T(e)[5]; T(f) = {1, 2}; T(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'T (*)' with an rvalue of type 'double'}} func(a, d, e, f, g); } void func2(int a, int c) { decltype(T())(a)->m = 7; decltype(T())(a)++; decltype(T())(a,5)<<c; decltype(T())(*d)(int); decltype(T())(e)[5]; decltype(T())(f) = {1, 2}; decltype(T())(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'decltype(T()) (*)' (aka 'T *') with an rvalue of type 'double'}} func(a, d, e, f, g); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s int f(); void g() { if (int x = f()) { // expected-note 2{{previous definition}} int x; // expected-error{{redefinition of 'x'}} } else { int x; // expected-error{{redefinition of 'x'}} } } void h() { if (int x = f()) // expected-note 2{{previous definition}} int x; // expected-error{{redefinition of 'x'}} else int x; // expected-error{{redefinition of 'x'}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.select
repos/DirectXShaderCompiler/tools/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
// RUN: %clang_cc1 -std=c++11 %s -verify // expected-no-diagnostics struct Value { constexpr Value(int n) : n(n) {} constexpr operator short() const { return n; } int n; }; enum E { E0, E1 }; struct Alt { constexpr operator E() const { return E0; } }; constexpr short s = Alt(); void test(Value v) { switch (v) { case Alt(): case E1: case Value(2): case 3: break; } switch (Alt a = Alt()) { case Alt(): case E1: case Value(2): case 3: break; } switch (E0) { case Alt(): case E1: // FIXME: These should produce a warning that 2 and 3 are not values of the // enumeration. case Value(2): case 3: break; } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/p2.cpp
// RUN: %clang_cc1 %s -fsyntax-only -verify // expected-no-diagnostics // "During the lookup for a base class name, non-type names are ignored" namespace PR5840 { struct Base {}; int Base = 10; struct Derived : Base {}; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/p1.cpp
// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 // base-clause: // : base-specifier-list // base-specifier-list: // base-specifier ...[opt] // base-specifier-list , base-specifier ...[opt] // base-specifier: // attribute-specifier-seq[opt] base-type-specifier // attribute-specifier-seq[opt] virtual access-specifier[opt] base-type-specifier // attribute-specifier-seq[opt] access-specifier virtual[opt] base-type-specifier // class-or-decltype: // nested-name-specifier[opt] class-name // decltype-specifier // base-type-specifier: // class-or-decltype // access-specifier: // private // protected // public namespace PR11216 { struct Base { }; struct Derived : decltype(Base()) { }; int func(); struct Derived2 : decltype(func()) { }; // expected-error {{base specifier must name a class}} template<typename T> struct Derived3 : decltype(T().foo()) { }; struct Foo { Base foo(); }; Derived3<Foo> d; struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}} struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}} template<typename T> struct Derived6 : typename T::foo { }; // expected-error {{'typename' is redundant; base classes are implicitly types}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.virtual/p2.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-inaccessible-base %s struct A { virtual void f() = 0; // expected-note 2{{overridden virtual function}} }; struct Aprime : virtual A { virtual void f(); }; struct B : Aprime { virtual void f(); // expected-note 3{{final overrider of 'A::f'}} }; struct C : virtual A { virtual void f(); // expected-note{{final overrider of 'A::f'}} }; struct D : B, C { }; // expected-error{{virtual function 'A::f' has more than one final overrider in 'D'}} struct B2 : B { }; struct E : B, B2 { }; //expected-error{{virtual function 'A::f' has more than one final overrider in 'E'}} struct F : B, B2 { virtual void f(); // okay }; struct G : F { }; // okay struct H : G, A { }; // okay namespace MultipleSubobjects { struct A { virtual void f(); }; struct B : A { virtual void f(); }; struct C : A { virtual void f(); }; struct D : B, C { }; // okay }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s namespace Test1 { struct B { virtual void f(int); }; struct D : B { virtual void f(long) override; // expected-error {{'f' marked 'override' but does not override any member functions}} void f(int) override; }; } namespace Test2 { struct A { virtual void f(int, char, int); }; template<typename T> struct B : A { // FIXME: Diagnose this. virtual void f(T) override; }; template<typename T> struct C : A { virtual void f(int) override; // expected-error {{does not override}} }; } namespace Test3 { struct A { virtual void f(int, char, int); }; template<typename... Args> struct B : A { virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}} }; template struct B<int, char, int>; template struct B<int>; // expected-note {{in instantiation of template class 'Test3::B<int>' requested here}} } namespace Test4 { struct B { virtual void f() const final; // expected-note {{overridden virtual function is here}} }; struct D : B { void f() const; // expected-error {{declaration of 'f' overrides a 'final' function}} }; } namespace PR13499 { struct X { virtual void f(); virtual void h(); }; template<typename T> struct A : X { void f() override; void h() final; }; template<typename T> struct B : X { void g() override; // expected-error {{only virtual member functions can be marked 'override'}} void i() final; // expected-error {{only virtual member functions can be marked 'final'}} }; B<int> b; // no-note template<typename T> struct C : T { void g() override; void i() final; }; template<typename T> struct D : X { virtual void g() override; // expected-error {{does not override}} virtual void i() final; }; template<typename...T> struct E : X { void f(T...) override; void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}} void h(T...) final; void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}} }; // FIXME: Diagnose these in the template definition, not in the instantiation. E<> e; // expected-note {{in instantiation of}} template<typename T> struct Y : T { void f() override; void h() final; }; template<typename T> struct Z : T { void g() override; // expected-error {{only virtual member functions can be marked 'override'}} void i() final; // expected-error {{only virtual member functions can be marked 'final'}} }; Y<X> y; Z<X> z; // expected-note {{in instantiation of}} } namespace MemberOfUnknownSpecialization { template<typename T> struct A { struct B {}; struct C : B { void f() override; }; }; template<> struct A<int>::B { virtual void f(); }; // ok A<int>::C c1; template<> struct A<char>::B { void f(); }; // expected-error@-13 {{only virtual member functions can be marked 'override'}} // expected-note@+1 {{in instantiation of}} A<char>::C c2; template<> struct A<double>::B { virtual void f() final; }; // expected-error@-20 {{declaration of 'f' overrides a 'final' function}} // expected-note@-3 {{here}} // expected-note@+1 {{in instantiation of}} A<double>::C c3; } namespace DiagnosticsQOI { struct X { virtual ~X(); virtual void foo(int x); // expected-note {{hidden overloaded virtual function}} virtual void bar(int x); // expected-note 2 {{hidden overloaded virtual function}} virtual void bar(float x); // expected-note 2 {{hidden overloaded virtual function}} }; struct Y : X { void foo(int x, int y) override; // expected-error {{non-virtual member function marked 'override' hides virtual member function}} void bar(double) override; // expected-error {{non-virtual member function marked 'override' hides virtual member functions}} void bar(long double) final; // expected-error {{non-virtual member function marked 'final' hides virtual member functions}} }; template<typename T> struct Z : T { static void foo() override; // expected-error {{only virtual member functions can be marked 'override'}} }; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.virtual/p12.cpp
// RUN: %clang_cc1 -ast-print %s | FileCheck %s // CHECK: test12_A::foo() struct test12_A { virtual void foo(); void bar() { test12_A::foo(); } }; // CHECK: xp->test24_B::wibble() struct test24_B { virtual void wibble(); }; void foo(test24_B *xp) { xp->test24_B::wibble(); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.abstract/p16.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s struct A { virtual void a(); // expected-note{{overridden virtual function is here}} virtual void b() = delete; // expected-note{{overridden virtual function is here}} }; struct B: A { virtual void a() = delete; // expected-error{{deleted function 'a' cannot override a non-deleted function}} virtual void b(); // expected-error{{non-deleted function 'b' cannot override a deleted function}} }; struct C: A { virtual void a(); virtual void b() = delete; }; struct E; struct F; struct G; struct H; struct D { virtual E &operator=(const E &); // expected-note {{here}} virtual F &operator=(const F &); virtual G &operator=(G&&); // expected-note {{here}} virtual H &operator=(H&&); // expected-note {{here}} friend struct F; private: D &operator=(const D&) = default; D &operator=(D&&) = default; virtual ~D(); // expected-note 2{{here}} }; struct E : D {}; // expected-error {{deleted function '~E' cannot override a non-deleted function}} \ // expected-error {{deleted function 'operator=' cannot override a non-deleted function}} struct F : D {}; struct G : D {}; // expected-error {{deleted function '~G' cannot override a non-deleted function}} // expected-error@-1 {{deleted function 'operator=' cannot override a non-deleted function}} struct H : D { H &operator=(H&&) = default; // expected-error {{deleted function 'operator=' cannot override a non-deleted function}} ~H(); };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.abstract/p4.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s namespace PR6631 { struct A { virtual void f() = 0; }; struct B : virtual A { }; struct C : virtual A { virtual void f(); }; struct D : public B, public C { virtual void f(); }; void f() { (void)new D; // okay } } // Check cases where we have a virtual function that is pure in one // subobject but not pure in another subobject. namespace PartlyPure { struct A { virtual void f() = 0; // expected-note{{unimplemented pure virtual method}} }; struct B : A { virtual void f(); }; struct C : virtual A { }; struct D : B, C { }; void f() { (void) new D; // expected-error{{abstract class}} } } namespace NonPureAlongOnePath { struct A { virtual void f() = 0; }; struct B : virtual A { virtual void f(); }; struct C : virtual A { }; struct D : B, C { }; void f() { (void) new D; // okay } } namespace NonPureAlongOnePath2 { struct Aprime { virtual void f() = 0; }; struct A : Aprime { }; struct B : virtual A { virtual void f(); }; struct C : virtual A { }; struct D : B, C { }; void f() { (void) new D; // okay } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.abstract/p5.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { virtual void f() = 0; // expected-note{{unimplemented pure virtual method}} }; struct B : A { virtual void f(); }; struct C : B { virtual void f() = 0; // expected-note 2{{unimplemented pure virtual method}} }; struct D : C { }; void test() { (void)new A; // expected-error{{abstract class}} (void)new B; (void)new C; // expected-error{{abstract class}} (void)new D; // expected-error{{abstract class}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.member.lookup/p7.cpp
// RUN: %clang_cc1 -verify %s // expected-no-diagnostics struct A { int n; }; struct B { float n; }; struct C : A, B {}; struct D : virtual C {}; struct E : virtual C { char n; }; struct F : D, E {} f; char &k = f.n;
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.member.lookup/p9.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s namespace rdar8436162 { class ClsA { public: static void f(); void g(); }; class ClsB : virtual private ClsA { public: using ClsA::f; using ClsA::g; // expected-note{{member found by ambiguous name lookup}} }; class ClsF : virtual private ClsA { public: using ClsA::f; using ClsA::g; // expected-note{{member found by ambiguous name lookup}} }; class ClsE : public ClsB, public ClsF { void test() { f(); g(); // expected-error{{member 'g' found in multiple base classes of different types}} } }; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.member.lookup/p8.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // FIXME: Access control checks namespace PR5820 { // also <rdar://problem/7535045> struct Base { void Foo(); int Member; }; struct D1 : public Base {}; struct D2 : public Base {}; struct Derived : public D1, public D2 { void Inner(); }; void Test() { Derived d; d.D1::Foo(); d.D1::Member = 17; } void Derived::Inner() { D1::Foo(); D1::Member = 42; this->D1::Foo(); this->D1::Member = 42; } } template<typename T> struct BaseT { void Foo(); // expected-note{{found by ambiguous name lookup}} int Member; }; template<typename T> struct Derived1T : BaseT<T> { }; template<typename T> struct Derived2T : BaseT<T> { }; template<typename T> struct DerivedT : public Derived1T<T>, public Derived2T<T> { void Inner(); }; template<typename T> void DerivedT<T>::Inner() { Derived1T<T>::Foo(); Derived2T<T>::Member = 42; this->Derived1T<T>::Foo(); this->Derived2T<T>::Member = 42; this->Foo(); // expected-error{{non-static member 'Foo' found in multiple base-class subobjects of type 'BaseT<int>'}} } template<typename T> void Test(DerivedT<T> d) { d.template Derived1T<T>::Foo(); d.template Derived2T<T>::Member = 17; d.Inner(); // expected-note{{in instantiation}} } template void Test(DerivedT<int>);
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.derived/class.member.lookup/p6.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s class V { public: int f(); int x; }; class W { public: int g(); // expected-note{{member found by ambiguous name lookup}} int y; // expected-note{{member found by ambiguous name lookup}} }; class B : public virtual V, public W { public: int f(); int x; int g(); // expected-note{{member found by ambiguous name lookup}} int y; // expected-note{{member found by ambiguous name lookup}} }; class C : public virtual V, public W { }; class D : public B, public C { void glorp(); }; void D::glorp() { x++; f(); y++; // expected-error{{member 'y' found in multiple base classes of different types}} g(); // expected-error{{member 'g' found in multiple base classes of different types}} } // PR6462 struct BaseIO { BaseIO* rdbuf() { return 0; } }; struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } }; struct P : virtual BaseIO, Pcommon {}; void f() { P p; p.rdbuf(); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -triple=x86_64-linux-gnu using size_t = decltype(sizeof(int)); namespace std { struct string {}; } template<typename T, typename U> struct same_type; template<typename T> struct same_type<T, T> {}; namespace std_example { long double operator "" _w(long double); std::string operator "" _w(const char16_t*, size_t); unsigned operator "" _w(const char*); int main() { auto v1 = 1.2_w; // calls operator "" _w(1.2L) auto v2 = u"one"_w; // calls operator "" _w(u"one", 3) auto v3 = 12_w; // calls operator "" _w("12") "two"_w; // expected-error {{no matching literal operator for call to 'operator "" _w' with arguments of types 'const char *' and 'unsigned long'}} same_type<decltype(v1), long double> test1; same_type<decltype(v2), std::string> test2; same_type<decltype(v3), unsigned> test3; } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s using size_t = decltype(sizeof(int)); void operator "" _x(const wchar_t *, size_t); namespace std_example { int main() { L"A" "B" "C"_x; "P"_x "Q" "R"_y; // expected-error {{differing user-defined suffixes ('_x' and '_y') in string literal concatenation}} } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp
// RUN: %clang_cc1 -std=c++11 -verify %s using size_t = decltype(sizeof(int)); constexpr const char *operator "" _id(const char *p, size_t) { return p; } constexpr const char *s = "foo"_id "bar" "baz"_id "quux"; constexpr bool streq(const char *p, const char *q) { return *p == *q && (!*p || streq(p+1, q+1)); } static_assert(streq(s, "foobarbazquux"), ""); constexpr const char *operator "" _trim(const char *p, size_t n) { return *p == ' ' ? operator "" _trim(p + 1, n - 1) : p; } constexpr const char *t = " " " "_trim " foo"; static_assert(streq(t, "foo"), ""); const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
// RUN: %clang_cc1 -std=c++11 -verify %s using size_t = decltype(sizeof(int)); void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}} void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}} template<typename T> void f() { // A program containing a reserved ud-suffix is ill-formed. 123wibble; // expected-error {{invalid suffix 'wibble'}} 123.0wibble; // expected-error {{invalid suffix 'wibble'}} const char *p = ""wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} const char *q = R"x("hello")x"wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s int &operator "" _x1 (long double); int &i1 = 0.123_x1; double &operator "" _x1 (const char *); int &i2 = 45._x1; template<char...> char &operator "" _x1 (); int &i3 = 0377e-1_x1; int &i4 = 1e1000000_x1; // expected-warning {{too large for type 'long double'}} double &operator "" _x2 (const char *); double &i5 = 1e1000000_x2; template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); } static_assert(1e1000000_x3 == 9, "");
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s int &operator "" _x1 (unsigned long long); int &i1 = 0x123_x1; double &operator "" _x1 (const char *); int &i2 = 45_x1; template<char...> char &operator "" _x1 (); int &i3 = 0377_x1; int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-error {{integer literal is too large to be represented in any integer type}} double &operator "" _x2 (const char *); double &i5 = 123123123123123123123123123123123123123123123_x2; template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); } static_assert(123456789012345678901234567890123456789012345678901234567890_x3 == 60, "");
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s typedef decltype(sizeof(int)) size_t; // FIXME: These diagnostics should say 'size_t' instead of 'unsigned long' int a = 123_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}} int b = 4.2_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'long double' or 'const char *', and no matching literal operator template}} int c = "foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}} int d = L"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const wchar_t *' and 'unsigned}} int e = u8"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}} int f = u"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char16_t *' and 'unsigned}} int g = U"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char32_t *' and 'unsigned}} int h = 'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char'}} int i = L'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'wchar_t'}} int j = u'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char16_t'}} int k = U'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char32_t'}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s void operator "" p31(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}} void operator "" _p31(long double); long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}} float hexfloat = 0x1p31; // allow hexfloats
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p12.cpp
// RUN: %clang_cc1 -std=gnu++11 -verify %s template<typename T, T... cs> struct check; // expected-note {{template is declared here}} expected-note {{template is declared here}} template<> struct check<char, 34, -47, -126, -48, -75, -47, -127, -47, -126, 32, -16, -112, -128, -128>{}; template<> struct check<char16_t, 34, 1090, 1077, 1089, 1090, 32, 55296, 56320>{}; template<> struct check<char32_t, 34, 1090, 1077, 1089, 1090, 32, 65536>{}; template<typename T, T... str> int operator""_x() { // #1 expected-warning {{string literal operator templates are a GNU extension}} check<T, str...> chars; // expected-error {{implicit instantiation of undefined template 'check<char, 't', 'e', 's', 't'>'}} expected-error {{implicit instantiation of undefined template 'check<char32_t, 34, 1090, 1077, 1089, 1090, 95, 65536>'}} return 1; } void *operator""_x(const char*); // #2 void *a = 123_x; // ok, calls #2 int b = u8"\"тест 𐀀"_x; // ok, calls #1 int c = u8R"("тест 𐀀)"_x; // ok, calls #1 int d = "test"_x; // expected-note {{in instantiation of function template specialization 'operator "" _x<char, 't', 'e', 's', 't'>' requested here}} int e = uR"("тест 𐀀)"_x; int f = UR"("тест 𐀀)"_x; int g = UR"("тест_𐀀)"_x; // expected-note {{in instantiation of function template specialization 'operator "" _x<char32_t, 34, 1090, 1077, 1089, 1090, 95, 65536>' requested here}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -triple=x86_64-linux-gnu using size_t = decltype(sizeof(int)); int &operator "" _x1 (const char *); double &operator "" _x1 (const char *, size_t); double &i1 = "foo"_x1; double &i2 = u8"foo"_x1; double &i3 = L"foo"_x1; // expected-error {{no matching literal operator for call to 'operator "" _x1' with arguments of types 'const wchar_t *' and 'unsigned long'}} char &operator "" _x1(const wchar_t *, size_t); char &i4 = L"foo"_x1; // ok double &i5 = R"(foo)"_x1; // ok double &i6 = u\ 8\ R\ "(foo)"\ _\ x\ 1; // ok
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p11.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s using size_t = decltype(sizeof(int)); template<typename T, typename U> struct same_type; template<typename T> struct same_type<T, T> {}; template<typename T> using X = T; template<typename CharT, X<CharT>...> int operator "" _x(); // expected-warning {{string literal operator templates are a GNU extension}} template<char...> double operator "" _x(); auto a="string"_x; auto b=42_x; same_type<decltype(a), int> test_a; same_type<decltype(b), double> test_b; char operator "" _x(const char *begin, size_t size); auto c="string"_x; auto d=L"string"_x; same_type<decltype(c), char> test_c; same_type<decltype(d), int> test_d;
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s using size_t = decltype(sizeof(int)); int &operator "" _x1 (const char *); double &i1 = 'a'_x1; // expected-error {{no matching literal operator}} double &operator "" _x1 (wchar_t); double &i2 = L'a'_x1; double &i3 = 'a'_x1; // expected-error {{no matching literal operator}} double &i4 = operator"" _x1('a'); // ok char &operator "" _x1(char16_t); char &i5 = u'a'_x1; // ok double &i6 = L'a'_x1; // ok
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics // Check types of char literals extern char a; extern __typeof('a') a; extern int b; extern __typeof('asdf') b; extern wchar_t c; extern __typeof(L'a') c; #if __cplusplus >= 201103L extern char16_t d; extern __typeof(u'a') d; extern char32_t e; extern __typeof(U'a') e; #endif
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.trigraph/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -ftrigraphs -Wtrigraphs -verify %s // expected-no-diagnostics char a[] = "?? ??\"??#??$??%??&??*??+??,??.??0??1??2??3??4??5??6" "??7??8??9??:??;?????@??A??B??C??D??E??F??G??H??I??J" "??K??L??M??N??O??P??Q??R??S??T??U??V??W??X??Y??Z??[" "??\\??]??^??_??`??a??b??c??d??e??f??g??h??i??j??k??l" "??m??n??o??p??q??r??s??t??u??v??w??x??y??z??{??|??}??~";
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.trigraph/p2.cpp
// RUN: %clang_cc1 -fsyntax-only -ftrigraphs -Wtrigraphs -verify %s ??=define arraycheck(a,b) a??(b??) ??!??! b??(a??) // expected-warning {{trigraph converted to '#' character}} expected-warning {{trigraph converted to '[' character}} expected-warning {{trigraph converted to ']' character}} expected-warning {{trigraph converted to '|' character}} expected-warning {{trigraph converted to '|' character}} expected-warning {{trigraph converted to '[' character}} expected-warning {{trigraph converted to ']' character}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.trigraph/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -ftrigraphs -Wtrigraphs -verify %s ??=pragma // expected-warning {{trigraph converted to '#' character}} int a = '??/0'; // expected-warning {{trigraph converted to '\' character}} int b = 1 ??' 0; // expected-warning {{trigraph converted to '^' character}} int c ??(1]; // expected-warning {{trigraph converted to '[' character}} int d [1??); // expected-warning {{trigraph converted to ']' character}} int e = 1 ??! 0; // expected-warning {{trigraph converted to '|' character}} void f() ??<} // expected-warning {{trigraph converted to '{' character}} void g() {??> // expected-warning {{trigraph converted to '}' character}} int h = ??- 0; // expected-warning {{trigraph converted to '~' character}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.charset/p2-cxx11.cpp
// RUN: %clang_cc1 -verify -std=c++11 %s char c00 = '\u0000'; // ok char c01 = '\u0001'; // ok char c1f = '\u001f'; // ok char c20 = '\u0020'; // ' ', ok char c22 = '\u0022'; // ", ok char c23 = '\u0023'; // #, ok char c24 = '\u0024'; // $, ok char c25 = '\u0025'; // %, ok char c27 = '\u0027'; // ', ok char c3f = '\u003f'; // ?, ok char c40 = '\u0040'; // @, ok char c41 = '\u0041'; // A, ok char c5f = '\u005f'; // _, ok char c60 = '\u0060'; // `, ok char c7e = '\u007e'; // ~, ok char c7f = '\u007f'; // ok wchar_t w007f = L'\u007f'; wchar_t w0080 = L'\u0080'; wchar_t w009f = L'\u009f'; wchar_t w00a0 = L'\u00a0'; wchar_t wd799 = L'\ud799'; wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}} wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}} wchar_t we000 = L'\ue000'; char32_t w10fffe = U'\U0010fffe'; char32_t w10ffff = U'\U0010ffff'; char32_t w110000 = U'\U00110000'; // expected-error {{invalid universal character}} const char *p1 = "\u0000\u0001\u001f\u0020\u0022\u0023\u0024\u0025\u0027\u003f\u0040\u0041\u005f\u0060\u007e\u007f"; const wchar_t *p2 = L"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; const char *p3 = u8"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; const char16_t *p4 = u"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; const char32_t *p5 = U"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; const wchar_t *p6 = L"foo \U00110000 bar"; // expected-error {{invalid universal character}} const char *p7 = u8"foo \U0000d800 bar"; // expected-error {{invalid universal character}} const char16_t *p8 = u"foo \U0000dfff bar"; // expected-error {{invalid universal character}} const char32_t *p9 = U"foo \U0010ffff bar"; // ok
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.charset/p2-cxx98.cpp
// RUN: %clang_cc1 -verify -std=c++98 %s char c00 = '\u0000'; // expected-error {{universal character name refers to a control character}} char c01 = '\u0001'; // expected-error {{universal character name refers to a control character}} char c1f = '\u001f'; // expected-error {{universal character name refers to a control character}} char c20 = '\u0020'; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}} char c22 = '\u0022'; // ", expected-error {{character '"' cannot be specified by a universal character name}} char c23 = '\u0023'; // #, expected-error {{character '#' cannot be specified by a universal character name}} char c24 = '\u0024'; // $, ok char c25 = '\u0025'; // %, expected-error {{character '%' cannot be specified by a universal character name}} char c27 = '\u0027'; // ', expected-error {{character ''' cannot be specified by a universal character name}} char c3f = '\u003f'; // ?, expected-error {{character '?' cannot be specified by a universal character name}} char c40 = '\u0040'; // @, ok char c41 = '\u0041'; // A, expected-error {{character 'A' cannot be specified by a universal character name}} char c5f = '\u005f'; // _, expected-error {{character '_' cannot be specified by a universal character name}} char c60 = '\u0060'; // `, ok char c7e = '\u007e'; // ~, expected-error {{character '~' cannot be specified by a universal character name}} char c7f = '\u007f'; // expected-error {{universal character name refers to a control character}} wchar_t w007f = L'\u007f'; // expected-error {{universal character name refers to a control character}} wchar_t w0080 = L'\u0080'; // expected-error {{universal character name refers to a control character}} wchar_t w009f = L'\u009f'; // expected-error {{universal character name refers to a control character}} wchar_t w00a0 = L'\u00a0'; wchar_t wd799 = L'\ud799'; wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}} wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}} wchar_t we000 = L'\ue000'; const char *s00 = "\u0000"; // expected-error {{universal character name refers to a control character}} const char *s01 = "\u0001"; // expected-error {{universal character name refers to a control character}} const char *s1f = "\u001f"; // expected-error {{universal character name refers to a control character}} const char *s20 = "\u0020"; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}} const char *s22 = "\u0022"; // ", expected-error {{character '"' cannot be specified by a universal character name}} const char *s23 = "\u0023"; // #, expected-error {{character '#' cannot be specified by a universal character name}} const char *s24 = "\u0024"; // $, ok const char *s25 = "\u0025"; // %, expected-error {{character '%' cannot be specified by a universal character name}} const char *s27 = "\u0027"; // ', expected-error {{character ''' cannot be specified by a universal character name}} const char *s3f = "\u003f"; // ?, expected-error {{character '?' cannot be specified by a universal character name}} const char *s40 = "\u0040"; // @, ok const char *s41 = "\u0041"; // A, expected-error {{character 'A' cannot be specified by a universal character name}} const char *s5f = "\u005f"; // _, expected-error {{character '_' cannot be specified by a universal character name}} const char *s60 = "\u0060"; // `, ok const char *s7e = "\u007e"; // ~, expected-error {{character '~' cannot be specified by a universal character name}} const char *s7f = "\u007f"; // expected-error {{universal character name refers to a control character}} const wchar_t *ws007f = L"\u007f"; // expected-error {{universal character name refers to a control character}} const wchar_t *ws0080 = L"\u0080"; // expected-error {{universal character name refers to a control character}} const wchar_t *ws009f = L"\u009f"; // expected-error {{universal character name refers to a control character}} const wchar_t *ws00a0 = L"\u00a0"; const wchar_t *wsd799 = L"\ud799"; const wchar_t *wsd800 = L"\ud800"; // expected-error {{invalid universal character}} const wchar_t *wsdfff = L"\udfff"; // expected-error {{invalid universal character}} const wchar_t *wse000 = L"\ue000";
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex
repos/DirectXShaderCompiler/tools/clang/test/CXX/lex/lex.pptoken/p3-0x.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s int a<::> = { 1, 2, 3 }; int b = a<:::a<:0:>:>; bool c = a<:0:><::b; template<int &n> void f() {} template void f<::b>(); #define x a<:: ## : b :> int d = x; // expected-error {{pasting formed ':::', an invalid preprocessing token}} expected-error {{expected unqualified-id}} const char xs[] = R"(\ ??=\U0000)"; static_assert(sizeof(xs) == 12, "did not revert all changes");
0
repos/DirectXShaderCompiler/tools/clang/test/CXX
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/p3.cpp
// RUN: %clang_cc1 -verify %s template<typename T> struct S { static int a, b; }; template<typename T> int S<T>::a, S<T>::b; // expected-error {{can only declare a single entity}} template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expected ';' after struct}} \ expected-error {{use of undeclared identifier 'T'}} \ expected-error {{no member named 'a'}} \ expected-warning {{extra qualification}} template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \ expected-error {{requires a type specifier}} template<typename T> struct C { } // expected-error {{expected ';' after struct}} A<int> c;
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/p3.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template<typename T> using A = int; template<typename T> using A<T*> = char; // expected-error {{partial specialization of alias templates is not permitted}} template<> using A<char> = char; // expected-error {{explicit specialization of alias templates is not permitted}} template using A<char> = char; // expected-error {{explicit instantiation of alias templates is not permitted}} using A<char> = char; // expected-error {{name defined in alias declaration must be an identifier}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics // Example bind implementation from the variadic templates proposal, // ISO C++ committee document number N2080. // Helper type traits template<typename T> struct add_reference { typedef T &type; }; template<typename T> struct add_reference<T&> { typedef T &type; }; template<typename T> struct add_const_reference { typedef T const &type; }; template<typename T> struct add_const_reference<T&> { typedef T &type; }; template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; template<typename T> class reference_wrapper { T *ptr; public: reference_wrapper(T& t) : ptr(&t) { } operator T&() const { return *ptr; } }; template<typename T> reference_wrapper<T> ref(T& t) { return reference_wrapper<T>(t); } template<typename T> reference_wrapper<const T> cref(const T& t) { return reference_wrapper<const T>(t); } template<typename... Values> class tuple; // Basis case: zero-length tuple template<> class tuple<> { }; template<typename Head, typename... Tail> class tuple<Head, Tail...> : private tuple<Tail...> { typedef tuple<Tail...> inherited; public: tuple() { } // implicit copy-constructor is okay // Construct tuple from separate arguments. tuple(typename add_const_reference<Head>::type v, typename add_const_reference<Tail>::type... vtail) : m_head(v), inherited(vtail...) { } // Construct tuple from another tuple. template<typename... VValues> tuple(const tuple<VValues...>& other) : m_head(other.head()), inherited(other.tail()) { } template<typename... VValues> tuple& operator=(const tuple<VValues...>& other) { m_head = other.head(); tail() = other.tail(); return *this; } typename add_reference<Head>::type head() { return m_head; } typename add_reference<const Head>::type head() const { return m_head; } inherited& tail() { return *this; } const inherited& tail() const { return *this; } protected: Head m_head; }; // Creation functions template<typename T> struct make_tuple_result { typedef T type; }; template<typename T> struct make_tuple_result<reference_wrapper<T> > { typedef T& type; }; template<typename... Values> tuple<typename make_tuple_result<Values>::type...> make_tuple(const Values&... values) { return tuple<typename make_tuple_result<Values>::type...>(values...); } template<typename... Values> tuple<Values&...> tie(Values&... values) { return tuple<Values&...>(values...); } // Helper classes template<typename Tuple> struct tuple_size; template<typename... Values> struct tuple_size<tuple<Values...> > { static const int value = sizeof...(Values); }; template<int I, typename Tuple> struct tuple_element; template<int I, typename Head, typename... Tail> struct tuple_element<I, tuple<Head, Tail...> > { typedef typename tuple_element<I-1, tuple<Tail...> >::type type; }; template<typename Head, typename... Tail> struct tuple_element<0, tuple<Head, Tail...> > { typedef Head type; }; // Element access template<int I, typename Tuple> class get_impl; template<int I, typename Head, typename... Values> class get_impl<I, tuple<Head, Values...> > { typedef typename tuple_element<I-1, tuple<Values...> >::type Element; typedef typename add_reference<Element>::type RJ; typedef typename add_const_reference<Element>::type PJ; typedef get_impl<I-1, tuple<Values...> > Next; public: static RJ get(tuple<Head, Values...>& t) { return Next::get(t.tail()); } static PJ get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); } }; template<typename Head, typename... Values> class get_impl<0, tuple<Head, Values...> > { typedef typename add_reference<Head>::type RJ; typedef typename add_const_reference<Head>::type PJ; public: static RJ get(tuple<Head, Values...>& t) { return t.head(); } static PJ get(const tuple<Head, Values...>& t) { return t.head(); } }; template<int I, typename... Values> typename add_reference< typename tuple_element<I, tuple<Values...> >::type >::type get(tuple<Values...>& t) { return get_impl<I, tuple<Values...> >::get(t); } template<int I, typename... Values> typename add_const_reference< typename tuple_element<I, tuple<Values...> >::type >::type get(const tuple<Values...>& t) { return get_impl<I, tuple<Values...> >::get(t); } // Relational operators inline bool operator==(const tuple<>&, const tuple<>&) { return true; } template<typename T, typename... TTail, typename U, typename... UTail> bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { return t.head() == u.head() && t.tail() == u.tail(); } template<typename... TValues, typename... UValues> bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) { return !(t == u); } inline bool operator<(const tuple<>&, const tuple<>&) { return false; } template<typename T, typename... TTail, typename U, typename... UTail> bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { return (t.head() < u.head() || (!(t.head() < u.head()) && t.tail() < u.tail())); } template<typename... TValues, typename... UValues> bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) { return u < t; } template<typename... TValues, typename... UValues> bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) { return !(u < t); } template<typename... TValues, typename... UValues> bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) { return !(t < u); } // make_indices helper template<int...> struct int_tuple {}; // make_indexes impl is a helper for make_indexes template<int I, typename IntTuple, typename... Types> struct make_indexes_impl; template<int I, int... Indexes, typename T, typename... Types> struct make_indexes_impl<I, int_tuple<Indexes...>, T, Types...> { typedef typename make_indexes_impl<I+1, int_tuple<Indexes..., I>, Types...>::type type; }; template<int I, int... Indexes> struct make_indexes_impl<I, int_tuple<Indexes...> > { typedef int_tuple<Indexes...> type; }; template<typename... Types> struct make_indexes : make_indexes_impl<0, int_tuple<>, Types...> { }; // Bind template<typename T> struct is_bind_expression { static const bool value = false; }; template<typename T> struct is_placeholder { static const int value = 0; }; template<typename F, typename... BoundArgs> class bound_functor { typedef typename make_indexes<BoundArgs...>::type indexes; public: typedef typename F::result_type result_type; explicit bound_functor(const F& f, const BoundArgs&... bound_args) : f(f), bound_args(bound_args...) { } template<typename... Args> typename F::result_type operator()(Args&... args); private: F f; tuple<BoundArgs...> bound_args; }; template<typename F, typename... BoundArgs> inline bound_functor<F, BoundArgs...> bind(const F& f, const BoundArgs&... bound_args) { return bound_functor<F, BoundArgs...>(f, bound_args...); } template<typename F, typename ...BoundArgs> struct is_bind_expression<bound_functor<F, BoundArgs...> > { static const bool value = true; }; // enable_if helper template<bool Cond, typename T = void> struct enable_if; template<typename T> struct enable_if<true, T> { typedef T type; }; template<typename T> struct enable_if<false, T> { }; // safe_tuple_element helper template<int I, typename Tuple, typename = void> struct safe_tuple_element { }; template<int I, typename... Values> struct safe_tuple_element<I, tuple<Values...>, typename enable_if<(I >= 0 && I < tuple_size<tuple<Values...> >::value)>::type> { typedef typename tuple_element<I, tuple<Values...> >::type type; }; // mu template<typename Bound, typename... Args> inline typename safe_tuple_element<is_placeholder<Bound>::value -1, tuple<Args...> >::type mu(Bound& bound_arg, const tuple<Args&...>& args) { return get<is_placeholder<Bound>::value-1>(args); } template<typename T, typename... Args> inline T& mu(reference_wrapper<T>& bound_arg, const tuple<Args&...>&) { return bound_arg.get(); } template<typename F, int... Indexes, typename... Args> inline typename F::result_type unwrap_and_forward(F& f, int_tuple<Indexes...>, const tuple<Args&...>& args) { return f(get<Indexes>(args)...); } template<typename Bound, typename... Args> inline typename enable_if<is_bind_expression<Bound>::value, typename Bound::result_type>::type mu(Bound& bound_arg, const tuple<Args&...>& args) { typedef typename make_indexes<Args...>::type Indexes; return unwrap_and_forward(bound_arg, Indexes(), args); } template<typename T> struct is_reference_wrapper { static const bool value = false; }; template<typename T> struct is_reference_wrapper<reference_wrapper<T>> { static const bool value = true; }; template<typename Bound, typename... Args> inline typename enable_if<(!is_bind_expression<Bound>::value && !is_placeholder<Bound>::value && !is_reference_wrapper<Bound>::value), Bound&>::type mu(Bound& bound_arg, const tuple<Args&...>&) { return bound_arg; } template<typename F, typename... BoundArgs, int... Indexes, typename... Args> typename F::result_type apply_functor(F& f, tuple<BoundArgs...>& bound_args, int_tuple<Indexes...>, const tuple<Args&...>& args) { return f(mu(get<Indexes>(bound_args), args)...); } template<typename F, typename... BoundArgs> template<typename... Args> typename F::result_type bound_functor<F, BoundArgs...>::operator()(Args&... args) { return apply_functor(f, bound_args, indexes(), tie(args...)); } template<int N> struct placeholder { }; template<int N> struct is_placeholder<placeholder<N>> { static const int value = N; }; template<typename T> struct plus { typedef T result_type; T operator()(T x, T y) { return x + y; } }; placeholder<1> _1; // Test bind void test_bind() { int x = 17; int y = 25; bind(plus<int>(), x, _1)(y); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics // Example tuple implementation from the variadic templates proposal, // ISO C++ committee document number N2080. // Helper type traits template<typename T> struct add_reference { typedef T &type; }; template<typename T> struct add_reference<T&> { typedef T &type; }; template<typename T> struct add_const_reference { typedef T const &type; }; template<typename T> struct add_const_reference<T&> { typedef T &type; }; template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; template<typename T> class reference_wrapper { T *ptr; public: reference_wrapper(T& t) : ptr(&t) { } operator T&() const { return *ptr; } }; template<typename T> reference_wrapper<T> ref(T& t) { return reference_wrapper<T>(t); } template<typename T> reference_wrapper<const T> cref(const T& t) { return reference_wrapper<const T>(t); } template<typename... Values> class tuple; // Basis case: zero-length tuple template<> class tuple<> { }; template<typename Head, typename... Tail> class tuple<Head, Tail...> : private tuple<Tail...> { typedef tuple<Tail...> inherited; public: tuple() { } // implicit copy-constructor is okay // Construct tuple from separate arguments. tuple(typename add_const_reference<Head>::type v, typename add_const_reference<Tail>::type... vtail) : m_head(v), inherited(vtail...) { } // Construct tuple from another tuple. template<typename... VValues> tuple(const tuple<VValues...>& other) : m_head(other.head()), inherited(other.tail()) { } template<typename... VValues> tuple& operator=(const tuple<VValues...>& other) { m_head = other.head(); tail() = other.tail(); return *this; } typename add_reference<Head>::type head() { return m_head; } typename add_reference<const Head>::type head() const { return m_head; } inherited& tail() { return *this; } const inherited& tail() const { return *this; } protected: Head m_head; }; void test_tuple() { tuple<> t0a; tuple<> t0b(t0a); t0a = t0b; tuple<int> t1a; tuple<int> t1b(17); tuple<int> t1c(t1b); t1a = t1b; tuple<float> t1d(3.14159); tuple<float> t1e(t1d); t1d = t1e; int i; float f; double d; tuple<int*, float*, double*> t3a(&i, &f, &d); } // Creation functions template<typename T> struct make_tuple_result { typedef T type; }; template<typename T> struct make_tuple_result<reference_wrapper<T> > { typedef T& type; }; template<typename... Values> tuple<typename make_tuple_result<Values>::type...> make_tuple(const Values&... values) { return tuple<typename make_tuple_result<Values>::type...>(values...); } template<typename... Values> tuple<Values&...> tie(Values&... values) { return tuple<Values&...>(values...); } template<typename T> const T *addr(const T& ref) { return &ref; } void test_creation_functions() { int i; float f; double d; const tuple<int, float&, const double&> *t3p = addr(make_tuple(i, ref(f), cref(d))); const tuple<int&, float&, double&> *t3q = addr(tie(i, f, d)); } // Helper classes template<typename Tuple> struct tuple_size; template<typename... Values> struct tuple_size<tuple<Values...> > { static const int value = sizeof...(Values); }; int check_tuple_size_0[tuple_size<tuple<> >::value == 0? 1 : -1]; int check_tuple_size_1[tuple_size<tuple<int>>::value == 1? 1 : -1]; int check_tuple_size_2[tuple_size<tuple<float, double>>::value == 2? 1 : -1]; int check_tuple_size_3[tuple_size<tuple<char, unsigned char, signed char>>::value == 3? 1 : -1]; template<int I, typename Tuple> struct tuple_element; template<int I, typename Head, typename... Tail> struct tuple_element<I, tuple<Head, Tail...> > { typedef typename tuple_element<I-1, tuple<Tail...> >::type type; }; template<typename Head, typename... Tail> struct tuple_element<0, tuple<Head, Tail...> > { typedef Head type; }; int check_tuple_element_0[is_same<tuple_element<0, tuple<int&, float, double>>::type, int&>::value? 1 : -1]; int check_tuple_element_1[is_same<tuple_element<1, tuple<int&, float, double>>::type, float>::value? 1 : -1]; int check_tuple_element_2[is_same<tuple_element<2, tuple<int&, float, double>>::type, double>::value? 1 : -1]; // Element access template<int I, typename Tuple> class get_impl; template<int I, typename Head, typename... Values> class get_impl<I, tuple<Head, Values...> > { typedef typename tuple_element<I-1, tuple<Values...> >::type Element; typedef typename add_reference<Element>::type RJ; typedef typename add_const_reference<Element>::type PJ; typedef get_impl<I-1, tuple<Values...> > Next; public: static RJ get(tuple<Head, Values...>& t) { return Next::get(t.tail()); } static PJ get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); } }; template<typename Head, typename... Values> class get_impl<0, tuple<Head, Values...> > { typedef typename add_reference<Head>::type RJ; typedef typename add_const_reference<Head>::type PJ; public: static RJ get(tuple<Head, Values...>& t) { return t.head(); } static PJ get(const tuple<Head, Values...>& t) { return t.head(); } }; template<int I, typename... Values> typename add_reference< typename tuple_element<I, tuple<Values...> >::type >::type get(tuple<Values...>& t) { return get_impl<I, tuple<Values...> >::get(t); } template<int I, typename... Values> typename add_const_reference< typename tuple_element<I, tuple<Values...> >::type >::type get(const tuple<Values...>& t) { return get_impl<I, tuple<Values...> >::get(t); } void test_element_access(tuple<int*, float*, double*&> t3) { int i; float f; double d; get<0>(t3) = &i; get<1>(t3) = &f; get<2>(t3) = &d; } // Relational operators inline bool operator==(const tuple<>&, const tuple<>&) { return true; } template<typename T, typename... TTail, typename U, typename... UTail> bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { return t.head() == u.head() && t.tail() == u.tail(); } template<typename... TValues, typename... UValues> bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) { return !(t == u); } inline bool operator<(const tuple<>&, const tuple<>&) { return false; } template<typename T, typename... TTail, typename U, typename... UTail> bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { return (t.head() < u.head() || (!(t.head() < u.head()) && t.tail() < u.tail())); } template<typename... TValues, typename... UValues> bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) { return u < t; } template<typename... TValues, typename... UValues> bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) { return !(u < t); } template<typename... TValues, typename... UValues> bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) { return !(t < u); } void test_relational_operators(tuple<int*, float*, double*> t3) { (void)(t3 == t3); (void)(t3 != t3); (void)(t3 < t3); (void)(t3 <= t3); (void)(t3 >= t3); (void)(t3 > t3); };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // Check for template type parameter pack (mis-)matches with template // type parameters. template<typename ...T> struct X0t; template<typename ...T> struct X0t; template<typename ...T> struct X1t; // expected-note{{previous template type parameter pack declared here}} template<typename T> struct X1t; // expected-error{{template type parameter conflicts with previous template type parameter pack}} template<typename T> struct X2t; // expected-note{{previous template type parameter declared here}} template<typename ...T> struct X2t; // expected-error{{template type parameter pack conflicts with previous template type parameter}} template<template<typename ...T> class> struct X0t_intt; template<template<typename ...T> class> struct X0t_intt; template<template<typename ...T> class> struct X1t_intt; // expected-note{{previous template type parameter pack declared here}} template<template<typename T> class> struct X1t_intt; // expected-error{{template type parameter conflicts with previous template type parameter pack}} template<template<typename T> class> struct X2t_intt; // expected-note{{previous template type parameter declared here}} template<template<typename ...T> class> struct X2t_intt; // expected-error{{template type parameter pack conflicts with previous template type parameter}} template<int ...Values> struct X1nt; // expected-note{{previous non-type template parameter pack declared here}} template<int Values> struct X1nt; // expected-error{{non-type template parameter conflicts with previous non-type template parameter pack}} template<template<class T> class> class X1tt; // expected-note{{previous template template parameter declared here}} template<template<class T> class...> class X1tt; // expected-error{{template template parameter pack conflicts with previous template template parameter}} // Check for matching with out-of-line definitions namespace rdar8859985 { template<typename ...> struct tuple { }; template<int ...> struct int_tuple { }; template<typename T> struct X { template<typename ...Args1, int ...Indices1> X(tuple<Args1...>, int_tuple<Indices1...>); }; template<typename T> template<typename ...Args1, int ...Indices1> X<T>::X(tuple<Args1...>, int_tuple<Indices1...>) {} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics // Example function implementation from the variadic templates proposal, // ISO C++ committee document number N2080. template<typename Signature> class function; template<typename R, typename... Args> class invoker_base { public: virtual ~invoker_base() { } virtual R invoke(Args...) = 0; virtual invoker_base* clone() = 0; }; template<typename F, typename R, typename... Args> class functor_invoker : public invoker_base<R, Args...> { public: explicit functor_invoker(const F& f) : f(f) { } R invoke(Args... args) { return f(args...); } functor_invoker* clone() { return new functor_invoker(f); } private: F f; }; template<typename R, typename... Args> class function<R (Args...)> { public: typedef R result_type; function() : invoker (0) { } function(const function& other) : invoker(0) { if (other.invoker) invoker = other.invoker->clone(); } template<typename F> function(const F& f) : invoker(0) { invoker = new functor_invoker<F, R, Args...>(f); } ~function() { if (invoker) delete invoker; } function& operator=(const function& other) { function(other).swap(*this); return *this; } template<typename F> function& operator=(const F& f) { function(f).swap(*this); return *this; } void swap(function& other) { invoker_base<R, Args...>* tmp = invoker; invoker = other.invoker; other.invoker = tmp; } result_type operator()(Args... args) const { return invoker->invoke(args...); } private: invoker_base<R, Args...>* invoker; }; template<typename T> struct add { T operator()(T x, T y) { return x + y; } }; int add_ints(int x, int y) { return x + y; } void test_function() { function<int(int, int)> f2a; function<int(int, int)> f2b = add<int>(); function<int(int, int)> f2c = add<float>(); function<int(int, int)> f2d(f2b); function<int(int, int)> f2e = &add_ints; f2c = f2d; f2d = &add_ints; f2c(1.0, 3); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s template<typename... Types> struct tuple; template<int I> struct int_c; template<typename T> struct identity { typedef T type; }; template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; // FIXME: Several more bullets to go // In a function parameter pack, the pattern is the parameter-declaration // without the ellipsis. namespace PR11850 { template<typename ...T> struct S { int f(T...a, int b) { return b; } }; S<> s; S<int*, char, const double&> t; int k = s.f(0); int l = t.f(&k, 'x', 5.9, 4); template<typename ...As> struct A { template<typename ...Bs> struct B { template<typename ...Cs> struct C { C(As..., Bs..., int &k, Cs...); }; }; }; A<>::B<>::C<> c000(k); A<int>::B<>::C<int> c101(1, k, 3); A<>::B<int>::C<int> c011(1, k, 3); A<int>::B<int>::C<> c110(1, 2, k); A<int, int>::B<int, int>::C<int, int> c222(1, 2, 3, 4, k, 5, 6); A<int, int, int>::B<>::C<> c300(1, 2, 3, k); int &f(); char &f(void*); template<typename ...A> struct U { template<typename ...B> struct V { auto g(A...a, B...b) -> decltype(f(a...)); }; }; U<>::V<int*> v0; U<int*>::V<> v1; int &v0f = v0.g(0); char &v1f = v1.g(0); } namespace PR12096 { void Foo(int) {} void Foo(int, int) = delete; template<typename ...Args> struct Var { Var(const Args &...args, int *) { Foo(args...); } }; Var<int> var(1, 0); } // In an initializer-list (8.5); the pattern is an initializer-clause. // Note: this also covers expression-lists, since expression-list is // just defined as initializer-list. void five_args(int, int, int, int, int); // expected-note{{candidate function not viable: requires 5 arguments, but 6 were provided}} template<int ...Values> void initializer_list_expansion() { int values[5] = { Values... }; // expected-error{{excess elements in array initializer}} five_args(Values...); // expected-error{{no matching function for call to 'five_args'}} } template void initializer_list_expansion<1, 2, 3, 4, 5>(); template void initializer_list_expansion<1, 2, 3, 4, 5, 6>(); // expected-note{{in instantiation of function template specialization 'initializer_list_expansion<1, 2, 3, 4, 5, 6>' requested here}} namespace PR8977 { struct A { }; template<typename T, typename... Args> void f(Args... args) { // An empty expression-list performs value initialization. constexpr T t(args...); }; template void f<A>(); } // In a base-specifier-list (Clause 10); the pattern is a base-specifier. template<typename ...Mixins> struct HasMixins : public Mixins... { HasMixins(); HasMixins(const HasMixins&); HasMixins(int i); }; struct A { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const A' for 1st argument}} \ // expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'A' for 1st argument}} \ // expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} struct B { }; struct C { }; struct D { }; A *checkA = new HasMixins<A, B, C, D>; B *checkB = new HasMixins<A, B, C, D>; D *checkD = new HasMixins<A, B, C, D>; C *checkC = new HasMixins<A, B, D>; // expected-error{{cannot initialize a variable of type 'C *' with an rvalue of type 'HasMixins<A, B, D> *'}} HasMixins<> *checkNone = new HasMixins<>; template<typename Mixins> struct BrokenMixins : public Mixins... { }; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} // In a mem-initializer-list (12.6.2); the pattern is a mem-initializer. template<typename ...Mixins> HasMixins<Mixins...>::HasMixins(): Mixins()... { } template<typename ...Mixins> HasMixins<Mixins...>::HasMixins(const HasMixins &other): Mixins(other)... { } template<typename ...Mixins> HasMixins<Mixins...>::HasMixins(int i): Mixins(i)... { } // expected-error{{no matching constructor for initialization of 'A'}} void test_has_mixins() { HasMixins<A, B> ab; HasMixins<A, B> ab2 = ab; HasMixins<A, B> ab3(17); // expected-note{{in instantiation of member function 'HasMixins<A, B>::HasMixins' requested here}} } template<typename T> struct X { T member; X() : member()... { } // expected-error{{pack expansion for initialization of member 'member'}} }; // There was a bug in the delayed parsing code for the // following case. template<typename ...T> struct DelayedParseTest : T... { int a; DelayedParseTest(T... i) : T{i}..., a{10} {} }; // In a template-argument-list (14.3); the pattern is a template-argument. template<typename ...Types> struct tuple_of_refs { typedef tuple<Types& ...> types; }; tuple<int&, float&> *t_int_ref_float_ref; tuple_of_refs<int&, float&>::types *t_int_ref_float_ref_2 = t_int_ref_float_ref; template<typename ...Types> struct extract_nested_types { typedef tuple<typename Types::type...> types; }; tuple<int, float> *t_int_float; extract_nested_types<identity<int>, identity<float> >::types *t_int_float_2 = t_int_float; template<int ...N> struct tuple_of_ints { typedef tuple<int_c<N>...> type; }; int check_temp_arg_1[is_same<tuple_of_ints<1, 2, 3, 4, 5>::type, tuple<int_c<1>, int_c<2>, int_c<3>, int_c<4>, int_c<5>>>::value? 1 : -1]; // In a dynamic-exception-specification (15.4); the pattern is a type-id. template<typename ...Types> struct f_with_except { virtual void f() throw(Types...); // expected-note{{overridden virtual function is here}} }; struct check_f_with_except_1 : f_with_except<int, float> { virtual void f() throw(int, float); }; struct check_f_with_except_2 : f_with_except<int, float> { virtual void f() throw(int); }; struct check_f_with_except_3 : f_with_except<int, float> { virtual void f() throw(int, float, double); // expected-error{{exception specification of overriding function is more lax than base version}} };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics namespace pr12262 { template<typename T, typename... Ts> void abc1(int (*xxx)[sizeof ... (Ts) + 1]); void qq1 () { abc1<int>(0); abc1<int,double>(0); } template <unsigned N> class array {}; template<typename T, typename... Types> array<sizeof...(Types)> make_array1(Types&&... args); void qq2 () { array<1> arr = make_array1<int>(1); array<3> arr2 = make_array1<int>(1,array<5>(),0.1); } template<typename T, typename... Types> int make_array(array<sizeof...(Types)>&, Types... args); void qq3 () { array<1> a1; int aa1 = make_array<int>(a1,1); array<2> a2; int aa2 = make_array<int>(a2, 0L, "abc"); } template<typename ... Ts> struct AAA { template<typename T, typename... Types> static array<sizeof...(Types)> make_array(Types ... args); }; void qq4 () { array<2> arr2 = AAA<int, int>::make_array<int>(1,2); } } namespace pr12439 { template<class... Members> struct X { template<int Idx> using get_t = decltype(sizeof...(Members)); template<int i> get_t<i> get(); }; template<class... Members> template<int i> X<Members...>::get_t<i> X<Members...>::get() { return 0; } } namespace pr13272 { template<bool B, class T = void> struct enable_if { }; template<class T> struct enable_if<true, T> { typedef T type; }; class Exception {}; template<class Ex, typename... Args> void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) { return; } void test() { cxx_throw<Exception>("Youpi",1); } } namespace pr13817 { template <unsigned> struct zod; template <> struct zod<1> {}; template <typename T, typename ... Ts> zod<sizeof...(Ts)> make_zod(Ts ...) { return zod<sizeof...(Ts)>(); } int main(int argc, char *argv[]) { make_zod<int>(1); return 0; } } namespace pr14273 { template<typename T, int i> struct myType { }; template<typename T, typename... Args> struct Counter { static const int count = 1 + Counter<Args...>::count; }; template<typename T> struct Counter<T> { static const int count = 1; }; template<typename Arg, typename... Args> myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args) { return 0; } void func(void) { make_array_with_type<char>(1,2,3); } } namespace pr15112 { template<bool, typename _Tp = void> struct enable_if { }; template<typename _Tp> struct enable_if<true,_Tp> { typedef _Tp type; }; typedef __typeof__(sizeof(int)) size_t; template <size_t n, typename T, typename... Args> struct is_array_of { static const bool value = true; }; struct cpu { using value_type = void; }; template <size_t Order, typename T> struct coords_alias { typedef T type; }; template <size_t Order, typename MemoryTag> using coords = typename coords_alias<Order, MemoryTag>::type; template <typename MemTag, typename... Args> typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value, coords<sizeof...(Args), MemTag>>::type mkcoords(Args... args); auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul); } namespace pr12699 { template<bool B> struct bool_constant { static const bool value = B; }; template<typename... A> struct F { template<typename... B> using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>; template<typename... B, typename = SameSize<B...>> F(B...) { } }; void func() { F<int> f1(3); } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s template<typename T, typename U> struct pair { }; template<typename ...Types> struct tuple { }; template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; namespace ExpandIntoFixed { template<typename T, typename U, typename V = pair<T, U>, typename W = V*> class X0 { }; template<typename ...Ts> class X1 { public: typedef X0<Ts...> type; }; static_assert(is_same<X1<int, int>::type, X0<int, int, pair<int, int>, pair<int, int>*>>::value, "fails with two default arguments"); static_assert(is_same<X1<int, int, float>::type, X0<int, int, float, float*>>::value, "fails with one default argument"); static_assert(is_same<X1<int, int, float, double>::type, X0<int, int, float, double>>::value, "fails with no default arguments"); } namespace ExpandIntoFixedShifted { template<typename T, typename U, typename V = pair<T, U>, typename W = V*> class X0 { }; template<typename ...Ts> class X1 { public: typedef X0<char, Ts...> type; }; static_assert(is_same<X1<int>::type, X0<char, int, pair<char, int>, pair<char, int>*>>::value, "fails with two default arguments"); static_assert(is_same<X1<int, float>::type, X0<char, int, float, float*>>::value, "fails with one default argument"); static_assert(is_same<X1<int, float, double>::type, X0<char, int, float, double>>::value, "fails with no default arguments"); } namespace Deduction { template <typename X, typename Y = double> struct Foo {}; template <typename ...Args> tuple<Args...> &foo(Foo<Args...>); void call_foo(Foo<int, float> foo_if, Foo<int> foo_i) { tuple<int, float> &t1 = foo(foo_if); tuple<int, double> &t2 = foo(foo_i); } } namespace PR9021a { template<typename, typename> struct A { }; template<typename ...T> struct B { A<T...> a1; }; void test() { B<int, int> c; } } namespace PR9021b { template<class, class> struct t2 { }; template<template<class...> class M> struct m { template<class... B> using inner = M<B...>; }; m<t2> sta2; } namespace PartialSpecialization { template<typename T, typename U, typename V = U> struct X0; // expected-note{{template is declared here}} template<typename ...Ts> struct X0<Ts...> { }; X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}} X0<int, float> x0if; X0<int, float, double> x0ifd; } namespace FixedAliasTemplate { template<typename,typename,typename> struct S {}; template<typename T, typename U> using U = S<T, int, U>; // expected-note 2{{template parameter is declared here}} template<typename...Ts> U<Ts...> &f(U<Ts...>, Ts...); // expected-error 2{{pack expansion used as argument for non-pack parameter of alias template}} S<int, int, double> &s1 = f({}, 0, 0.0); // expected-error {{no matching function}} } namespace PR18401 { template<typename... Args> struct foo { }; template<typename T, typename... Args> using bar = foo<T, Args...>; // expected-note 2{{template parameter is declared here}} expected-note {{'bar' declared here}} template<typename T, typename... Args> using baz = bar<Args..., T>; // expected-error {{pack expansion used as argument for non-pack parameter of alias template}} // FIXME: We should still record the alias template, but mark it as invalid. template<typename...T> void f(baz<T...>); // expected-error {{no template named 'baz'; did you mean 'bar'}} expected-error {{pack expansion used as argument for non-pack}} void g() { f(foo<int, char, double>()); } // expected-error {{no matching function}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp
// RUN: %clang_cc1 -std=c++11 -fblocks -fsyntax-only -verify %s // Tests the use of blocks with variadic templates. template<typename ...Args> int f0(Args ...args) { return ^ { return sizeof...(Args); }() + ^ { return sizeof...(args); }(); } template<typename ...Args> int f1(Args ...args) { return ^ { return f0(args...); }(); } template int f0(int, float, double); template int f1(const char*, int, float, double); template<typename ...Args> int f2(Args ...args) { return ^(Args ...block_args) { return f1(block_args...); }(args + 0 ...); } template int f2(const char*, int, float, double); template<typename ...Args> int f3(Args ...args) { return ^(Args *...block_args) { return f1(block_args...); }(&args...); } template int f3(const char*, int, float, double); template<typename ...Args> int PR9953(Args ...args) { return ^(Args *...block_args) { return f1(block_args); // expected-error{{expression contains unexpanded parameter pack 'block_args'}} }(&args...); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template<typename T, T ...Values> struct value_tuple {}; template<typename...> struct tuple { }; template<typename T, typename U> struct pair { }; template<typename T, T Value> struct value_c; template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; template<typename T> struct X0 { template<T ...Values> void f(value_tuple<T, Values...> * = 0); }; void test_X0() { X0<int>().f<1, 2, 3, 4, 5>(); } namespace PacksAtDifferentLevels { template<typename ...Types> struct X { template<typename> struct Inner { static const unsigned value = 1; }; template<typename ...YTypes> struct Inner<tuple<pair<Types, YTypes>...> > { static const unsigned value = sizeof...(Types) - sizeof...(YTypes); }; }; int check0[X<short, int, long>::Inner<tuple<pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>> >::value == 0? 1 : -1]; int check1[X<short, int>::Inner<tuple<pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>> >::value == 1? 1 : -1]; template<unsigned ...Values> struct unsigned_tuple { }; template<typename ...Types> struct X1 { template<typename, typename> struct Inner { static const unsigned value = 0; }; template<typename ...YTypes> struct Inner<tuple<pair<Types, YTypes>...>, unsigned_tuple<sizeof(Types) + sizeof(YTypes)...>> { static const unsigned value = 1; }; }; int check2[X1<short, int, long>::Inner<tuple<pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>>, unsigned_tuple<sizeof(short) + sizeof(unsigned short), sizeof(int) + sizeof(unsigned int), sizeof(long) + sizeof(unsigned long)> >::value == 1? 1 : -1]; int check3[X1<short, int>::Inner<tuple<pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>>, unsigned_tuple<sizeof(short) + sizeof(unsigned short), sizeof(int) + sizeof(unsigned int), sizeof(long) + sizeof(unsigned long)> >::value == 0? 1 : -1]; template<typename ...Types> struct X2 { template<typename> struct Inner { static const unsigned value = 1; }; template<typename R, typename ...YTypes> struct Inner<R(pair<Types, YTypes>...)> { static const unsigned value = sizeof...(Types) - sizeof...(YTypes); }; }; int check4[X2<short, int, long>::Inner<int(pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>) >::value == 0? 1 : -1]; int check5[X2<short, int>::Inner<int(pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>) >::value == 1? 1 : -1]; template<typename T, typename U> struct some_function_object { template<typename> struct result_of; }; template<template<class> class...> struct metafun_tuple { }; template<typename ...Types1> struct X3 { template<typename, typename> struct Inner { static const unsigned value = 0; }; template<typename ...Types2> struct Inner<tuple<pair<Types1, Types2>...>, metafun_tuple<some_function_object<Types1, Types2>::template result_of...> > { static const unsigned value = 1; }; }; int check6[X3<short, int, long>::Inner<tuple<pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>>, metafun_tuple< some_function_object<short, unsigned short>::result_of, some_function_object<int, unsigned int>::result_of, some_function_object<long, unsigned long>::result_of> >::value == 1? 1 : -1]; int check7[X3<short, int>::Inner<tuple<pair<short, unsigned short>, pair<int, unsigned int>, pair<long, unsigned long>>, metafun_tuple< some_function_object<short, unsigned short>::result_of, some_function_object<int, unsigned int>::result_of, some_function_object<long, unsigned long>::result_of> >::value == 0? 1 : -1]; template<unsigned I, unsigned J> struct unsigned_pair { }; template<unsigned ...Values1> struct X4 { template<typename> struct Inner { static const unsigned value = 0; }; template<unsigned ...Values2> struct Inner<tuple<unsigned_pair<Values1, Values2>...>> { static const unsigned value = 1; }; }; int check8[X4<1, 3, 5>::Inner<tuple<unsigned_pair<1, 2>, unsigned_pair<3, 4>, unsigned_pair<5, 6>> >::value == 1? 1 : -1]; int check9[X4<1, 3>::Inner<tuple<unsigned_pair<1, 2>, unsigned_pair<3, 4>, unsigned_pair<5, 6>> >::value == 0? 1 : -1]; template<class> struct add_reference; template<class> struct add_pointer; template<class> struct add_const; template<template<class> class ...Templates> struct X5 { template<typename> struct Inner { static const unsigned value = 0; }; template<typename ...Types> struct Inner<tuple<Templates<Types>...>> { static const unsigned value = 1; }; }; int check10[X5<add_reference, add_pointer, add_const> ::Inner<tuple<add_reference<int>, add_pointer<float>, add_const<double>>>::value == 1? 1 : -1]; int check11[X5<add_reference, add_pointer> ::Inner<tuple<add_reference<int>, add_pointer<float>, add_const<double>>>::value == 0? 1 : -1]; namespace PR13811 { constexpr int g(int n, int m) { return n * 10 + m; } template<typename...A> struct X6 { template<typename...B> constexpr auto f1(A ...a) const -> decltype(g(A(a + B())...)) { return g(A(a + B())...); } template<typename...B> constexpr auto f2(A ...a, B ...b) const -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}} template<typename...B> struct Inner { template<typename...C> constexpr auto f(A ...a, B ...b, C ...c) const -> decltype(g(a+b+c...)) { return g(a+b+c...); } }; }; struct A { constexpr operator int() const { return 2; } }; struct B { constexpr operator int() const { return 1; } }; static_assert(X6<unsigned char, int>().f1<A, B>(255, 1) == 12, ""); static_assert(X6<int, int>().f2(3, 4, 0, 0) == 34, ""); static_assert(X6<int, int>().f2(3, 4, 0, 1) == 34, ""); // expected-error {{constant expression}} expected-note {{in call}} static_assert(X6<int, int>::Inner<int, int>().f(1, 2, 3, 4, 5, 6) == 102, ""); } } namespace ExpandingNonTypeTemplateParameters { template<typename ...Types> struct tuple_of_values { template<Types ...Values> // expected-error{{a non-type template parameter cannot have type 'float'}} \ // expected-note{{template parameter is declared here}} struct apply { // expected-note 2{{template is declared here}} typedef tuple<value_c<Types, Values>...> type; }; }; int i; float f; int check_tuple_of_values_1[ is_same<tuple_of_values<int&, float&, char, int>::apply<i, f, 'a', 17> ::type, tuple<value_c<int&, i>, value_c<float&, f>, value_c<char, 'a'>, value_c<int, 17>> >::value? 1 : -1]; tuple_of_values<int, float> tv1; // expected-note{{in instantiation of template class 'ExpandingNonTypeTemplateParameters::tuple_of_values<int, float>' requested here}} tuple_of_values<int&, float&>::apply<i, i>::type tv2; // expected-error{{non-type template parameter of reference type 'float &' cannot bind to template argument of type 'int'}} tuple_of_values<int&, float&>::apply<i>::type tv3; // expected-error{{too few template arguments for class template 'apply'}} tuple_of_values<int&, float&>::apply<i, f, i>::type tv4; // expected-error{{too many template arguments for class template 'apply'}} } namespace ExpandingFunctionParameters { template<typename ...T> struct X0 { typedef int type; }; template<typename ...T> struct X1 { template<typename ... U> typename X0<T(T, U...)...>::type f(U...); }; void test() { X1<float> x1; x1.f(17, 3.14159); } } namespace PR10230 { template<typename> struct s { template<typename... Args> auto f() -> int(&)[sizeof...(Args)]; }; void main() { int (&ir1)[1] = s<int>().f<int>(); int (&ir3)[3] = s<int>().f<int, float, double>(); } } namespace PR13386 { template<typename...> struct tuple {}; template<typename...T> struct S { template<typename...U> void f(T &&...t, U &&...u) {} // expected-note {{candidate}} template<typename...U> void g(U &&...u, T &&...t) {} // expected-note {{candidate}} template<typename...U> void h(tuple<T, U> &&...) {} // expected-note 2{{candidate}} template<typename...U> struct X { template<typename...V> void x(tuple<T, U, V> &&...); // expected-error {{different lengths}} }; }; void test() { S<>().f(); S<>().f(0); S<int>().f(0); S<int>().f(0, 1); S<int, int>().f(0); // expected-error {{no matching member function for call}} S<>().g(); S<>().g(0); S<int>().g(0); S<int>().g(0, 1); // expected-error {{no matching member function for call}} S<int>().g<int>(0, 1); S<int, int>().g(0, 1); S<>().h(); S<>().h(0); // expected-error {{no matching member function for call}} S<int>().h({}); // expected-error {{no matching member function for call}} S<int>().h<int>({}); S<int>().h(tuple<int,int>{}); S<int, int>().h(tuple<int,int>{}, tuple<int,int>{}); S<int, int>::X<char>(); // expected-note {{here}} } }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/p2.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template<class ... Types> void f(Types ... args); void test() { f(); f(1); f(2, 1.0); } // Test simple recursive variadic function template template<typename Head, typename ...Tail> void recurse_until_fail(const Head &, const Tail &...tail) { // expected-note{{candidate function template not viable: requires at least 1 argument, but 0 were provided}} recurse_until_fail(tail...); // expected-error{{no matching function for call to 'recurse_until_fail'}} \ // expected-note{{in instantiation of function template specialization 'recurse_until_fail<char [7]>' requested here}} \ // expected-note{{in instantiation of function template specialization 'recurse_until_fail<double, char [7]>' requested here}} } void test_recurse_until_fail() { recurse_until_fail(1, 3.14159, "string"); // expected-note{{in instantiation of function template specialization 'recurse_until_fail<int, double, char [7]>' requested here}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/p1.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template<class ...Types> struct Tuple; Tuple<> *t0; Tuple<int> *t1; Tuple<int, char> *t2a; Tuple<int, float> *t2b = t2a; // expected-error{{cannot initialize a variable of type 'Tuple<int, float> *' with an lvalue of type 'Tuple<int, char> *'}} Tuple<int, float, double> *t3;
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics // Various tests related to partial ordering of variadic templates. template<typename ...Types> struct tuple; template<typename Tuple> struct X1 { static const unsigned value = 0; }; template<typename Head, typename ...Tail> struct X1<tuple<Head, Tail...> > { static const unsigned value = 1; }; template<typename Head, typename ...Tail> struct X1<tuple<Head, Tail&...> > { static const unsigned value = 2; }; template<typename Head, typename ...Tail> struct X1<tuple<Head&, Tail&...> > { static const unsigned value = 3; }; int check0[X1<tuple<>>::value == 0? 1 : -1]; int check1[X1<tuple<int>>::value == 2? 1 : -1]; int check2[X1<tuple<int, int>>::value == 1? 1 : -1]; int check3[X1<tuple<int, int&>>::value == 2? 1 : -1]; int check4[X1<tuple<int&, int&>>::value == 3? 1 : -1]; // Partial ordering of function templates. template<typename T1, typename T2, typename ...Rest> int &f0(T1, T2, Rest...); template<typename T1, typename T2> float &f0(T1, T2); void test_f0() { int &ir1 = f0(1, 2.0, 'a'); float &fr1 = f0(1, 2.0); } template<typename T1, typename T2, typename ...Rest> int &f1(T1, T2, Rest...); template<typename T1, typename T2> float &f1(T1, T2, ...); void test_f1() { int &ir1 = f1(1, 2.0, 'a'); } template<typename T1, typename T2, typename ...Rest> int &f2(T1, T2, Rest...); float &f2(...); void test_f2() { int &ir1 = f2(1, 2.0, 'a'); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fblocks -fms-extensions -fsyntax-only -verify %s template<typename T, typename U> struct pair; template<typename ...> struct tuple; // A parameter pack whose name appears within the pattern of a pack // expansion is expanded by that pack expansion. An appearance of the // name of a parameter pack is only expanded by the innermost // enclosing pack expansion. The pattern of a pack expansion shall // name one or more parameter packs that are not expanded by a nested // pack expansion. template<typename... Types> struct Expansion { typedef pair<Types..., int> expand_with_pacs; // okay typedef pair<Types, int...> expand_no_packs; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} typedef pair<pair<Types..., int>..., int> expand_with_expanded_nested; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} }; // All of the parameter packs expanded by a pack expansion shall have // the same number of arguments specified. template<typename ...Types> struct ExpansionLengthMismatch { template<typename ...OtherTypes> struct Inner { typedef tuple<pair<Types, OtherTypes>...> type; // expected-error{{pack expansion contains parameter packs 'Types' and 'OtherTypes' that have different lengths (3 vs. 2)}} }; }; ExpansionLengthMismatch<int, long>::Inner<unsigned int, unsigned long>::type *il_pairs; tuple<pair<int, unsigned int>, pair<long, unsigned long> >*il_pairs_2 = il_pairs; ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>::type // expected-note{{in instantiation of template class 'ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>' requested here}} *il_pairs_bad; // An appearance of a name of a parameter pack that is not expanded is // ill-formed. // Test for unexpanded parameter packs in each of the type nodes. template<typename T, int N, typename ... Types> struct TestPPName : public Types, public T // expected-error{{base type contains unexpanded parameter pack 'Types'}} { // BuiltinType is uninteresting // FIXME: ComplexType is uninteresting? // PointerType typedef Types *types_pointer; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // BlockPointerType typedef Types (^block_pointer_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} typedef int (^block_pointer_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // LValueReferenceType typedef Types &lvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // RValueReferenceType typedef Types &&rvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // MemberPointerType typedef Types TestPPName::* member_pointer_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} typedef int Types::*member_pointer_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // ConstantArrayType typedef Types constant_array[17]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // IncompleteArrayType typedef Types incomplete_array[]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // VariableArrayType void f(int i) { Types variable_array[i]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} } // DependentSizedArrayType typedef Types dependent_sized_array[N]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // DependentSizedExtVectorType typedef Types dependent_sized_ext_vector __attribute__((ext_vector_type(N))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // VectorType is uninteresting // ExtVectorType typedef Types ext_vector __attribute__((ext_vector_type(4))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // FunctionProtoType typedef Types (function_type_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} typedef int (function_type_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // FunctionNoProtoType is uninteresting // UnresolvedUsingType is uninteresting // ParenType is uninteresting // TypedefType is uninteresting // TypeOfExprType typedef __typeof__((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // TypeOfType typedef __typeof__(Types) typeof_type; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // DecltypeType typedef decltype((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // RecordType is uninteresting // EnumType is uninteresting // ElaboratedType is uninteresting // TemplateTypeParmType typedef Types template_type_parm; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // SubstTemplateTypeParmType is uninteresting // TemplateSpecializationType typedef pair<Types, int> template_specialization; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // InjectedClassName is uninteresting. // DependentNameType typedef typename Types::type dependent_name; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // DependentTemplateSpecializationType typedef typename Types::template apply<int> dependent_name_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} typedef typename T::template apply<Types> dependent_name_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} // ObjCObjectType is uninteresting // ObjCInterfaceType is uninteresting // ObjCObjectPointerType is uninteresting }; // FIXME: Test for unexpanded parameter packs in each of the expression nodes. template<int ...Values> void test_unexpanded_in_exprs() { // PredefinedExpr is uninteresting // DeclRefExpr Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}} // IntegerLiteral is uninteresting // FloatingLiteral is uninteresting // ImaginaryLiteral is uninteresting // StringLiteral is uninteresting // CharacterLiteral is uninteresting (Values); // expected-error{{expression contains unexpanded parameter pack 'Values'}} // UnaryOperator -Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}} // OffsetOfExpr struct OffsetMe { int array[17]; }; __builtin_offsetof(OffsetMe, array[Values]); // expected-error{{expression contains unexpanded parameter pack 'Values'}} // FIXME: continue this... } template<typename ... Types> void TestPPNameFunc(int i) { f(static_cast<Types>(i)); // expected-error{{expression contains unexpanded parameter pack 'Types'}} } template<typename T, template<class> class ...Meta> struct TestUnexpandedTTP { typedef tuple<typename Meta<T>::type> type; // expected-error{{declaration type contains unexpanded parameter pack 'Meta'}} }; // Test for unexpanded parameter packs in declarations. template<typename T, typename... Types> // FIXME: this should test that the diagnostic reads "type contains..." struct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}} void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} void member_function () throw(Types); // expected-error{{exception type contains unexpanded parameter pack 'Types'}} void member_function2() noexcept(Types()); // expected-error{{expression contains unexpanded parameter pack 'Types'}} operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}} static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} unsigned bit_field : static_cast<Types>(0); // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}} static_assert(static_cast<Types>(0), "Boom"); // expected-error{{static assertion contains unexpanded parameter pack 'Types'}} enum E0 : Types { // expected-error{{fixed underlying type contains unexpanded parameter pack 'Types'}} EnumValue = static_cast<Types>(0) // expected-error{{enumerator value contains unexpanded parameter pack 'Types'}} }; using typename Types::type; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}} using Types::value; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}} using T::operator Types; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}} friend class Types::foo; // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}} friend void friend_func(Types); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}} friend void Types::other_friend_func(int); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}} void test_initializers() { T copy_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}} T direct_init(0, static_cast<Types>(0)); // expected-error{{initializer contains unexpanded parameter pack 'Types'}} T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}} } T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}} TestUnexpandedDecls() : Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}} Types(static_cast<Types>(0))..., in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}} void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}} template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} struct default_template_args_1; template<int = static_cast<Types>(0)> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} struct default_template_args_2; template<template<typename> class = Types::template apply> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} struct default_template_args_3; template<Types value> // expected-error{{non-type template parameter type contains unexpanded parameter pack 'Types'}} struct non_type_template_param_type; void decls_in_stmts() { Types t; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} for (Types *t = 0; ; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} for (; Types *t = 0; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} T a[] = { T(), T(), T() }; for (Types t : a) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} switch(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} while(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} if (Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} try { } catch (Types*) { // expected-error{{exception type contains unexpanded parameter pack 'Types'}} } } }; // FIXME: Test for unexpanded parameter packs in each of the statements. struct X { void f(int, int); template<typename ...Types> void f(Types...); }; namespace std { class type_info; } typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[ 8 ]; } GUID; template<typename T, typename ...Types> void test_unexpanded_exprs(Types ...values) { // CXXOperatorCallExpr (void)(values + 0); // expected-error{{expression contains unexpanded parameter pack 'values'}} (void)(0 + values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXMemberCallExpr values.f(); // expected-error{{expression contains unexpanded parameter pack 'values'}} X x; x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} x.Types::f(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // CXXStaticCastExpr (void)static_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} // CXXDynamicCastExpr (void)dynamic_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} // CXXReinterpretCastExpr (void)reinterpret_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} // CXXConstCastExpr (void)const_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} // CXXTypeidExpr (void)typeid(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} (void)typeid(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXUuidofExpr (void)__uuidof(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} (void)__uuidof(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXThisExpr is uninteresting // CXXThrowExpr throw Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} throw values; // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXDefaultArgExpr is uninteresting // CXXBindTemporaryExpr is uninteresting // CXXConstructExpr is uninteresting // CXXFunctionalCastExpr (void)Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // CXXTemporaryObjectExpr (void)X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXScalarValueInitExpr is uninteresting // CXXNewExpr (void)new Types; // expected-error{{expression contains unexpanded parameter pack 'Types'}} (void)new X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} (void)new (values) X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} (void)new X [values]; // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXDeleteExpr delete values; // expected-error{{expression contains unexpanded parameter pack 'values'}} delete [] values; // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXPseudoDestructorExpr T t; values.~T(); // expected-error{{expression contains unexpanded parameter pack 'values'}} t.~Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} t.Types::~T(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // Unary TypeTraitExpr __is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // Binary TypeTraitExpr __is_base_of(Types, T); // expected-error{{expression contains unexpanded parameter pack 'Types'}} __is_base_of(T, Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // UnresolvedLookupExpr test_unexpanded_exprs(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // DependentScopeDeclRefExpr Types::test_unexpanded_exprs(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} T::template test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // CXXUnresolvedConstructExpr Types(5); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // CXXDependentScopeMemberExpr values.foo(); // expected-error{{expression contains unexpanded parameter pack 'values'}} t.foo(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // FIXME: There's an evil ambiguity here, because we don't know if // Types refers to the template type parameter pack in scope or a // non-pack member. // t.Types::foo(); t.template foo<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} // UnresolvedMemberExpr x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // CXXNoexceptExpr noexcept(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} // PackExpansionExpr is uninteresting // SizeOfPackExpr is uninteresting // FIXME: Objective-C expressions will need to go elsewhere for (auto t : values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}} switch (values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}} switch (0) { case 0: case values: ; } // expected-error{{expression contains unexpanded parameter pack 'values'}} do { } while (values); // expected-error{{expression contains unexpanded parameter pack 'values'}} test: goto *values; // expected-error{{expression contains unexpanded parameter pack 'values'}} void f(int arg = values); // expected-error{{default argument contains unexpanded parameter pack 'values'}} } // Test unexpanded parameter packs in partial specializations. template<typename ...Types> struct TestUnexpandedDecls<int, Types>; // expected-error{{partial specialization contains unexpanded parameter pack 'Types'}} // Test for diagnostics in the presence of multiple unexpanded // parameter packs. template<typename T, typename U> struct pair; template<typename ...OuterTypes> struct MemberTemplatePPNames { template<typename ...InnerTypes> struct Inner { typedef pair<OuterTypes, InnerTypes>* types; // expected-error{{declaration type contains unexpanded parameter packs 'OuterTypes' and 'InnerTypes'}} template<typename ...VeryInnerTypes> struct VeryInner { typedef pair<pair<VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; // expected-error{{declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ...}} }; }; }; // Example from working paper namespace WorkingPaperExample { template<typename...> struct Tuple {}; template<typename T1, typename T2> struct Pair {}; template<class ... Args1> struct zip { template<class ... Args2> struct with { typedef Tuple<Pair<Args1, Args2> ... > type; // expected-error{{pack expansion contains parameter packs 'Args1' and 'Args2' that have different lengths (1 vs. 2)}} }; }; typedef zip<short, int>::with<unsigned short, unsigned>::type T1; // T1 is Tuple<Pair<short, unsigned short>, Pair<int, unsigned>> typedef Tuple<Pair<short, unsigned short>, Pair<int, unsigned>> T1; typedef zip<short>::with<unsigned short, unsigned>::type T2; // expected-note{{in instantiation of template class}} template<class ... Args> void f(Args...); template<class ... Args> void h(Args...); template<class ... Args> void g(Args ... args) { f(const_cast<const Args*>(&args)...); // OK: "Args" and "args" are expanded within f f(5 ...); // expected-error{{pack expansion does not contain any unexpanded parameter packs}} f(args); // expected-error{{expression contains unexpanded parameter pack 'args'}} f(h(args ...) + args ...); } } namespace PR16303 { template<int> struct A { A(int); }; template<int...N> struct B { template<int...M> struct C : A<N>... { C() : A<N>(M)... {} // expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (2 vs. 3)}} expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (4 vs. 3)}} }; }; B<1,2>::C<4,5,6> c1; // expected-note{{in instantiation of}} B<1,2,3,4>::C<4,5,6> c2; // expected-note{{in instantiation of}} } namespace PR21289 { template<int> using T = int; template<typename> struct S { static const int value = 0; }; template<typename> const int vt = 0; // expected-warning {{extension}} int f(...); template<int ...Ns> void g() { f(T<Ns>()...); f(S<T<Ns>>::value...); f(vt<T<Ns>>...); } template void g<>(); template void g<1, 2, 3>(); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics namespace DeductionForInstantiation { template<unsigned I, typename ...Types> struct X { }; template<typename ...Types> void f0(X<sizeof...(Types), Types&...>) { } // No explicitly-specified arguments template void f0(X<0>); template void f0(X<1, int&>); template void f0(X<2, int&, short&>); // One explicitly-specified argument template void f0<float>(X<1, float&>); template void f0<double>(X<1, double&>); // Two explicitly-specialized arguments template void f0<char, unsigned char>(X<2, char&, unsigned char&>); template void f0<signed char, char>(X<2, signed char&, char&>); // FIXME: Extension of explicitly-specified arguments // template void f0<short, int>(X<3, short&, int&, long&>); } namespace DeductionWithConversion { template<char...> struct char_values { static const unsigned value = 0; }; template<int C1, char C3> struct char_values<C1, 12, C3> { static const unsigned value = 1; }; int check0[char_values<1, 12, 3>::value == 1? 1 : -1]; template<int...> struct int_values { static const unsigned value = 0; }; template<unsigned char C1, unsigned char C3> struct int_values<C1, 12, C3> { static const unsigned value = 1; }; int check1[int_values<256, 12, 3>::value == 0? 1 : -1]; int check2[int_values<3, 12, 3>::value == 1? 1 : -1]; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // This is a collection of various template metafunctions involving // variadic templates, which are meant to exercise common use cases. template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; template<typename...> struct tuple { }; template<int ...> struct int_tuple { }; template<typename T, typename U> struct pair { }; namespace Count { template<typename Head, typename ...Tail> struct count { static const unsigned value = 1 + count<Tail...>::value; }; template<typename T> struct count<T> { static const unsigned value = 1; }; int check1[count<int>::value == 1? 1 : -1]; int check2[count<float, double>::value == 2? 1 : -1]; int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1]; } namespace CountWithPackExpansion { template<typename ...> struct count; template<typename Head, typename ...Tail> struct count<Head, Tail...> { static const unsigned value = 1 + count<Tail...>::value; }; template<> struct count<> { static const unsigned value = 0; }; int check0[count<>::value == 0? 1 : -1]; int check1[count<int>::value == 1? 1 : -1]; int check2[count<float, double>::value == 2? 1 : -1]; int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1]; } namespace Replace { // Simple metafunction that replaces the template arguments of // template template parameters with 'int'. template<typename T> struct EverythingToInt; template<template<typename ...> class TT, typename T1, typename T2> struct EverythingToInt<TT<T1, T2> > { typedef TT<int, int> type; }; int check0[is_same<EverythingToInt<tuple<double, float>>::type, tuple<int, int>>::value? 1 : -1]; } namespace Math { template<int ...Values> struct double_values { typedef int_tuple<Values*2 ...> type; }; int check0[is_same<double_values<1, 2, -3>::type, int_tuple<2, 4, -6>>::value? 1 : -1]; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; int check1[is_same<square<1, 2, -3>::type, int_tuple<1, 4, 9>>::value? 1 : -1]; template<typename IntTuple> struct square_tuple; template<int ...Values> struct square_tuple<int_tuple<Values...>> { typedef int_tuple<(Values*Values)...> type; }; int check2[is_same<square_tuple<int_tuple<1, 2, -3> >::type, int_tuple<1, 4, 9>>::value? 1 : -1]; template<int ...Values> struct sum; template<int First, int ...Rest> struct sum<First, Rest...> { static const int value = First + sum<Rest...>::value; }; template<> struct sum<> { static const int value = 0; }; int check3[sum<1, 2, 3, 4, 5>::value == 15? 1 : -1]; template<int ... Values> struct lazy_sum { int operator()() { return sum<Values...>::value; } }; void f() { lazy_sum<1, 2, 3, 4, 5>()(); } } namespace ListMath { template<typename T, T ... V> struct add; template<typename T, T i, T ... V> struct add<T, i, V...> { static const T value = i + add<T, V...>::value; }; template<typename T> struct add<T> { static const T value = T(); }; template<typename T, T ... V> struct List { struct sum { static const T value = add<T, V...>::value; }; }; template<int ... V> struct ListI : public List<int, V...> { }; int check0[ListI<1, 2, 3>::sum::value == 6? 1 : -1]; } namespace Indices { template<unsigned I, unsigned N, typename IntTuple> struct build_indices_impl; template<unsigned I, unsigned N, int ...Indices> struct build_indices_impl<I, N, int_tuple<Indices...> > : build_indices_impl<I+1, N, int_tuple<Indices..., I> > { }; template<unsigned N, int ...Indices> struct build_indices_impl<N, N, int_tuple<Indices...> > { typedef int_tuple<Indices...> type; }; template<unsigned N> struct build_indices : build_indices_impl<0, N, int_tuple<> > { }; int check0[is_same<build_indices<5>::type, int_tuple<0, 1, 2, 3, 4>>::value? 1 : -1]; } namespace TemplateTemplateApply { template<typename T, template<class> class ...Meta> struct apply_each { typedef tuple<typename Meta<T>::type...> type; }; template<typename T> struct add_reference { typedef T& type; }; template<typename T> struct add_pointer { typedef T* type; }; template<typename T> struct add_const { typedef const T type; }; int check0[is_same<apply_each<int, add_reference, add_pointer, add_const>::type, tuple<int&, int*, int const>>::value? 1 : -1]; template<typename T, template<class> class ...Meta> struct apply_each_indirect { typedef typename apply_each<T, Meta...>::type type; }; int check1[is_same<apply_each_indirect<int, add_reference, add_pointer, add_const>::type, tuple<int&, int*, int const>>::value? 1 : -1]; template<typename T, typename ...Meta> struct apply_each_nested { typedef typename apply_each<T, Meta::template apply...>::type type; }; struct add_reference_meta { template<typename T> struct apply { typedef T& type; }; }; struct add_pointer_meta { template<typename T> struct apply { typedef T* type; }; }; struct add_const_meta { template<typename T> struct apply { typedef const T type; }; }; int check2[is_same<apply_each_nested<int, add_reference_meta, add_pointer_meta, add_const_meta>::type, tuple<int&, int*, int const>>::value? 1 : -1]; } namespace FunctionTypes { template<typename FunctionType> struct Arity; template<typename R, typename ...Types> struct Arity<R(Types...)> { static const unsigned value = sizeof...(Types); }; template<typename R, typename ...Types> struct Arity<R(Types......)> { // expected-warning {{varargs}} expected-note {{pack}} expected-note {{insert ','}} static const unsigned value = sizeof...(Types); }; template<typename R, typename T1, typename T2, typename T3, typename T4> struct Arity<R(T1, T2, T3, T4)>; // expected-note{{template is declared here}} int check0[Arity<int()>::value == 0? 1 : -1]; int check1[Arity<int(float, double)>::value == 2? 1 : -1]; int check2[Arity<int(float...)>::value == 1? 1 : -1]; int check3[Arity<int(float, double, long double...)>::value == 3? 1 : -1]; Arity<int(float, double, long double, char)> check4; // expected-error{{implicit instantiation of undefined template 'FunctionTypes::Arity<int (float, double, long double, char)>'}} } namespace SuperReplace { template<typename T> struct replace_with_int { typedef int type; }; template<template<typename ...> class TT, typename ...Types> struct replace_with_int<TT<Types...>> { typedef TT<typename replace_with_int<Types>::type...> type; }; int check0[is_same<replace_with_int<pair<tuple<float, double, short>, pair<char, unsigned char>>>::type, pair<tuple<int, int, int>, pair<int, int>>>::value? 1 : -1]; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics // Check for declaration matching with out-of-line declarations and // variadic templates, which involves proper computation of the // injected-class-name. template<typename T, typename ...Types> struct X0 { typedef T type; void f0(T); type f1(T); }; template<typename T, typename ...Types> void X0<T, Types...>::f0(T) { } template<typename T, typename ...Types> typename X0<T, Types...>::type X0<T, Types...>::f1(T) { } template<typename T, typename ...Types> struct X0<T, T, Types...> { typedef T* result; result f3(); template<typename... InnerTypes> struct Inner; }; template<typename T, typename ...Types> typename X0<T, T, Types...>::result X0<T, T, Types...>::f3() { return 0; } template<typename T, typename ...Types> template<typename ...InnerTypes> struct X0<T, T, Types...>::Inner { template<typename ...ReallyInner> void f4(); }; template<typename T, typename ...Types> template<typename ...InnerTypes> template<typename ...ReallyInner> void X0<T, T, Types...>::Inner<InnerTypes...>::f4() { } namespace rdar8848837 { // Out-of-line definitions that cause rebuilding in the current // instantiation. template<typename F> struct X; template<typename R, typename ...ArgTypes> struct X<R(ArgTypes...)> { X<R(ArgTypes...)> f(); }; template<typename R, typename ...ArgTypes> X<R(ArgTypes...)> X<R(ArgTypes...)>::f() { return *this; } X<int(float, double)> xif; template<unsigned> struct unsigned_c { }; template<typename ...ArgTypes> int g(ArgTypes...); template<typename F> struct X1; template<typename R, typename ...ArgTypes> struct X1<R(ArgTypes...)> { unsigned_c<sizeof(1 + g(ArgTypes()...))> f(); }; template<typename R, typename ...ArgTypes> unsigned_c<sizeof(1 + g(ArgTypes()...))> X1<R(ArgTypes...)>::f() { return unsigned_c<sizeof(int)>(); } X1<int(float, double)> xif2; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template <class T> struct AA { template <class C> virtual void g(C); // expected-error{{'virtual' cannot be specified on member function templates}} virtual void f(); };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.mem/p2.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template <typename> void quux(); void fun() { struct foo { template <typename> struct bar {}; // expected-error{{templates cannot be declared inside of a local class}} template <typename> void baz() {} // expected-error{{templates cannot be declared inside of a local class}} template <typename> void qux(); // expected-error{{templates cannot be declared inside of a local class}} }; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics template <class T> struct A { static T cond; template <class U> struct B { static T twice(U value) { return (cond ? value + value : value); } }; }; int foo() { A<bool>::cond = true; return A<bool>::B<int>::twice(4); } namespace PR6376 { template<typename T> struct X { template<typename Y> struct Y1 { }; // }; template<> struct X<float> { template<typename Y> struct Y1 { }; }; template<typename T, typename U> struct Z : public X<T>::template Y1<U> { }; Z<float, int> z0; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { template <class T> operator T*(); }; template <class T> A::operator T*() { return 0; } template <> A::operator char*(){ return 0; } // specialization template A::operator void*(); // explicit instantiation int main() { A a; int *ip; ip = a.operator int*(); } // PR5742 namespace PR5742 { template <class T> struct A { }; template <class T> struct B { }; struct S { template <class T> operator T(); } s; void f() { s.operator A<A<int> >(); s.operator A<B<int> >(); s.operator A<B<A<int> > >(); } } // PR5762 class Foo { public: template <typename T> operator T(); template <typename T> T As() { return this->operator T(); } template <typename T> T As2() { return operator T(); } int AsInt() { return this->operator int(); } }; template float Foo::As(); template double Foo::As2(); // Partial ordering with conversion function templates. struct X0 { template<typename T> operator T*() { T x = 1; // expected-note{{variable 'x' declared const here}} x = 17; // expected-error{{cannot assign to variable 'x' with const-qualified type 'const int'}} } template<typename T> operator T*() const; // expected-note{{explicit instantiation refers here}} template<typename T> operator const T*() const { T x = T(); return x; // expected-error{{cannot initialize return object of type 'const char *' with an lvalue of type 'char'}} \ // expected-error{{cannot initialize return object of type 'const int *' with an lvalue of type 'int'}} } }; template X0::operator const char*() const; // expected-note{{'X0::operator const char *<char>' requested here}} template X0::operator const int*(); // expected-note{{'X0::operator const int *<const int>' requested here}} template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}} void test_X0(X0 x0, const X0 &x0c) { x0.operator const int*(); // expected-note{{in instantiation of function template specialization}} x0.operator float *(); x0c.operator const char*(); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<class T> class A { }; class X { template<class T> friend class A<T*>; // expected-error{{partial specialization cannot be declared as a friend}} };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<typename T> struct X1 { friend void f6(int) { } // expected-error{{redefinition of}} \ // expected-note{{previous definition}} }; X1<int> x1a; X1<float> x1b; // expected-note {{in instantiation of}} template<typename T> struct X2 { operator int(); friend void f(int x) { } // expected-error{{redefinition}} \ // expected-note{{previous definition}} }; int array0[sizeof(X2<int>)]; int array1[sizeof(X2<float>)]; // expected-note{{instantiation of}} void g() { X2<int> xi; f(xi); X2<float> xf; f(xf); } template<typename T> struct X3 { operator int(); friend void h(int x); }; int array2[sizeof(X3<int>)]; int array3[sizeof(X3<float>)]; void i() { X3<int> xi; h(xi); X3<float> xf; h(xf); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template <class T> class A { typedef int Member; }; class B { template <class T> friend class A; template <class T> friend class Undeclared; template <class T> friend typename A<T>::Member; // expected-error {{friend type templates must use an elaborated type}} };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
// RUN: %clang_cc1 -verify -emit-llvm-only %s namespace test0 { template <typename T> struct Num { T value_; public: Num(T value) : value_(value) {} T get() const { return value_; } template <typename U> struct Rep { U count_; Rep(U count) : count_(count) {} friend Num operator*(const Num &a, const Rep &n) { Num x = 0; for (U count = n.count_; count; --count) x += a; return x; } }; friend Num operator+(const Num &a, const Num &b) { return a.value_ + b.value_; } Num& operator+=(const Num& b) { value_ += b.value_; return *this; } class Representation {}; friend class Representation; }; class A { template <typename T> friend bool iszero(const A &a) throw(); }; template <class T> class B_iterator; template <class T> class B { friend class B_iterator<T>; }; int calc1() { Num<int> left = -1; Num<int> right = 1; Num<int> result = left + right; return result.get(); } int calc2() { Num<int> x = 3; Num<int>::Rep<char> n = (char) 10; Num<int> result = x * n; return result.get(); } } // Reduced from GNU <locale> namespace test1 { class A { bool b; // expected-note {{declared private here}} template <typename T> friend bool has(const A&); }; template <typename T> bool has(const A &x) { return x.b; } template <typename T> bool hasnot(const A &x) { return x.b; // expected-error {{'b' is a private member of 'test1::A'}} } } namespace test2 { class A { bool b; // expected-note {{declared private here}} template <typename T> friend class HasChecker; }; template <typename T> class HasChecker { bool check(A *a) { return a->b; } }; template <typename T> class HasNotChecker { bool check(A *a) { return a->b; // expected-error {{'b' is a private member of 'test2::A'}} } }; } namespace test3 { class Bool; template <class T> class User; template <class T> T transform(class Bool, T); class Bool { friend class User<bool>; friend bool transform<>(Bool, bool); bool value; // expected-note 2 {{declared private here}} }; template <class T> class User { static T compute(Bool b) { return b.value; // expected-error {{'value' is a private member of 'test3::Bool'}} } }; template <class T> T transform(Bool b, T value) { if (b.value) // expected-error {{'value' is a private member of 'test3::Bool'}} return value; return value + 1; } template bool transform(Bool, bool); template int transform(Bool, int); // expected-note {{requested here}} template class User<bool>; template class User<int>; // expected-note {{requested here}} } namespace test4 { template <class T> class A { template <class T0> friend class B; bool foo(const A<T> *) const; }; template <class T> class B { bool bar(const A<T> *a, const A<T> *b) { return a->foo(b); } }; template class B<int>; } namespace test5 { template <class T, class U=int> class A {}; template <class T> class B { template <class X, class Y> friend class A; }; template class B<int>; template class A<int>; } namespace Dependent { template<typename T, typename Traits> class X; template<typename T, typename Traits> X<T, Traits> operator+(const X<T, Traits>&, const T*); template<typename T, typename Traits> class X { typedef typename Traits::value_type value_type; friend X operator+<>(const X&, const value_type*); }; } namespace test7 { template <class T> class A { // expected-note {{declared here}} friend class B; int x; // expected-note {{declared private here}} }; class B { int foo(A<int> &a) { return a.x; } }; class C { int foo(A<int> &a) { return a.x; // expected-error {{'x' is a private member of 'test7::A<int>'}} } }; // This shouldn't crash. template <class T> class D { friend class A; // expected-error {{elaborated type refers to a template}} }; template class D<int>; } namespace test8 { template <class N> class A { static int x; template <class T> friend void foo(); }; template class A<int>; template <class T> void foo() { A<int>::x = 0; } template void foo<int>(); } namespace test9 { template <class T> class A { class B; class C; int foo(B *b) { return b->x; } int foo(C *c) { return c->x; // expected-error {{'x' is a private member}} } class B { int x; friend int A::foo(B*); }; class C { int x; // expected-note {{declared private here}} }; }; template class A<int>; // expected-note {{in instantiation}} } namespace test10 { template <class T> class A; template <class T> A<T> bar(const T*, const A<T>&); template <class T> class A { private: void foo(); // expected-note {{declared private here}} friend A bar<>(const T*, const A<T>&); }; template <class T> A<T> bar(const T *l, const A<T> &r) { A<T> l1; l1.foo(); A<char> l2; l2.foo(); // expected-error {{'foo' is a private member of 'test10::A<char>'}} return l1; } template A<int> bar<int>(const int *, const A<int> &); // expected-note {{in instantiation}} } // PR6752: this shouldn't crash. namespace test11 { struct Foo { template<class A> struct IteratorImpl { template<class T> friend class IteratorImpl; }; }; template struct Foo::IteratorImpl<int>; template struct Foo::IteratorImpl<long>; } // PR6827 namespace test12 { template <typename T> class Foo; template <typename T> Foo<T> foo(T* t){ return Foo<T>(t, true); } template <typename T> class Foo { public: Foo(T*); friend Foo<T> foo<T>(T*); private: Foo(T*, bool); // expected-note {{declared private here}} }; // Should work. int globalInt; Foo<int> f = foo(&globalInt); // Shouldn't work. long globalLong; template <> Foo<long> foo(long *t) { Foo<int> s(&globalInt, false); // expected-error {{calling a private constructor}} return Foo<long>(t, true); } } // PR6514 namespace test13 { template <int N, template <int> class Temp> class Role : public Temp<N> { friend class Temp<N>; int x; }; template <int N> class Foo { void foo(Role<N, test13::Foo> &role) { (void) role.x; } }; template class Foo<0>; } namespace test14 { template <class T> class B; template <class T> class A { friend void B<T>::foo(); static void foo(); // expected-note {{declared private here}} }; template <class T> class B { public: void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test14::A<long>'}} }; template class B<int>; // expected-note {{in instantiation}} } namespace test15 { template <class T> class B; template <class T> class A { friend void B<T>::foo(); // This shouldn't be misrecognized as a templated-scoped reference. template <class U> friend void B<T>::bar(U); static void foo(); // expected-note {{declared private here}} }; template <class T> class B { public: void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test15::A<long>'}} }; template <> class B<float> { public: void foo() { return A<float>::foo(); } template <class U> void bar(U u) { (void) A<float>::foo(); } }; template class B<int>; // expected-note {{in instantiation}} } namespace PR10913 { template<class T> class X; template<class T> void f(X<T> *x) { x->member = 0; } template<class U, class T> void f2(X<T> *x) { x->member = 0; // expected-error{{'member' is a protected member of 'PR10913::X<int>'}} } template<class T> class X { friend void f<T>(X<T> *x); friend void f2<T>(X<int> *x); protected: int member; // expected-note{{declared protected here}} }; template void f(X<int> *); template void f2<int>(X<int> *); template void f2<float>(X<int> *); // expected-note{{in instantiation of function template specialization 'PR10913::f2<float, int>' requested here}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s namespace test0 { template <class T> class A { class Member {}; }; class B { template <class T> friend class A<T>::Member; // expected-warning {{not supported}} int n; }; A<int> a; B b; } // rdar://problem/8204127 namespace test1 { template <class T> struct A; class C { static void foo(); template <class T> friend void A<T>::f(); // expected-warning {{not supported}} }; template <class T> struct A { void f() { C::foo(); } }; template <class T> struct A<T*> { void f() { C::foo(); } }; template <> struct A<char> { void f() { C::foo(); } }; } // FIXME: these should fail! namespace test2 { template <class T> struct A; class C { static void foo(); template <class T> friend void A<T>::g(); // expected-warning {{not supported}} }; template <class T> struct A { void f() { C::foo(); } }; template <class T> struct A<T*> { void f() { C::foo(); } }; template <> struct A<char> { void f() { C::foo(); } }; } // Tests 3, 4 and 5 were all noted in <rdar://problem/8540527>. namespace test3 { template <class T> struct A { struct Inner { static int foo(); }; }; template <class U> class C { int i; template <class T> friend struct A<T>::Inner; // expected-warning {{not supported}} }; template <class T> int A<T>::Inner::foo() { C<int> c; c.i = 0; return 0; } int test = A<int>::Inner::foo(); } namespace test4 { template <class T> struct X { template <class U> void operator+=(U); template <class V> template <class U> friend void X<V>::operator+=(U); // expected-warning {{not supported}} }; void test() { X<int>() += 1.0; } } namespace test5 { template<template <class> class T> struct A { template<template <class> class U> friend void A<U>::foo(); // expected-warning {{not supported}} }; template <class> struct B {}; template class A<B>; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-1y.cpp
// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s // -- The argument list of the specialization shall not be identical // to the implicit argument list of the primary template. template<typename T, int N, template<typename> class X> int v1; template<typename T, int N, template<typename> class X> int v1<T, N, X>; // expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} template<typename...T> int v2; template<typename...T> int v2<T...>; // expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} template<int...N> int v3; template<int...N> int v3<N...>; // expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} template<template<typename> class...X> int v4; template<template<typename> class...X> int v4<X...>; // expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} template<typename Outer> struct X { template<typename Inner> static int y; template<typename Inner> static int y<Outer>; // expected-warning {{cannot be deduced}} expected-note {{'Inner'}} template<typename Inner> static int y<Inner>; // expected-error {{does not specialize}} }; template<typename Outer> template<typename Inner> int X<Outer>::y<Outer>; // expected-warning {{cannot be deduced}} expected-note {{'Inner'}} template<typename Outer> template<typename Inner> int X<Outer>::y<Inner>; // expected-error {{does not specialize}} // FIXME: Merging this with the above class causes an assertion failure when // instantiating one of the bogus partial specializations. template<typename Outer> struct Y { template<typename Inner> static int y; }; template<> template<typename Inner> int Y<int>::y<Inner>; // expected-error {{does not specialize}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template<int ...Values> struct X1; template<int ...Values> struct X1<0, Values+1 ...>; // expected-error{{non-type template argument depends on a template parameter of the partial specialization}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics // PR8905 template<char C1, char C2> struct X { static const bool value = 0; }; template<int C1> struct X<C1, C1> { static const bool value = 1; }; int check0[X<1, 2>::value == 0? 1 : -1]; int check1[X<1, 1>::value == 1? 1 : -1]; template<int, int, int> struct int_values { static const unsigned value = 0; }; template<unsigned char C1, unsigned char C3> struct int_values<C1, 12, C3> { static const unsigned value = 1; }; int check2[int_values<256, 12, 3>::value == 0? 1 : -1];
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // -- The argument list of the specialization shall not be identical // to the implicit argument list of the primary template. template<typename T, typename ...Types> struct X1; template<typename T, typename ...Types> struct X1<T, Types...> // expected-error{{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} { };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // Test class template partial specializations of member templates. template<typename T> struct X0 { template<typename U> struct Inner0 { static const unsigned value = 0; }; template<typename U> struct Inner0<U*> { static const unsigned value = 1; }; }; template<typename T> template<typename U> struct X0<T>::Inner0<const U*> { static const unsigned value = 2; }; int array0[X0<int>::Inner0<int>::value == 0? 1 : -1]; int array1[X0<int>::Inner0<int*>::value == 1? 1 : -1]; int array2[X0<int>::Inner0<const int*>::value == 2? 1 : -1]; // Make sure we can provide out-of-line class template partial specializations // for member templates (and instantiate them). template<class T> struct A { struct C { template<class T2> struct B; }; }; // partial specialization of A<T>::C::B<T2> template<class T> template<class T2> struct A<T>::C::B<T2*> { }; A<short>::C::B<int*> absip; // Check for conflicts during template instantiation. template<typename T, typename U> struct Outer { template<typename X, typename Y> struct Inner; template<typename Y> struct Inner<T, Y> {}; // expected-note{{previous}} template<typename Y> struct Inner<U, Y> {}; // expected-error{{cannot be redeclared}} }; Outer<int, int> outer; // expected-note{{instantiation}} // Test specialization of class template partial specialization members. template<> template<typename Z> struct X0<float>::Inner0<Z*> { static const unsigned value = 3; }; int array3[X0<float>::Inner0<int>::value == 0? 1 : -1]; int array4[X0<float>::Inner0<int*>::value == 3? 1 : -1]; int array5[X0<float>::Inner0<const int*>::value == 2? 1 : -1]; namespace rdar8651930 { template<typename OuterT> struct Outer { template<typename T, typename U> struct Inner; template<typename T> struct Inner<T, T> { static const bool value = true; }; template<typename T, typename U> struct Inner { static const bool value = false; }; }; int array0[Outer<int>::Inner<int, int>::value? 1 : -1]; int array1[Outer<int>::Inner<int, float>::value? -1 : 1]; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<typename T, int N> struct A; template<typename T> // expected-note{{previous template declaration}} struct A<T*, 2> { void f0(); void f1(); void f2(); }; template<> struct A<int, 1> { void g0(); }; // FIXME: We should probably give more precise diagnostics here, but the // diagnostics we give aren't terrible. // FIXME: why not point to the first parameter that's "too many"? template<typename T, int N> // expected-error{{too many template parameters}} void A<T*, 2>::f0() { } template<typename T, int N> void A<T, N>::f1() { } // expected-error{{out-of-line definition}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics template<typename T, int N> struct A; template<typename T> struct A<T*, 2> { A(T); ~A(); void f(T*); operator T*(); static T value; }; template<class X> void A<X*, 2>::f(X*) { } template<class X> X A<X*, 2>::value; template<class X> A<X*, 2>::A(X) { value = 0; } template<class X> A<X*, 2>::~A() { } template<class X> A<X*, 2>::operator X*() { return 0; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics template<int I, int J, class T> struct X { static const int value = 0; }; template<int I, int J> struct X<I, J, int> { static const int value = 1; }; template<int I> struct X<I, I, int> { static const int value = 2; }; int array0[X<0, 0, float>::value == 0? 1 : -1]; int array1[X<0, 1, int>::value == 1? 1 : -1]; int array2[X<0, 0, int>::value == 2? 1 : -1]; namespace DependentSubstPartialOrdering { template<typename T, typename U = void, typename V = void> struct X { static const unsigned value = 1; }; template<typename T, typename U> struct X<T, U, typename T::is_b> { static const unsigned value = 2; }; template<typename T> struct X<T, typename T::is_a, typename T::is_b> { static const unsigned value = 3; }; struct X1 { }; struct X2 { typedef void is_b; }; struct X3 { typedef void is_a; typedef void is_b; }; int check_X1[X<X1, void, void>::value == 1? 1 : -1]; int check_X2[X<X2, void, void>::value == 2? 1 : -1]; int check_X3[X<X3, void, void>::value == 3? 1 : -1]; }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics // All of these function templates are distinct. template<typename T> void f0(T) { } template<typename T, typename U> void f0(T) { } template<typename T, typename U> void f0(U) { } void f0(); template<typename T> void f0(T*); void f0(int); template<int I> void f0(); template<typename T> void f0();
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<typename T> void f0(T) { } // expected-note{{previous}} template<class U> void f0(U) { } // expected-error{{redefinition}} template<int I> void f0() { } // expected-note{{previous}} template<int> void f0() { } // expected-error{{redefinition}} typedef int INT; template<template<class T, T Value1, INT> class X> void f0() { } // expected-note{{previous}} template<template<typename T, T Value1, int> class> void f0() { } // expected-error{{redefinition}} template<typename T> struct MetaFun; template<typename T> typename MetaFun<T*>::type f0(const T&) { while (1) {} } // expected-note{{previous}} template<class U> typename MetaFun<U*>::type f0(const U&) { while (1) {} } // expected-error{{redefinition}} // FIXME: We need canonicalization of expressions for this to work // template<int> struct A { }; // template<int I> void f0(A<I>) { } // Xpected-note{{previous}} // template<int J> void f0(A<J>) { } // Xpected-error{{redefinition}}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<int N, int M> struct A0 { void g0(); }; template<int X, int Y> void f0(A0<X, Y>) { } // expected-note{{previous}} template<int N, int M> void f0(A0<M, N>) { } template<int V1, int V2> void f0(A0<V1, V2>) { } // expected-error{{redefinition}} template<int X, int Y> void f1(A0<0, (X + Y)>) { } // expected-note{{previous}} template<int X, int Y> void f1(A0<0, (X - Y)>) { } template<int A, int B> void f1(A0<0, (A + B)>) { } // expected-error{{redefinition}} template<int X, int Y> void A0<X, Y>::g0() { }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s template<class T> struct A { A(); }; template<class T> int &f(T); template<class T> float &f(T*); template<class T> double &f(const T*); template<class T> void g(T); // expected-note{{candidate}} template<class T> void g(T&); // expected-note{{candidate}} template<class T> int &h(const T&); template<class T> float &h(A<T>&); void m() { const int *p; double &dr1 = f(p); float x; g(x); // expected-error{{ambiguous}} A<int> z; float &fr1 = h(z); const A<int> z2; int &ir1 = h(z2); } namespace core_26909 { template<typename T> struct A {}; template<typename T, typename U> void f(T&, U); // expected-note {{candidate}} template<typename T, typename U> void f(T&&, A<U>); // expected-note {{candidate}} expected-warning 0-1{{extension}} template<typename T, typename U> void g(const T&, U); // expected-note {{candidate}} template<typename T, typename U> void g(T&, A<U>); // expected-note {{candidate}} void h(int a, const char b, A<int> c) { f(a, c); // expected-error{{ambiguous}} g(b, c); // expected-error{{ambiguous}} } } namespace PR22435 { template<typename T, typename U> void foo(void (*)(T), const U &); // expected-note {{candidate}} template<typename T, typename U> bool foo(void (*)(T &), U &); // expected-note {{candidate}} void bar(const int x) { bool b = foo<char>(0, x); } // expected-error {{ambiguous}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // expected-no-diagnostics namespace OrderWithStaticMember { struct A { template<class T> int g(T**, int=0) { return 0; } template<class T> static int g(T*) { return 1; } }; void f() { A a; int **p; a.g(p); } } #if __cplusplus >= 201103L namespace OperatorWithRefQualifier { struct A { }; template<class T> struct B { template<class R> int &operator*(R&) &&; }; template<class T, class R> float &operator*(T&&, R&); void test() { A a; B<A> b; float &ir = b * a; int &ir2 = B<A>() * a; } } namespace PR17075 { template <typename T> struct V {}; struct S { template<typename T> S &operator>>(T &t) = delete; }; template<typename T> S &operator>>(S &s, V<T> &v); void f(S s, V<int> v) { s >> v; } } #endif
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics template<class T> int &f(T); template<class T> float &f(T*, int=1); template<class T> int &g(T); template<class T> float &g(T*, ...); int main() { int* ip; float &fr1 = f(ip); float &fr2 = g(ip); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // The example given in the standard (this is rejected for other reasons anyway). template<class T> struct A; template<class T> using B = typename A<T>::U; // expected-error {{no type named 'U' in 'A<T>'}} template<class T> struct A { typedef B<T> U; // expected-note {{in instantiation of template type alias 'B' requested here}} }; B<short> b; template<typename T> using U = int; template<typename ...T> void f(U<T> ...xs); void g() { f<void,void,void>(1, 2, 3); } // FIXME: This is illegal, but probably only because CWG1044 missed this paragraph. template<typename T> using U = U<T>;
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template<typename T> using U = T; using I = U<U<U<U<int>>>>; using I = int; template<typename A, typename B> using Fst = A; template<typename A, typename B> using Snd = B; using I = Fst<Snd<char,int>,double>; namespace StdExample { // Prerequisites for example. template<class T, class A> struct vector { /* ... */ }; template<class T> struct Alloc {}; template<class T> using Vec = vector<T, Alloc<T>>; Vec<int> v; template<class T> void process(Vec<T>& v) // expected-note {{previous definition is here}} { /* ... */ } template<class T> void process(vector<T, Alloc<T>>& w) // expected-error {{redefinition of 'process'}} { /* ... */ } template<template<class> class TT> void f(TT<int>); // expected-note {{candidate template ignored}} template<template<class,class> class TT> void g(TT<int, Alloc<int>>); int h() { f(v); // expected-error {{no matching function for call to 'f'}} g(v); // OK: TT = vector } // v's type is same as vector<int, Alloc<int>>. using VTest = vector<int, Alloc<int>>; using VTest = decltype(v); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics template<typename T> using U = T; // The name of the alias template is a template-name. U<char> x; void f(U<int>); typedef U<U<U<U<int>>>> I;
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<typename T, typename U> struct X0 { struct Inner; }; template<typename T, typename U> struct X0<T, U>::Inner { T x; U y; void f() { x = y; } // expected-error{{incompatible}} }; void test(int i, float f) { X0<int, float>::Inner inner; inner.x = 5; inner.y = 3.4; inner.f(); X0<int*, float *>::Inner inner2; inner2.x = &i; inner2.y = &f; inner2.f(); // expected-note{{instantiation}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics template<typename T> struct X1 { }; template<typename T> struct X0 { typedef int size_type; typedef T value_type; size_type f0() const; value_type *f1(); X1<value_type*> f2(); }; template<typename T> typename X0<T>::size_type X0<T>::f0() const { return 0; } template<typename U> typename X0<U>::value_type *X0<U>::f1() { return 0; }; template<typename U> X1<typename X0<U>::value_type*> X0<U>::f2() { return 0; };
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // Test instantiation of member functions of class templates defined out-of-line template<typename T, typename U> struct X0 { void f(T *t, const U &u); void f(T *); }; template<typename T, typename U> void X0<T, U>::f(T *t, const U &u) { *t = u; // expected-warning{{indirection on operand of type 'void *'}} expected-error{{not assignable}} } void test_f(X0<float, int> xfi, X0<void, int> xvi, float *fp, void *vp, int i) { xfi.f(fp, i); xvi.f(vp, i); // expected-note{{instantiation}} }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<typename T, typename U> // expected-note{{previous template}} class X0 { public: typedef int size_type; X0(int); ~X0(); void f0(const T&, const U&); T& operator[](int i) const; void f1(size_type) const; void f2(size_type) const; void f3(size_type) const; void f4() ; operator T*() const; T value; }; template<typename T, typename U> void X0<T, U>::f0(const T&, const U&) { // expected-note{{previous definition}} } template<class X, class Y> X& X0<X, Y>::operator[](int i) const { (void)i; return value; } template<class X, class Y> void X0<X, Y>::f1(int) const { } template<class X, class Y> void X0<X, Y>::f2(size_type) const { } template<class X, class Y, class Z> // expected-error{{too many template parameters}} void X0<X, Y>::f3(size_type) const { } template<class X, class Y> void X0<Y, X>::f4() { } // expected-error{{does not refer}} // FIXME: error message should probably say, "redefinition of 'X0<T, U>::f0'" // rather than just "redefinition of 'f0'" template<typename T, typename U> void X0<T, U>::f0(const T&, const U&) { // expected-error{{redefinition}} } // Test out-of-line constructors, destructors template<typename T, typename U> X0<T, U>::X0(int x) : value(x) { } template<typename T, typename U> X0<T, U>::~X0() { } // Test out-of-line conversion functions. template<typename T, typename U> X0<T, U>::operator T*() const { return &value; } namespace N { template <class X> class A {void a();}; } namespace N { template <class X> void A<X>::a() {} } // PR5566 template<typename T> struct X1 { template<typename U> struct B { void f(); }; }; template<typename T> template<typename U> void X1<T>::template B<U>::f() { } // PR5527 template <template <class> class T> class X2 { template <class F> class Bar { void Func(); }; }; template <template <class> class T> template <class F> void X2<T>::Bar<F>::Func() {} // PR5528 template <template <class> class T> class X3 { void F(); }; template <template <class> class T> void X3<T>::F() {}
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics extern "C" void * malloc(int); template <typename T> struct A { void *malloc(int); }; template <typename T> inline void *A<T>::malloc(int) { return 0; } void f() { malloc(10); }
0
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class
repos/DirectXShaderCompiler/tools/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
// RUN: %clang_cc1 -std=c++11 -verify %s template<typename T> struct A { enum E : T; // expected-note {{here}} E v; E f() { return A::e1; } // expected-error {{no member named 'e1' in 'A<T>'}} E g() { return E::e1; } E h(); }; A<int> a; A<int>::E a0 = A<int>().v; int n = A<int>::E::e1; // expected-error {{implicit instantiation of undefined member}} template<typename T> enum A<T>::E : T { e1, e2 }; // expected-note 2 {{declared here}} // FIXME: Now that A<T>::E is defined, we are supposed to inject its enumerators // into the already-instantiated class A<T>. This seems like a really bad idea, // though, so we don't implement that, but what we do implement is inconsistent. // // Either do as the standard says, or only include enumerators lexically defined // within the class in its scope. A<int>::E a1 = A<int>::e1; // expected-error {{no member named 'e1' in 'A<int>'; did you mean simply 'e1'?}} A<char>::E a2 = A<char>::e2; template<typename T> typename A<T>::E A<T>::h() { return e2; } A<short>::E a3 = A<short>().h(); template<typename T> struct B { enum class E; E v; E f() { return E::e1; } E g(); }; B<int> b; B<int>::E b0 = B<int>().v; template<typename T> enum class B<T>::E { e1, e2 }; B<int>::E b1 = B<int>::E::e1; B<char>::E b2 = B<char>::E::e2; template<typename T> typename B<T>::E B<T>::g() { return e2; } B<short>::E b3 = B<short>().g(); // Enumeration members of class templates can be explicitly specialized. For // unscoped enumerations, specializations must be defined before the primary // template is, since otherwise the primary template will be implicitly // instantiated when we parse the nested name specifier. template<> enum A<long long>::E : long long { e3, e4 }; // expected-error {{explicit specialization of 'E' after instantiation}} expected-note {{first required here}} template<> enum class B<long long>::E { e3, e4 }; B<long long>::E b4 = B<long long>::E::e4; B<long>::E b5; template<> enum class B<long>::E { e5 }; void fb5() { b5 = decltype(b5)::e5; } B<long>::E b6 = B<long>::E::e5; template<typename T> struct C { enum class E : T; }; template<> enum class C<long long>::E : long long { e3, e4 }; C<long long>::E c0 = C<long long>::E::e3; C<long>::E c1; template<> enum class C<long>::E : long { e5 }; void fc1() { c1 = decltype(c1)::e5; } C<long>::E c2 = C<long>::E::e5; template<> enum class C<int>::E : int { e6 }; template<typename T> enum class C<T>::E : T { e0 }; C<int>::E c3 = C<int>::E::e6; C<int>::E c4 = C<int>::E::e0; // expected-error {{no member named 'e0' in 'C<int>::E'}} // Enumeration members can't be partially-specialized. template<typename T> enum class B<T*>::E { e5, e6 }; // expected-error {{nested name specifier for a declaration cannot depend on a template parameter}} // Explicit specializations can be forward-declared. template<typename T> struct D { enum class E { e1 }; }; template<> enum class D<int>::E; D<int>::E d1 = D<int>::E::e1; // expected-error {{incomplete type 'D<int>::E'}} template<> enum class D<int>::E { e2 }; D<int>::E d2 = D<int>::E::e2; D<char>::E d3 = D<char>::E::e1; // expected-note {{first required here}} D<char>::E d4 = D<char>::E::e2; // expected-error {{no member named 'e2' in 'D<char>::E'; did you mean simply 'e2'?}} template<> enum class D<char>::E { e3 }; // expected-error {{explicit specialization of 'E' after instantiation}} template<> enum class D<short>::E; struct F { // Per C++11 [class.friend]p3, these friend declarations have no effect. // Only classes and functions can be friends. template<typename T> friend enum D<T>::E; template<> friend enum D<short>::E; template<> friend enum D<double>::E { e3 }; // expected-error {{cannot define a type in a friend declaration}} private: static const int n = 1; // expected-note {{private here}} }; template<> enum class D<short>::E { e = F::n // expected-error {{private member}} }; class Access { friend class X; template<typename T> class Priv { friend class X; enum class E : T; }; class S { typedef int N; // expected-note {{here}} static const int k = 3; // expected-note {{here}} friend class Priv<char>; }; static const int k = 5; }; template<> enum class Access::Priv<Access::S::N>::E : Access::S::N { // expected-error {{private member}} a = Access::k, // ok b = Access::S::k // expected-error {{private member}} }; template<typename T> enum class Access::Priv<T>::E : T { c = Access::k, d = Access::S::k }; class X { Access::Priv<int>::E a = Access::Priv<int>::E::a; Access::Priv<char>::E c = Access::Priv<char>::E::d; // FIXME: We should see an access error for this enumerator. Access::Priv<short>::E b = Access::Priv<short>::E::d; };