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
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-unused-label-error.cpp
// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -verify %s static int unused_local_static; namespace PR8455 { void f() { A: // expected-warning {{unused label 'A'}} __attribute__((unused)) int i; // attribute applies to variable B: // attribute applies to label __attribute__((unused)); int j; // expected-warning {{unused variable 'j'}} } void g() { C: // unused label 'C' will not appear here because an error has occurred __attribute__((unused)) #pragma weak unused_local_static // expected-error {{expected ';' after __attribute__}} ; } void h() { D: // expected-warning {{unused label 'D'}} #pragma weak unused_local_static __attribute__((unused)) // expected-warning {{declaration does not declare anything}} ; } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/microsoft-dtor-lookup-cxx11.cpp
// RUN: %clang_cc1 -triple i686-pc-win32 -std=c++11 -verify %s struct S { virtual ~S() = delete; // expected-note {{'~S' has been explicitly marked deleted here}} void operator delete(void*, int); void operator delete(void*, double); } s; // expected-error {{attempt to use a deleted function}} struct T { // expected-note{{virtual destructor requires an unambiguous, accessible 'operator delete'}} virtual ~T() = default; // expected-note {{explicitly defaulted function was implicitly deleted here}} void operator delete(void*, int); void operator delete(void*, double); } t; // expected-error {{attempt to use a deleted function}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/accessible-base.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { int a; }; struct X1 : virtual A {}; struct Y1 : X1, virtual A {}; struct Y2 : X1, A // expected-warning{{direct base 'A' is inaccessible due to ambiguity:\n struct Y2 -> struct X1 -> struct A\n struct Y2 -> struct A}} {}; struct X2 : A {}; struct Z1 : X2, virtual A // expected-warning{{direct base 'A' is inaccessible due to ambiguity:\n struct Z1 -> struct X2 -> struct A\n struct Z1 -> struct A}} {}; struct Z2 : X2, A // expected-warning{{direct base 'A' is inaccessible due to ambiguity:\n struct Z2 -> struct X2 -> struct A\n struct Z2 -> struct A}} {};
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-tautological-undefined-compare.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-undefined-compare %s // RUN: %clang_cc1 -fsyntax-only -verify -Wno-tautological-compare -Wtautological-undefined-compare %s // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-compare %s void test1(int &x) { if (x == 1) { } if (&x == 0) { } // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&x != 0) { } // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} } class test2 { test2() : x(y) {} void foo() { if (this == 0) { } // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (this != 0) { } // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true}} } void bar() { if (x == 1) { } if (&x == 0) { } // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&x != 0) { } // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} } int &x; int y; }; namespace function_return_reference { int& get_int(); // expected-note@-1 4{{'get_int' returns a reference}} class B { public: static int &stat(); // expected-note@-1 4{{'stat' returns a reference}} int &get(); // expected-note@-1 8{{'get' returns a reference}} }; void test() { if (&get_int() == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&(get_int()) == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&get_int() != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&(get_int()) != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&B::stat() == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&(B::stat()) == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&B::stat() != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&(B::stat()) != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} B b; if (&b.get() == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&(b.get()) == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&b.get() != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&(b.get()) != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} B* b_ptr = &b; if (&b_ptr->get() == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&(b_ptr->get()) == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&b_ptr->get() != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&(b_ptr->get()) != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} int& (B::*m_ptr)() = &B::get; if (&(b.*m_ptr)() == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&((b.*m_ptr)()) == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&(b.*m_ptr)() != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&((b.*m_ptr)()) != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} int& (*f_ptr)() = &get_int; if (&(*f_ptr)() == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&((*f_ptr)()) == 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} if (&(*f_ptr)() != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} if (&((*f_ptr)()) != 0) {} // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} } } namespace macros { #define assert(x) if (x) {} void test(int &x) { assert(&x != 0); // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} assert(&x == 0); // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} assert(&x != 0 && "Expecting valid reference"); // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}} assert(&x == 0 && "Expecting invalid reference"); // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}} } class S { void test() { assert(this != 0); // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true}} assert(this == 0); // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false}} assert(this != 0 && "Expecting valid reference"); // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true}} assert(this == 0 && "Expecting invalid reference"); // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false}} } }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overload-call-copycon.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs class X { }; // expected-note {{the implicit copy constructor}} \ // expected-note{{the implicit default constructor}} int& copycon(X x); // expected-note{{passing argument to parameter}} float& copycon(...); void test_copycon(X x, X const xc, X volatile xv) { int& i1 = copycon(x); int& i2 = copycon(xc); copycon(xv); // expected-error{{no matching constructor}} } class A { public: A(A&); // expected-note{{would lose const qualifier}} \ // expected-note{{no known conversion}} }; class B : public A { }; // expected-note{{would lose const qualifier}} \ // expected-note{{would lose volatile qualifier}} \ // expected-note 2{{requires 0 arguments}} short& copycon2(A a); // expected-note{{passing argument to parameter}} int& copycon2(B b); // expected-note 2{{passing argument to parameter}} float& copycon2(...); void test_copycon2(A a, const A ac, B b, B const bc, B volatile bv) { int& i1 = copycon2(b); copycon2(bc); // expected-error{{no matching constructor}} copycon2(bv); // expected-error{{no matching constructor}} short& s1 = copycon2(a); copycon2(ac); // expected-error{{no matching constructor}} } int& copycon3(A a); // expected-note{{passing argument to parameter 'a' here}} float& copycon3(...); void test_copycon3(B b, const B bc) { int& i1 = copycon3(b); copycon3(bc); // expected-error{{no matching constructor}} } class C : public B { }; float& copycon4(A a); int& copycon4(B b); void test_copycon4(C c) { int& i = copycon4(c); };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/enum-scoped.cpp
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s enum class E1 { Val1 = 1L }; enum struct E2 { Val1 = '\0' }; E1 v1 = Val1; // expected-error{{undeclared identifier}} E1 v2 = E1::Val1; static_assert(sizeof(E1) == sizeof(int), "bad size"); static_assert(sizeof(E1::Val1) == sizeof(int), "bad size"); static_assert(sizeof(E2) == sizeof(int), "bad size"); static_assert(sizeof(E2::Val1) == sizeof(int), "bad size"); E1 v3 = E2::Val1; // expected-error{{cannot initialize a variable}} int x1 = E1::Val1; // expected-error{{cannot initialize a variable}} enum E3 : char { Val2 = 1 }; E3 v4 = Val2; E1 v5 = Val2; // expected-error{{cannot initialize a variable}} static_assert(sizeof(E3) == 1, "bad size"); int x2 = Val2; int a1[Val2]; int a2[E1::Val1]; // expected-error{{size of array has non-integer type}} int* p1 = new int[Val2]; int* p2 = new int[E1::Val1]; // expected-error{{array size expression must have integral or unscoped enumeration type, not 'E1'}} enum class E4 { e1 = -2147483648, // ok e2 = 2147483647, // ok e3 = 2147483648 // expected-error{{enumerator value evaluates to 2147483648, which cannot be narrowed to type 'int'}} }; enum class E5 { e1 = 2147483647, // ok e2 // expected-error{{2147483648 is not representable in the underlying}} }; enum class E6 : bool { e1 = false, e2 = true, e3 // expected-error{{2 is not representable in the underlying}} }; enum E7 : bool { e1 = false, e2 = true, e3 // expected-error{{2 is not representable in the underlying}} }; template <class T> struct X { enum E : T { e1, e2, e3 // expected-error{{2 is not representable in the underlying}} }; }; X<bool> X2; // expected-note{{in instantiation of template}} enum Incomplete1; // expected-error{{C++ forbids forward references}} enum Complete1 : int; Complete1 complete1; enum class Complete2; Complete2 complete2; // All the redeclarations below are done twice on purpose. Tests that the type // of the declaration isn't changed. enum class Redeclare2; // expected-note{{previous declaration is here}} expected-note{{previous declaration is here}} enum Redeclare2; // expected-error{{previously declared as scoped}} enum Redeclare2; // expected-error{{previously declared as scoped}} enum Redeclare3 : int; // expected-note{{previous declaration is here}} expected-note{{previous declaration is here}} enum Redeclare3; // expected-error{{previously declared with fixed underlying type}} enum Redeclare3; // expected-error{{previously declared with fixed underlying type}} enum class Redeclare5; enum class Redeclare5 : int; // ok enum Redeclare6 : int; // expected-note{{previous declaration is here}} expected-note{{previous declaration is here}} enum Redeclare6 : short; // expected-error{{redeclared with different underlying type}} enum Redeclare6 : short; // expected-error{{redeclared with different underlying type}} enum class Redeclare7; // expected-note{{previous declaration is here}} expected-note{{previous declaration is here}} enum class Redeclare7 : short; // expected-error{{redeclared with different underlying type}} enum class Redeclare7 : short; // expected-error{{redeclared with different underlying type}} enum : long { long_enum_val = 10000 }; enum : long x; // expected-error{{unnamed enumeration must be a definition}} \ // expected-warning{{declaration does not declare anything}} void PR9333() { enum class scoped_enum { yes, no, maybe }; scoped_enum e = scoped_enum::yes; if (e == scoped_enum::no) { } } // <rdar://problem/9366066> namespace rdar9366066 { enum class X : unsigned { value }; void f(X x) { x % X::value; // expected-error{{invalid operands to binary expression ('rdar9366066::X' and 'rdar9366066::X')}} x % 8; // expected-error{{invalid operands to binary expression ('rdar9366066::X' and 'int')}} } } // Part 1 of PR10264 namespace test5 { namespace ns { typedef unsigned Atype; enum A : Atype; } enum ns::A : ns::Atype { x, y, z }; } // Part 2 of PR10264 namespace test6 { enum A : unsigned; struct A::a; // expected-error {{incomplete type 'test6::A' named in nested name specifier}} enum A::b; // expected-error {{incomplete type 'test6::A' named in nested name specifier}} int A::c; // expected-error {{incomplete type 'test6::A' named in nested name specifier}} void A::d(); // expected-error {{incomplete type 'test6::A' named in nested name specifier}} void test() { (void) A::e; // expected-error {{incomplete type 'test6::A' named in nested name specifier}} } } namespace PR11484 { const int val = 104; enum class test1 { owner_dead = val, }; } namespace N2764 { enum class E { a, b }; enum E x1 = E::a; // ok enum class E x2 = E::a; // expected-error {{reference to scoped enumeration must use 'enum' not 'enum class'}} enum F { a, b }; enum F y1 = a; // ok enum class F y2 = a; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}} struct S { friend enum class E; // expected-error {{reference to scoped enumeration must use 'enum' not 'enum class'}} friend enum class F; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}} friend enum G {}; // expected-error {{forward reference}} expected-error {{cannot define a type in a friend declaration}} friend enum class H {}; // expected-error {{cannot define a type in a friend declaration}} enum A : int; A a; } s; enum S::A : int {}; enum class B; } enum class N2764::B {}; namespace PR12106 { template<typename E> struct Enum { Enum() : m_e(E::Last) {} E m_e; }; enum eCOLORS { Last }; Enum<eCOLORS> e; } namespace test7 { enum class E { e = (struct S*)0 == (struct S*)0 }; S *p; } namespace test8 { template<typename T> struct S { enum A : int; // expected-note {{here}} enum class B; // expected-note {{here}} enum class C : int; // expected-note {{here}} enum class D : int; // expected-note {{here}} }; template<typename T> enum S<T>::A { a }; // expected-error {{previously declared with fixed underlying type}} template<typename T> enum class S<T>::B : char { b }; // expected-error {{redeclared with different underlying}} template<typename T> enum S<T>::C : int { c }; // expected-error {{previously declared as scoped}} template<typename T> enum class S<T>::D : char { d }; // expected-error {{redeclared with different underlying}} } namespace test9 { template<typename T> struct S { enum class ET : T; // expected-note 2{{here}} enum class Eint : int; // expected-note 2{{here}} }; template<> enum class S<int>::ET : int {}; template<> enum class S<char>::ET : short {}; // expected-error {{different underlying type}} template<> enum class S<int>::Eint : short {}; // expected-error {{different underlying type}} template<> enum class S<char>::Eint : int {}; template<typename T> enum class S<T>::ET : int {}; // expected-error {{different underlying type 'int' (was 'short')}} template<typename T> enum class S<T>::Eint : T {}; // expected-error {{different underlying type 'short' (was 'int')}} // The implicit instantiation of S<short> causes the implicit instantiation of // all declarations of member enumerations, so is ill-formed, even though we // never instantiate the definitions of S<short>::ET nor S<short>::Eint. S<short> s; // expected-note {{in instantiation of}} } namespace test10 { template<typename T> int f() { enum E : int; enum E : T; // expected-note {{here}} E x; enum E : int { e }; // expected-error {{different underlying}} x = e; return x; } int k = f<int>(); int l = f<short>(); // expected-note {{here}} template<typename T> int g() { enum class E : int; enum class E : T; // expected-note {{here}} E x; enum class E : int { e }; // expected-error {{different underlying}} x = E::e; return (int)x; } int m = g<int>(); int n = g<short>(); // expected-note {{here}} } namespace pr13128 { // This should compile cleanly class C { enum class E { C }; }; } namespace PR15633 { template<typename T> struct A { struct B { enum class E : T; enum class E2 : T; }; }; template<typename T> enum class A<T>::B::E { e }; template class A<int>; struct B { enum class E; }; template<typename T> enum class B::E { e }; // expected-error {{enumeration cannot be a template}} } namespace PR16900 { enum class A; A f(A a) { return -a; } // expected-error {{invalid argument type 'PR16900::A' to unary expression}} } namespace PR18551 { enum class A { A }; bool f() { return !A::A; } // expected-error {{invalid argument type 'PR18551::A' to unary expression}} } namespace rdar15124329 { enum class B : bool { F, T }; const rdar15124329::B T1 = B::T; typedef B C; const C T2 = B::T; static_assert(T1 != B::F, ""); static_assert(T2 == B::T, ""); } namespace PR18044 { enum class E { a }; int E::e = 0; // expected-error {{does not refer into a class}} void E::f() {} // expected-error {{does not refer into a class}} struct E::S {}; // expected-error {{no struct named 'S'}} struct T : E::S {}; // expected-error {{expected class name}} enum E::E {}; // expected-error {{no enum named 'E'}} int E::*p; // expected-error {{does not point into a class}} using E::f; // expected-error {{no member named 'f'}} using E::a; // ok! E b = a; } namespace test11 { enum class E { a }; typedef E E2; E2 f1() { return E::a; } bool f() { return !f1(); } // expected-error {{invalid argument type 'E2' (aka 'test11::E') to unary expression}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/address-space-initialize.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s __attribute__((address_space(42))) const float withc = 1.0f; __attribute__((address_space(42))) volatile float withv = 1.0f; __attribute__((address_space(42))) float nocv = 1.0f; __attribute__((address_space(42))) float nocv_array[10] = { 1.0f }; __attribute__((address_space(42))) int nocv_iarray[10] = { 4 }; __attribute__((address_space(9999))) int* as_ptr = nocv_iarray; // expected-error{{cannot initialize a variable of type '__attribute__((address_space(9999))) int *' with an lvalue of type '__attribute__((address_space(42))) int [10]'}} __attribute__((address_space(42))) int* __attribute__((address_space(42))) ptr_in_same_addr_space = nocv_iarray; __attribute__((address_space(42))) int* __attribute__((address_space(999))) ptr_in_different_addr_space = nocv_iarray;
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-no-sanitize.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // RUN: not %clang_cc1 -std=c++11 -ast-dump %s | FileCheck --check-prefix=DUMP %s // RUN: not %clang_cc1 -std=c++11 -ast-print %s | FileCheck --check-prefix=PRINT %s int v1 __attribute__((no_sanitize("address"))); // expected-error{{'no_sanitize' attribute only applies to functions and methods}} int f1() __attribute__((no_sanitize)); // expected-error{{'no_sanitize' attribute takes at least 1 argument}} int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' attribute requires a string}} // DUMP-LABEL: FunctionDecl {{.*}} f3 // DUMP: NoSanitizeAttr {{.*}} address // PRINT: int f3() __attribute__((no_sanitize("address"))) int f3() __attribute__((no_sanitize("address"))); // DUMP-LABEL: FunctionDecl {{.*}} f4 // DUMP: NoSanitizeAttr {{.*}} thread // PRINT: int f4() {{\[\[}}clang::no_sanitize("thread")]] [[clang::no_sanitize("thread")]] int f4(); // DUMP-LABEL: FunctionDecl {{.*}} f5 // DUMP: NoSanitizeAttr {{.*}} address thread // PRINT: int f5() __attribute__((no_sanitize("address", "thread"))) int f5() __attribute__((no_sanitize("address", "thread"))); // DUMP-LABEL: FunctionDecl {{.*}} f6 // DUMP: NoSanitizeAttr {{.*}} unknown // PRINT: int f6() __attribute__((no_sanitize("unknown"))) int f6() __attribute__((no_sanitize("unknown"))); // expected-warning{{unknown sanitizer 'unknown' ignored}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR20110.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // expected-no-diagnostics // FIXME: These templates should trigger errors in C++11 mode. template <char const *p> class A { char const *get_p() { return *p; } }; template <int p> class B { char const *get_p() { return p; } };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/trivial-constructor.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // expected-no-diagnostics struct T1 { }; static_assert(__has_trivial_constructor(T1), "T1 has trivial constructor!"); struct T2 { T2(); }; static_assert(!__has_trivial_constructor(T2), "T2 has a user-declared constructor!"); struct T3 { virtual void f(); }; static_assert(!__has_trivial_constructor(T3), "T3 has a virtual function!"); struct T4 : virtual T3 { }; static_assert(!__has_trivial_constructor(T4), "T4 has a virtual base class!"); struct T5 : T1 { }; static_assert(__has_trivial_constructor(T5), "All the direct base classes of T5 have trivial constructors!"); struct T6 { T5 t5; T1 t1[2][2]; static T2 t2; }; static_assert(__has_trivial_constructor(T6), "All nonstatic data members of T6 have trivial constructors!"); struct T7 { T4 t4; }; static_assert(!__has_trivial_constructor(T7), "t4 does not have a trivial constructor!"); struct T8 : T2 { }; static_assert(!__has_trivial_constructor(T8), "The base class T2 does not have a trivial constructor!");
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp
// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only %s // RUN: %clang_cc1 -std=c++1y %s -verify -DCXX1Y // Explicit member declarations behave as in C++11. namespace n3323_example { template <class T> class zero_init { public: zero_init() : val(static_cast<T>(0)) {} zero_init(T val) : val(val) {} operator T &() { return val; } //@13 operator T() const { return val; } //@14 private: T val; }; void Delete() { zero_init<int *> p; p = new int(7); delete p; //@23 delete (p + 0); delete + p; } void Switch() { zero_init<int> i; i = 7; switch (i) {} // @31 switch (i + 0) {} switch (+i) {} } } #ifdef CXX1Y #else //expected-error@23 {{ambiguous conversion of delete expression of type 'zero_init<int *>' to a pointer}} //expected-note@13 {{conversion to pointer type 'int *'}} //expected-note@14 {{conversion to pointer type 'int *'}} //expected-error@31 {{multiple conversions from switch condition type 'zero_init<int>' to an integral or enumeration type}} //expected-note@13 {{conversion to integral type 'int'}} //expected-note@14 {{conversion to integral type 'int'}} #endif namespace extended_examples { struct A0 { operator int(); // matching and viable }; struct A1 { operator int() &&; // matching and not viable }; struct A2 { operator float(); // not matching }; struct A3 { template<typename T> operator T(); // not matching (ambiguous anyway) }; struct A4 { template<typename T> operator int(); // not matching (ambiguous anyway) }; struct B1 { operator int() &&; // @70 operator int(); // @71 -- duplicate declaration with different qualifier is not allowed }; struct B2 { operator int() &&; // matching but not viable operator float(); // not matching }; void foo(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, B2 b2) { switch (a0) {} switch (a1) {} // @81 -- fails for different reasons switch (a2) {} // @82 switch (a3) {} // @83 switch (a4) {} // @84 switch (b2) {} // @85 -- fails for different reasons } } //expected-error@71 {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&&'}} //expected-note@70 {{previous declaration is here}} //expected-error@82 {{statement requires expression of integer type ('extended_examples::A2' invalid)}} //expected-error@83 {{statement requires expression of integer type ('extended_examples::A3' invalid)}} //expected-error@84 {{statement requires expression of integer type ('extended_examples::A4' invalid)}} #ifdef CXX1Y //expected-error@81 {{statement requires expression of integer type ('extended_examples::A1' invalid)}} //expected-error@85 {{statement requires expression of integer type ('extended_examples::B2' invalid)}} #else //expected-error@81 {{cannot initialize object parameter of type 'extended_examples::A1' with an expression of type 'extended_examples::A1'}} //expected-error@85 {{cannot initialize object parameter of type 'extended_examples::B2' with an expression of type 'extended_examples::B2'}} #endif namespace extended_examples_cxx1y { struct A1 { // leads to viable match in C++1y, and no viable match in C++11 operator int() &&; // matching but not viable template <typename T> operator T(); // In C++1y: matching and viable, since disambiguated by L.100 }; struct A2 { // leads to ambiguity in C++1y, and no viable match in C++11 operator int() &&; // matching but not viable template <typename T> operator int(); // In C++1y: matching but ambiguous (disambiguated by L.105). }; struct B1 { // leads to one viable match in both cases operator int(); // matching and viable template <typename T> operator T(); // In C++1y: matching and viable, since disambiguated by L.110 }; struct B2 { // leads to one viable match in both cases operator int(); // matching and viable template <typename T> operator int(); // In C++1y: matching but ambiguous, since disambiguated by L.115 }; struct C { // leads to no match in both cases operator float(); // not matching template <typename T> operator T(); // In C++1y: not matching, nor viable. }; struct D { // leads to viable match in C++1y, and no viable match in C++11 operator int() &&; // matching but not viable operator float(); // not matching template <typename T> operator T(); // In C++1y: matching and viable, since disambiguated by L.125 }; void foo(A1 a1, A2 a2, B1 b1, B2 b2, C c, D d) { switch (a1) {} // @138 -- should presumably call templated conversion operator to convert to int. switch (a2) {} // @139 switch (b1) {} switch (b2) {} switch (c) {} // @142 switch (d) {} // @143 } } //expected-error@142 {{statement requires expression of integer type ('extended_examples_cxx1y::C' invalid)}} #ifdef CXX1Y //expected-error@139 {{statement requires expression of integer type ('extended_examples_cxx1y::A2' invalid)}} #else //expected-error@138 {{cannot initialize object parameter of type 'extended_examples_cxx1y::A1' with an expression of type 'extended_examples_cxx1y::A1'}} //expected-error@139 {{cannot initialize object parameter of type 'extended_examples_cxx1y::A2' with an expression of type 'extended_examples_cxx1y::A2'}} //expected-error@143 {{cannot initialize object parameter of type 'extended_examples_cxx1y::D' with an expression of type 'extended_examples_cxx1y::D'}} #endif namespace extended_examples_array_bounds { typedef decltype(sizeof(int)) size_t; struct Foo { operator size_t(); // @162 operator unsigned short(); // @163 }; void bar() { Foo x; int *p = new int[x]; // @168 } } #ifdef CXX1Y #else //expected-error@168 {{ambiguous conversion of array size expression of type 'extended_examples_array_bounds::Foo' to an integral or enumeration type}} //expected-note@162 {{conversion to integral type 'size_t'}} //expected-note@163 {{conversion to integral type 'unsigned short' declared here}} #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/uninitialized.cpp
// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -std=c++11 -verify %s // definitions for std::move namespace std { inline namespace foo { template <class T> struct remove_reference { typedef T type; }; template <class T> struct remove_reference<T&> { typedef T type; }; template <class T> struct remove_reference<T&&> { typedef T type; }; template <class T> typename remove_reference<T>::type&& move(T&& t); } } int foo(int x); int bar(int* x); int boo(int& x); int far(const int& x); int moved(int&& x); int &ref(int x); // Test self-references within initializers which are guaranteed to be // uninitialized. int a = a; // no-warning: used to signal intended lack of initialization. int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} int c = (c + c); // expected-warning 2 {{variable 'c' is uninitialized when used within its own initialization}} int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} // Thes don't warn as they don't require the value. int g = sizeof(g); void* ptr = &ptr; int h = bar(&h); int i = boo(i); int j = far(j); int k = __alignof__(k); int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}} int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}} int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}} const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}} int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}} int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}} int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}} int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}} int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}} int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}} int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}} int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}} int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} void test_stuff () { int a = a; // no-warning: used to signal intended lack of initialization. int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} int c = (c + c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} // Thes don't warn as they don't require the value. int g = sizeof(g); void* ptr = &ptr; int h = bar(&h); int i = boo(i); int j = far(j); int k = __alignof__(k); int l = k ? l : l; // expected-warning {{variable 'l' is uninitialized when used within its own initialization}} int m = 1 + (k ? m : m); // expected-warning {{'m' is uninitialized when used within its own initialization}} int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}} const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}} int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}} int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}} int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}} int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}} int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}} int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}} int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}} int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}} int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} for (;;) { int a = a; // no-warning: used to signal intended lack of initialization. int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} int c = (c + c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} // Thes don't warn as they don't require the value. int g = sizeof(g); void* ptr = &ptr; int h = bar(&h); int i = boo(i); int j = far(j); int k = __alignof__(k); int l = k ? l : l; // expected-warning {{variable 'l' is uninitialized when used within its own initialization}} int m = 1 + (k ? m : m); // expected-warning {{'m' is uninitialized when used within its own initialization}} int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}} const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}} int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}} int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}} int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}} int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}} int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}} int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}} int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}} int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}} int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} } } void test_comma() { int a; // expected-note {{initialize the variable 'a' to silence this warning}} int b = (a, a ?: 2); // expected-warning {{variable 'a' is uninitialized when used here}} int c = (a, a, b, c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} int d; // expected-note {{initialize the variable 'd' to silence this warning}} int e = (foo(d), e, b); // expected-warning {{variable 'd' is uninitialized when used here}} int f; // expected-note {{initialize the variable 'f' to silence this warning}} f = f + 1, 2; // expected-warning {{variable 'f' is uninitialized when used here}} int h; int g = (h, g, 2); // no-warning: h, g are evaluated but not used. } namespace member_ptr { struct A { int x; int y; A(int x) : x{x} {} }; void test_member_ptr() { int A::* px = &A::x; A a{a.*px}; // expected-warning {{variable 'a' is uninitialized when used within its own initialization}} A b = b; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} } } namespace const_ptr { void foo(int *a); void bar(const int *a); void foobar(const int **a); void test_const_ptr() { int a; int b; // expected-note {{initialize the variable 'b' to silence this warning}} foo(&a); bar(&b); b = a + b; // expected-warning {{variable 'b' is uninitialized when used here}} int *ptr; //expected-note {{initialize the variable 'ptr' to silence this warning}} const int *ptr2; foo(ptr); // expected-warning {{variable 'ptr' is uninitialized when used here}} foobar(&ptr2); } } // Also test similar constructs in a field's initializer. struct S { int x; int y; const int z = 5; void *ptr; S(bool (*)[1]) : x(x) {} // expected-warning {{field 'x' is uninitialized when used here}} S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field 'x' is uninitialized when used here}} S(bool (*)[3]) : x(x + x) {} // expected-warning 2{{field 'x' is uninitialized when used here}} S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field 'x' is uninitialized when used here}} S(bool (*)[5]) : x(foo(x)) {} // expected-warning {{field 'x' is uninitialized when used here}} // These don't actually require the value of x and so shouldn't warn. S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363 S(char (*)[2]) : ptr(&ptr) {} S(char (*)[3]) : x(bar(&x)) {} S(char (*)[4]) : x(boo(x)) {} S(char (*)[5]) : x(far(x)) {} S(char (*)[6]) : x(__alignof__(x)) {} S(int (*)[1]) : x(0), y(x ? y : y) {} // expected-warning 2{{field 'y' is uninitialized when used here}} S(int (*)[2]) : x(0), y(1 + (x ? y : y)) {} // expected-warning 2{{field 'y' is uninitialized when used here}} S(int (*)[3]) : x(-x) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[4]) : x(std::move(x)) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[5]) : z(std::move(z)) {} // expected-warning {{field 'z' is uninitialized when used here}} S(int (*)[6]) : x(moved(std::move(x))) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[7]) : x(0), y(std::move((x ? x : (18, y)))) {} // expected-warning {{field 'y' is uninitialized when used here}} S(int (*)[8]) : x(0), y(x ?: y) {} // expected-warning {{field 'y' is uninitialized when used here}} S(int (*)[9]) : x(0), y(y ?: x) {} // expected-warning {{field 'y' is uninitialized when used here}} S(int (*)[10]) : x(0), y((foo(y), x)) {} // expected-warning {{field 'y' is uninitialized when used here}} S(int (*)[11]) : x(0), y(x += y) {} // expected-warning {{field 'y' is uninitialized when used here}} S(int (*)[12]) : x(x += 10) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[13]) : x(x++) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[14]) : x(0), y(((x ? (y, x) : (77, y))++, sizeof(y))) {} // expected-warning {{field 'y' is uninitialized when used here}} S(int (*)[15]) : x(++ref(x)) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[16]) : x((ref(x) += 10)) {} // expected-warning {{field 'x' is uninitialized when used here}} S(int (*)[17]) : x(0), y(y ? x : x) {} // expected-warning {{field 'y' is uninitialized when used here}} }; // Test self-references with record types. class A { // Non-POD class. public: enum count { ONE, TWO, THREE }; int num; static int count; int get() const { return num; } int get2() { return num; } int set(int x) { num = x; return num; } static int zero() { return 0; } A() {} A(A const &a) {} A(int x) {} A(int *x) {} A(A *a) {} A(A &&a) {} ~A(); bool operator!(); bool operator!=(const A&); }; bool operator!=(int, const A&); A getA() { return A(); } A getA(int x) { return A(); } A getA(A* a) { return A(); } A getA(A a) { return A(); } A moveA(A&& a) { return A(); } A const_refA(const A& a) { return A(); } void setupA(bool x) { A a1; a1.set(a1.get()); A a2(a1.get()); A a3(a1); A a4(&a4); A a5(a5.zero()); A a6(a6.ONE); A a7 = getA(); A a8 = getA(a8.TWO); A a9 = getA(&a9); A a10(a10.count); A a11(a11); // expected-warning {{variable 'a11' is uninitialized when used within its own initialization}} A a12(a12.get()); // expected-warning {{variable 'a12' is uninitialized when used within its own initialization}} A a13(a13.num); // expected-warning {{variable 'a13' is uninitialized when used within its own initialization}} A a14 = A(a14); // expected-warning {{variable 'a14' is uninitialized when used within its own initialization}} A a15 = getA(a15.num); // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}} A a16(&a16.num); // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}} A a17(a17.get2()); // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}} A a18 = x ? a18 : a17; // expected-warning {{variable 'a18' is uninitialized when used within its own initialization}} A a19 = getA(x ? a19 : a17); // expected-warning {{variable 'a19' is uninitialized when used within its own initialization}} A a20{a20}; // expected-warning {{variable 'a20' is uninitialized when used within its own initialization}} A a21 = {a21}; // expected-warning {{variable 'a21' is uninitialized when used within its own initialization}} // FIXME: Make the local uninitialized warning consistent with the global // uninitialized checking. A *a22 = new A(a22->count); // expected-warning {{variable 'a22' is uninitialized when used within its own initialization}} A *a23 = new A(a23->ONE); // expected-warning {{variable 'a23' is uninitialized when used within its own initialization}} A *a24 = new A(a24->TWO); // expected-warning {{variable 'a24' is uninitialized when used within its own initialization}} A *a25 = new A(a25->zero()); // expected-warning {{variable 'a25' is uninitialized when used within its own initialization}} A *a26 = new A(a26->get()); // expected-warning {{variable 'a26' is uninitialized when used within its own initialization}} A *a27 = new A(a27->get2()); // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}} A *a28 = new A(a28->num); // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}} const A a29(a29); // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}} const A a30 = a30; // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}} A a31 = std::move(a31); // expected-warning {{variable 'a31' is uninitialized when used within its own initialization}} A a32 = moveA(std::move(a32)); // expected-warning {{variable 'a32' is uninitialized when used within its own initialization}} A a33 = A(std::move(a33)); // expected-warning {{variable 'a33' is uninitialized when used within its own initialization}} A a34(std::move(a34)); // expected-warning {{variable 'a34' is uninitialized when used within its own initialization}} A a35 = std::move(x ? a34 : (37, a35)); // expected-warning {{variable 'a35' is uninitialized when used within its own initialization}} A a36 = const_refA(a36); A a37(const_refA(a37)); A a38({a38}); // expected-warning {{variable 'a38' is uninitialized when used within its own initialization}} A a39 = {a39}; // expected-warning {{variable 'a39' is uninitialized when used within its own initialization}} A a40 = A({a40}); // expected-warning {{variable 'a40' is uninitialized when used within its own initialization}} A a41 = !a41; // expected-warning {{variable 'a41' is uninitialized when used within its own initialization}} A a42 = !(a42); // expected-warning {{variable 'a42' is uninitialized when used within its own initialization}} A a43 = a43 != a42; // expected-warning {{variable 'a43' is uninitialized when used within its own initialization}} A a44 = a43 != a44; // expected-warning {{variable 'a44' is uninitialized when used within its own initialization}} A a45 = a45 != a45; // expected-warning 2{{variable 'a45' is uninitialized when used within its own initialization}} A a46 = 0 != a46; // expected-warning {{variable 'a46' is uninitialized when used within its own initialization}} A a47(a47.set(a47.num)); // expected-warning 2{{variable 'a47' is uninitialized when used within its own initialization}} A a48(a47.set(a48.num)); // expected-warning {{variable 'a48' is uninitialized when used within its own initialization}} A a49(a47.set(a48.num)); } bool cond; A a1; A a2(a1.get()); A a3(a1); A a4(&a4); A a5(a5.zero()); A a6(a6.ONE); A a7 = getA(); A a8 = getA(a8.TWO); A a9 = getA(&a9); A a10(a10.count); A a11(a11); // expected-warning {{variable 'a11' is uninitialized when used within its own initialization}} A a12(a12.get()); // expected-warning {{variable 'a12' is uninitialized when used within its own initialization}} A a13(a13.num); // expected-warning {{variable 'a13' is uninitialized when used within its own initialization}} A a14 = A(a14); // expected-warning {{variable 'a14' is uninitialized when used within its own initialization}} A a15 = getA(a15.num); // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}} A a16(&a16.num); // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}} A a17(a17.get2()); // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}} A a18 = cond ? a18 : a17; // expected-warning {{variable 'a18' is uninitialized when used within its own initialization}} A a19 = getA(cond ? a19 : a17); // expected-warning {{variable 'a19' is uninitialized when used within its own initialization}} A a20{a20}; // expected-warning {{variable 'a20' is uninitialized when used within its own initialization}} A a21 = {a21}; // expected-warning {{variable 'a21' is uninitialized when used within its own initialization}} A *a22 = new A(a22->count); A *a23 = new A(a23->ONE); A *a24 = new A(a24->TWO); A *a25 = new A(a25->zero()); A *a26 = new A(a26->get()); // expected-warning {{variable 'a26' is uninitialized when used within its own initialization}} A *a27 = new A(a27->get2()); // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}} A *a28 = new A(a28->num); // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}} const A a29(a29); // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}} const A a30 = a30; // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}} A a31 = std::move(a31); // expected-warning {{variable 'a31' is uninitialized when used within its own initialization}} A a32 = moveA(std::move(a32)); // expected-warning {{variable 'a32' is uninitialized when used within its own initialization}} A a33 = A(std::move(a33)); // expected-warning {{variable 'a33' is uninitialized when used within its own initialization}} A a34(std::move(a34)); // expected-warning {{variable 'a34' is uninitialized when used within its own initialization}} A a35 = std::move(x ? a34 : (37, a35)); // expected-warning {{variable 'a35' is uninitialized when used within its own initialization}} A a36 = const_refA(a36); A a37(const_refA(a37)); A a38({a38}); // expected-warning {{variable 'a38' is uninitialized when used within its own initialization}} A a39 = {a39}; // expected-warning {{variable 'a39' is uninitialized when used within its own initialization}} A a40 = A({a40}); // expected-warning {{variable 'a40' is uninitialized when used within its own initialization}} A a41 = !a41; // expected-warning {{variable 'a41' is uninitialized when used within its own initialization}} A a42 = !(a42); // expected-warning {{variable 'a42' is uninitialized when used within its own initialization}} A a43 = a43 != a42; // expected-warning {{variable 'a43' is uninitialized when used within its own initialization}} A a44 = a43 != a44; // expected-warning {{variable 'a44' is uninitialized when used within its own initialization}} A a45 = a45 != a45; // expected-warning 2{{variable 'a45' is uninitialized when used within its own initialization}} A a46 = 0 != a46; // expected-warning {{variable 'a46' is uninitialized when used within its own initialization}} A a47(a47.set(a47.num)); // expected-warning 2{{variable 'a47' is uninitialized when used within its own initialization}} A a48(a47.set(a48.num)); // expected-warning {{variable 'a48' is uninitialized when used within its own initialization}} A a49(a47.set(a48.num)); class T { A a, a2; const A c_a; A* ptr_a; T() {} T(bool (*)[1]) : a() {} T(bool (*)[2]) : a2(a.get()) {} T(bool (*)[3]) : a2(a) {} T(bool (*)[4]) : a(&a) {} T(bool (*)[5]) : a(a.zero()) {} T(bool (*)[6]) : a(a.ONE) {} T(bool (*)[7]) : a(getA()) {} T(bool (*)[8]) : a2(getA(a.TWO)) {} T(bool (*)[9]) : a(getA(&a)) {} T(bool (*)[10]) : a(a.count) {} T(bool (*)[11]) : a(a) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[12]) : a(a.get()) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[13]) : a(a.num) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[14]) : a(A(a)) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[15]) : a(getA(a.num)) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[16]) : a(&a.num) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[17]) : a(a.get2()) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[18]) : a2(cond ? a2 : a) {} // expected-warning {{field 'a2' is uninitialized when used here}} T(bool (*)[19]) : a2(cond ? a2 : a) {} // expected-warning {{field 'a2' is uninitialized when used here}} T(bool (*)[20]) : a{a} {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[21]) : a({a}) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[22]) : ptr_a(new A(ptr_a->count)) {} T(bool (*)[23]) : ptr_a(new A(ptr_a->ONE)) {} T(bool (*)[24]) : ptr_a(new A(ptr_a->TWO)) {} T(bool (*)[25]) : ptr_a(new A(ptr_a->zero())) {} T(bool (*)[26]) : ptr_a(new A(ptr_a->get())) {} // expected-warning {{field 'ptr_a' is uninitialized when used here}} T(bool (*)[27]) : ptr_a(new A(ptr_a->get2())) {} // expected-warning {{field 'ptr_a' is uninitialized when used here}} T(bool (*)[28]) : ptr_a(new A(ptr_a->num)) {} // expected-warning {{field 'ptr_a' is uninitialized when used here}} T(bool (*)[29]) : c_a(c_a) {} // expected-warning {{field 'c_a' is uninitialized when used here}} T(bool (*)[30]) : c_a(A(c_a)) {} // expected-warning {{field 'c_a' is uninitialized when used here}} T(bool (*)[31]) : a(std::move(a)) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[32]) : a(moveA(std::move(a))) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[33]) : a(A(std::move(a))) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[34]) : a(A(std::move(a))) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[35]) : a2(std::move(x ? a : (37, a2))) {} // expected-warning {{field 'a2' is uninitialized when used here}} T(bool (*)[36]) : a(const_refA(a)) {} T(bool (*)[37]) : a(A(const_refA(a))) {} T(bool (*)[38]) : a({a}) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[39]) : a{a} {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[40]) : a({a}) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[41]) : a(!a) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[42]) : a(!(a)) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[43]) : a(), a2(a2 != a) {} // expected-warning {{field 'a2' is uninitialized when used here}} T(bool (*)[44]) : a(), a2(a != a2) {} // expected-warning {{field 'a2' is uninitialized when used here}} T(bool (*)[45]) : a(a != a) {} // expected-warning 2{{field 'a' is uninitialized when used here}} T(bool (*)[46]) : a(0 != a) {} // expected-warning {{field 'a' is uninitialized when used here}} T(bool (*)[47]) : a2(a2.set(a2.num)) {} // expected-warning 2{{field 'a2' is uninitialized when used here}} T(bool (*)[48]) : a2(a.set(a2.num)) {} // expected-warning {{field 'a2' is uninitialized when used here}} T(bool (*)[49]) : a2(a.set(a.num)) {} }; struct B { // POD struct. int x; int *y; }; B getB() { return B(); }; B getB(int x) { return B(); }; B getB(int *x) { return B(); }; B getB(B *b) { return B(); }; B moveB(B &&b) { return B(); }; B* getPtrB() { return 0; }; B* getPtrB(int x) { return 0; }; B* getPtrB(int *x) { return 0; }; B* getPtrB(B **b) { return 0; }; void setupB(bool x) { B b1; B b2(b1); B b3 = { 5, &b3.x }; B b4 = getB(); B b5 = getB(&b5); B b6 = getB(&b6.x); // Silence unused warning (void) b2; (void) b4; B b7(b7); // expected-warning {{variable 'b7' is uninitialized when used within its own initialization}} B b8 = getB(b8.x); // expected-warning {{variable 'b8' is uninitialized when used within its own initialization}} B b9 = getB(b9.y); // expected-warning {{variable 'b9' is uninitialized when used within its own initialization}} B b10 = getB(-b10.x); // expected-warning {{variable 'b10' is uninitialized when used within its own initialization}} B* b11 = 0; B* b12(b11); B* b13 = getPtrB(); B* b14 = getPtrB(&b14); (void) b12; (void) b13; B* b15 = getPtrB(b15->x); // expected-warning {{variable 'b15' is uninitialized when used within its own initialization}} B* b16 = getPtrB(b16->y); // expected-warning {{variable 'b16' is uninitialized when used within its own initialization}} B b17 = { b17.x = 5, b17.y = 0 }; B b18 = { b18.x + 1, b18.y }; // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}} const B b19 = b19; // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}} const B b20(b20); // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}} B b21 = std::move(b21); // expected-warning {{variable 'b21' is uninitialized when used within its own initialization}} B b22 = moveB(std::move(b22)); // expected-warning {{variable 'b22' is uninitialized when used within its own initialization}} B b23 = B(std::move(b23)); // expected-warning {{variable 'b23' is uninitialized when used within its own initialization}} B b24 = std::move(x ? b23 : (18, b24)); // expected-warning {{variable 'b24' is uninitialized when used within its own initialization}} } B b1; B b2(b1); B b3 = { 5, &b3.x }; B b4 = getB(); B b5 = getB(&b5); B b6 = getB(&b6.x); B b7(b7); // expected-warning {{variable 'b7' is uninitialized when used within its own initialization}} B b8 = getB(b8.x); // expected-warning {{variable 'b8' is uninitialized when used within its own initialization}} B b9 = getB(b9.y); // expected-warning {{variable 'b9' is uninitialized when used within its own initialization}} B b10 = getB(-b10.x); // expected-warning {{variable 'b10' is uninitialized when used within its own initialization}} B* b11 = 0; B* b12(b11); B* b13 = getPtrB(); B* b14 = getPtrB(&b14); B* b15 = getPtrB(b15->x); // expected-warning {{variable 'b15' is uninitialized when used within its own initialization}} B* b16 = getPtrB(b16->y); // expected-warning {{variable 'b16' is uninitialized when used within its own initialization}} B b17 = { b17.x = 5, b17.y = 0 }; B b18 = { b18.x + 1, b18.y }; // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}} const B b19 = b19; // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}} const B b20(b20); // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}} B b21 = std::move(b21); // expected-warning {{variable 'b21' is uninitialized when used within its own initialization}} B b22 = moveB(std::move(b22)); // expected-warning {{variable 'b22' is uninitialized when used within its own initialization}} B b23 = B(std::move(b23)); // expected-warning {{variable 'b23' is uninitialized when used within its own initialization}} B b24 = std::move(x ? b23 : (18, b24)); // expected-warning {{variable 'b24' is uninitialized when used within its own initialization}} class U { B b1, b2; B *ptr1, *ptr2; const B constb = {}; U() {} U(bool (*)[1]) : b1() {} U(bool (*)[2]) : b2(b1) {} U(bool (*)[3]) : b1{ 5, &b1.x } {} U(bool (*)[4]) : b1(getB()) {} U(bool (*)[5]) : b1(getB(&b1)) {} U(bool (*)[6]) : b1(getB(&b1.x)) {} U(bool (*)[7]) : b1(b1) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[8]) : b1(getB(b1.x)) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[9]) : b1(getB(b1.y)) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[10]) : b1(getB(-b1.x)) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[11]) : ptr1(0) {} U(bool (*)[12]) : ptr1(0), ptr2(ptr1) {} U(bool (*)[13]) : ptr1(getPtrB()) {} U(bool (*)[14]) : ptr1(getPtrB(&ptr1)) {} U(bool (*)[15]) : ptr1(getPtrB(ptr1->x)) {} // expected-warning {{field 'ptr1' is uninitialized when used here}} U(bool (*)[16]) : ptr2(getPtrB(ptr2->y)) {} // expected-warning {{field 'ptr2' is uninitialized when used here}} U(bool (*)[17]) : b1 { b1.x = 5, b1.y = 0 } {} U(bool (*)[18]) : b1 { b1.x + 1, b1.y } {} // expected-warning 2{{field 'b1' is uninitialized when used here}} U(bool (*)[19]) : constb(constb) {} // expected-warning {{field 'constb' is uninitialized when used here}} U(bool (*)[20]) : constb(B(constb)) {} // expected-warning {{field 'constb' is uninitialized when used here}} U(bool (*)[21]) : b1(std::move(b1)) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[22]) : b1(moveB(std::move(b1))) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[23]) : b1(B(std::move(b1))) {} // expected-warning {{field 'b1' is uninitialized when used here}} U(bool (*)[24]) : b2(std::move(x ? b1 : (18, b2))) {} // expected-warning {{field 'b2' is uninitialized when used here}} }; struct C { char a[100], *e; } car = { .e = car.a }; // <rdar://problem/10398199> namespace rdar10398199 { class FooBase { protected: ~FooBase() {} }; class Foo : public FooBase { public: operator int&() const; }; void stuff(); template <typename T> class FooImpl : public Foo { T val; public: FooImpl(const T &x) : val(x) {} ~FooImpl() { stuff(); } }; template <typename T> FooImpl<T> makeFoo(const T& x) { return FooImpl<T>(x); } void test() { const Foo &x = makeFoo(42); const int&y = makeFoo(42u); (void)x; (void)y; }; } // PR 12325 - this was a false uninitialized value warning due to // a broken CFG. int pr12325(int params) { int x = ({ while (false) ; int _v = params; if (false) ; _v; // no-warning }); return x; } // Test lambda expressions with -Wuninitialized int test_lambda() { auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}} return f1(1, 2); } namespace { struct A { enum { A1 }; static int A2() {return 5;} int A3; int A4() { return 5;} }; struct B { A a; }; struct C { C() {} C(int x) {} static A a; B b; }; A C::a = A(); // Accessing non-static members will give a warning. struct D { C c; D(char (*)[1]) : c(c.b.a.A1) {} D(char (*)[2]) : c(c.b.a.A2()) {} D(char (*)[3]) : c(c.b.a.A3) {} // expected-warning {{field 'c' is uninitialized when used here}} D(char (*)[4]) : c(c.b.a.A4()) {} // expected-warning {{field 'c' is uninitialized when used here}} // c::a is static, so it is already initialized D(char (*)[5]) : c(c.a.A1) {} D(char (*)[6]) : c(c.a.A2()) {} D(char (*)[7]) : c(c.a.A3) {} D(char (*)[8]) : c(c.a.A4()) {} }; struct E { int b = 1; int c = 1; int a; // This field needs to be last to prevent the cross field // uninitialized warning. E(char (*)[1]) : a(a ? b : c) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[2]) : a(b ? a : a) {} // expected-warning 2{{field 'a' is uninitialized when used here}} E(char (*)[3]) : a(b ? (a) : c) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[4]) : a(b ? c : (a+c)) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[5]) : a(b ? c : b) {} E(char (*)[6]) : a(a ?: a) {} // expected-warning 2{{field 'a' is uninitialized when used here}} E(char (*)[7]) : a(b ?: a) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[8]) : a(a ?: c) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[9]) : a(b ?: c) {} E(char (*)[10]) : a((a, a, b)) {} E(char (*)[11]) : a((c + a, a + 1, b)) {} // expected-warning 2{{field 'a' is uninitialized when used here}} E(char (*)[12]) : a((b + c, c, a)) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[13]) : a((a, a, a, a)) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[14]) : a((b, c, c)) {} E(char (*)[15]) : a(b ?: a) {} // expected-warning {{field 'a' is uninitialized when used here}} E(char (*)[16]) : a(a ?: b) {} // expected-warning {{field 'a' is uninitialized when used here}} }; struct F { int a; F* f; F(int) {} F() {} }; int F::*ptr = &F::a; F* F::*f_ptr = &F::f; struct G { F f1, f2; F *f3, *f4; G(char (*)[1]) : f1(f1) {} // expected-warning {{field 'f1' is uninitialized when used here}} G(char (*)[2]) : f2(f1) {} G(char (*)[3]) : f2(F()) {} G(char (*)[4]) : f1(f1.*ptr) {} // expected-warning {{field 'f1' is uninitialized when used here}} G(char (*)[5]) : f2(f1.*ptr) {} G(char (*)[6]) : f3(f3) {} // expected-warning {{field 'f3' is uninitialized when used here}} G(char (*)[7]) : f3(f3->*f_ptr) {} // expected-warning {{field 'f3' is uninitialized when used here}} G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field 'f3' is uninitialized when used here}} }; struct H { H() : a(a) {} // expected-warning {{field 'a' is uninitialized when used here}} const A a; }; } namespace statics { static int a = a; // no-warning: used to signal intended lack of initialization. static int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} static int c = (c + c); // expected-warning 2{{variable 'c' is uninitialized when used within its own initialization}} static int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} static int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} // Thes don't warn as they don't require the value. static int g = sizeof(g); int gg = g; // Silence unneeded warning static void* ptr = &ptr; static int h = bar(&h); static int i = boo(i); static int j = far(j); static int k = __alignof__(k); static int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}} static int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}} static int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} static int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}} static const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}} static int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}} static int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}} static int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}} static int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}} static int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}} static int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}} static int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}} static int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}} static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}} static int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}} static int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}} static int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}} void test() { static int a = a; // no-warning: used to signal intended lack of initialization. static int b = b + 1; // expected-warning {{static variable 'b' is suspiciously used within its own initialization}} static int c = (c + c); // expected-warning 2{{static variable 'c' is suspiciously used within its own initialization}} static int d = ({ d + d ;}); // expected-warning 2{{static variable 'd' is suspiciously used within its own initialization}} static int e = static_cast<long>(e) + 1; // expected-warning {{static variable 'e' is suspiciously used within its own initialization}} static int f = foo(f); // expected-warning {{static variable 'f' is suspiciously used within its own initialization}} // Thes don't warn as they don't require the value. static int g = sizeof(g); static void* ptr = &ptr; static int h = bar(&h); static int i = boo(i); static int j = far(j); static int k = __alignof__(k); static int l = k ? l : l; // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}} static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}} static int n = -n; // expected-warning {{static variable 'n' is suspiciously used within its own initialization}} static int o = std::move(o); // expected-warning {{static variable 'o' is suspiciously used within its own initialization}} static const int p = std::move(p); // expected-warning {{static variable 'p' is suspiciously used within its own initialization}} static int q = moved(std::move(q)); // expected-warning {{static variable 'q' is suspiciously used within its own initialization}} static int r = std::move((p ? q : (18, r))); // expected-warning {{static variable 'r' is suspiciously used within its own initialization}} static int s = r ?: s; // expected-warning {{static variable 's' is suspiciously used within its own initialization}} static int t = t ?: s; // expected-warning {{static variable 't' is suspiciously used within its own initialization}} static int u = (foo(u), s); // expected-warning {{static variable 'u' is suspiciously used within its own initialization}} static int v = (u += v); // expected-warning {{static variable 'v' is suspiciously used within its own initialization}} static int w = (w += 10); // expected-warning {{static variable 'w' is suspiciously used within its own initialization}} static int x = x++; // expected-warning {{static variable 'x' is suspiciously used within its own initialization}} static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{static variable 'y' is suspiciously used within its own initialization}} static int z = ++ref(z); // expected-warning {{static variable 'z' is suspiciously used within its own initialization}} static int aa = (ref(aa) += 10); // expected-warning {{static variable 'aa' is suspiciously used within its own initialization}} static int bb = bb ? x : y; // expected-warning {{static variable 'bb' is suspiciously used within its own initialization}} for (;;) { static int a = a; // no-warning: used to signal intended lack of initialization. static int b = b + 1; // expected-warning {{static variable 'b' is suspiciously used within its own initialization}} static int c = (c + c); // expected-warning 2{{static variable 'c' is suspiciously used within its own initialization}} static int d = ({ d + d ;}); // expected-warning 2{{static variable 'd' is suspiciously used within its own initialization}} static int e = static_cast<long>(e) + 1; // expected-warning {{static variable 'e' is suspiciously used within its own initialization}} static int f = foo(f); // expected-warning {{static variable 'f' is suspiciously used within its own initialization}} // Thes don't warn as they don't require the value. static int g = sizeof(g); static void* ptr = &ptr; static int h = bar(&h); static int i = boo(i); static int j = far(j); static int k = __alignof__(k); static int l = k ? l : l; // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}} static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}} static int n = -n; // expected-warning {{static variable 'n' is suspiciously used within its own initialization}} static int o = std::move(o); // expected-warning {{static variable 'o' is suspiciously used within its own initialization}} static const int p = std::move(p); // expected-warning {{static variable 'p' is suspiciously used within its own initialization}} static int q = moved(std::move(q)); // expected-warning {{static variable 'q' is suspiciously used within its own initialization}} static int r = std::move((p ? q : (18, r))); // expected-warning {{static variable 'r' is suspiciously used within its own initialization}} static int s = r ?: s; // expected-warning {{static variable 's' is suspiciously used within its own initialization}} static int t = t ?: s; // expected-warning {{static variable 't' is suspiciously used within its own initialization}} static int u = (foo(u), s); // expected-warning {{static variable 'u' is suspiciously used within its own initialization}} static int v = (u += v); // expected-warning {{static variable 'v' is suspiciously used within its own initialization}} static int w = (w += 10); // expected-warning {{static variable 'w' is suspiciously used within its own initialization}} static int x = x++; // expected-warning {{static variable 'x' is suspiciously used within its own initialization}} static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{static variable 'y' is suspiciously used within its own initialization}} static int z = ++ref(z); // expected-warning {{static variable 'z' is suspiciously used within its own initialization}} static int aa = (ref(aa) += 10); // expected-warning {{static variable 'aa' is suspiciously used within its own initialization}} static int bb = bb ? x : y; // expected-warning {{static variable 'bb' is suspiciously used within its own initialization}} } } } namespace in_class_initializers { struct S { S() : a(a + 1) {} // expected-warning{{field 'a' is uninitialized when used here}} int a = 42; // Note: because a is in a member initializer list, this initialization is ignored. }; struct T { T() : b(a + 1) {} // No-warning. int a = 42; int b; }; struct U { U() : a(b + 1), b(a + 1) {} // expected-warning{{field 'b' is uninitialized when used here}} int a = 42; // Note: because a and b are in the member initializer list, these initializers are ignored. int b = 1; }; } namespace references { int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}} int &b(b); // expected-warning{{reference 'b' is not yet bound to a value when used within its own initialization}} int &c = a ? b : c; // expected-warning{{reference 'c' is not yet bound to a value when used within its own initialization}} int &d{d}; // expected-warning{{reference 'd' is not yet bound to a value when used within its own initialization}} int &e = d ?: e; // expected-warning{{reference 'e' is not yet bound to a value when used within its own initialization}} int &f = f ?: d; // expected-warning{{reference 'f' is not yet bound to a value when used within its own initialization}} int &return_ref1(int); int &return_ref2(int&); int &g = return_ref1(g); // expected-warning{{reference 'g' is not yet bound to a value when used within its own initialization}} int &h = return_ref2(h); // expected-warning{{reference 'h' is not yet bound to a value when used within its own initialization}} struct S { S() : a(a) {} // expected-warning{{reference 'a' is not yet bound to a value when used here}} int &a; }; void test() { int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}} int &b(b); // expected-warning{{reference 'b' is not yet bound to a value when used within its own initialization}} int &c = a ? b : c; // expected-warning{{reference 'c' is not yet bound to a value when used within its own initialization}} int &d{d}; // expected-warning{{reference 'd' is not yet bound to a value when used within its own initialization}} } struct T { T() // expected-note{{during field initialization in this constructor}} : a(b), b(a) {} // expected-warning{{reference 'b' is not yet bound to a value when used here}} int &a, &b; int &c = c; // expected-warning{{reference 'c' is not yet bound to a value when used here}} }; int x; struct U { U() : b(a) {} // No-warning. int &a = x; int &b; }; } namespace operators { struct A { A(bool); bool operator==(A); }; A makeA(); A a1 = a1 = makeA(); // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}} A a2 = a2 == a1; // expected-warning{{variable 'a2' is uninitialized when used within its own initialization}} A a3 = a2 == a3; // expected-warning{{variable 'a3' is uninitialized when used within its own initialization}} int x = x = 5; } namespace lambdas { struct A { template<typename T> A(T) {} int x; }; A a0([] { return a0.x; }); // ok void f() { A a1([=] { return a1.x; }); // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}} A a2([&] { return a2.x; }); // ok } } namespace record_fields { bool x; struct A { A() {} A get(); static A num(); static A copy(A); static A something(A&); }; A ref(A&); A const_ref(const A&); A pointer(A*); A normal(A); A rref(A&&); struct B { A a; B(char (*)[1]) : a(a) {} // expected-warning {{uninitialized}} B(char (*)[2]) : a(a.get()) {} // expected-warning {{uninitialized}} B(char (*)[3]) : a(a.num()) {} B(char (*)[4]) : a(a.copy(a)) {} // expected-warning {{uninitialized}} B(char (*)[5]) : a(a.something(a)) {} B(char (*)[6]) : a(ref(a)) {} B(char (*)[7]) : a(const_ref(a)) {} B(char (*)[8]) : a(pointer(&a)) {} B(char (*)[9]) : a(normal(a)) {} // expected-warning {{uninitialized}} B(char (*)[10]) : a(std::move(a)) {} // expected-warning {{uninitialized}} B(char (*)[11]) : a(A(std::move(a))) {} // expected-warning {{uninitialized}} B(char (*)[12]) : a(rref(std::move(a))) {} // expected-warning {{uninitialized}} B(char (*)[13]) : a(std::move(x ? a : (25, a))) {} // expected-warning 2{{uninitialized}} }; struct C { C() {} // expected-note9{{in this constructor}} A a1 = a1; // expected-warning {{uninitialized}} A a2 = a2.get(); // expected-warning {{uninitialized}} A a3 = a3.num(); A a4 = a4.copy(a4); // expected-warning {{uninitialized}} A a5 = a5.something(a5); A a6 = ref(a6); A a7 = const_ref(a7); A a8 = pointer(&a8); A a9 = normal(a9); // expected-warning {{uninitialized}} const A a10 = a10; // expected-warning {{uninitialized}} A a11 = std::move(a11); // expected-warning {{uninitialized}} A a12 = A(std::move(a12)); // expected-warning {{uninitialized}} A a13 = rref(std::move(a13)); // expected-warning {{uninitialized}} A a14 = std::move(x ? a13 : (22, a14)); // expected-warning {{uninitialized}} }; struct D { // expected-note9{{in the implicit default constructor}} A a1 = a1; // expected-warning {{uninitialized}} A a2 = a2.get(); // expected-warning {{uninitialized}} A a3 = a3.num(); A a4 = a4.copy(a4); // expected-warning {{uninitialized}} A a5 = a5.something(a5); A a6 = ref(a6); A a7 = const_ref(a7); A a8 = pointer(&a8); A a9 = normal(a9); // expected-warning {{uninitialized}} const A a10 = a10; // expected-warning {{uninitialized}} A a11 = std::move(a11); // expected-warning {{uninitialized}} A a12 = A(std::move(a12)); // expected-warning {{uninitialized}} A a13 = rref(std::move(a13)); // expected-warning {{uninitialized}} A a14 = std::move(x ? a13 : (22, a14)); // expected-warning {{uninitialized}} }; D d; struct E { A a1 = a1; A a2 = a2.get(); A a3 = a3.num(); A a4 = a4.copy(a4); A a5 = a5.something(a5); A a6 = ref(a6); A a7 = const_ref(a7); A a8 = pointer(&a8); A a9 = normal(a9); const A a10 = a10; A a11 = std::move(a11); A a12 = A(std::move(a12)); A a13 = rref(std::move(a13)); A a14 = std::move(x ? a13 : (22, a14)); }; } namespace cross_field_warnings { struct A { int a, b; A() {} A(char (*)[1]) : b(a) {} // expected-warning{{field 'a' is uninitialized when used here}} A(char (*)[2]) : a(b) {} // expected-warning{{field 'b' is uninitialized when used here}} }; struct B { int a = b; // expected-warning{{field 'b' is uninitialized when used here}} int b; B() {} // expected-note{{during field initialization in this constructor}} }; struct C { int a; int b = a; // expected-warning{{field 'a' is uninitialized when used here}} C(char (*)[1]) : a(5) {} C(char (*)[2]) {} // expected-note{{during field initialization in this constructor}} }; struct D { int a; int &b; int &c = a; int d = b; D() : b(a) {} }; struct E { int a; int get(); static int num(); E() {} E(int) {} }; struct F { int a; E e; int b; F(char (*)[1]) : a(e.get()) {} // expected-warning{{field 'e' is uninitialized when used here}} F(char (*)[2]) : a(e.num()) {} F(char (*)[3]) : e(a) {} // expected-warning{{field 'a' is uninitialized when used here}} F(char (*)[4]) : a(4), e(a) {} F(char (*)[5]) : e(b) {} // expected-warning{{field 'b' is uninitialized when used here}} F(char (*)[6]) : e(b), b(4) {} // expected-warning{{field 'b' is uninitialized when used here}} }; struct G { G(const A&) {}; }; struct H { A a1; G g; A a2; H() : g(a1) {} H(int) : g(a2) {} }; struct I { I(int*) {} }; struct J : public I { int *a; int *b; int c; J() : I((a = new int(5))), b(a), c(*a) {} }; struct K { int a = (b = 5); int b = b + 5; }; struct L { int a = (b = 5); int b = b + 5; // expected-warning{{field 'b' is uninitialized when used here}} L() : a(5) {} // expected-note{{during field initialization in this constructor}} }; struct M { }; struct N : public M { int a; int b; N() : b(a) { } // expected-warning{{field 'a' is uninitialized when used here}} }; struct O { int x = 42; int get() { return x; } }; struct P { O o; int x = o.get(); P() : x(o.get()) { } }; struct Q { int a; int b; int &c; Q() : a(c = 5), // expected-warning{{reference 'c' is not yet bound to a value when used here}} b(c), // expected-warning{{reference 'c' is not yet bound to a value when used here}} c(a) {} }; struct R { int a; int b; int c; int d = a + b + c; R() : a(c = 5), b(c), c(a) {} }; // FIXME: Use the CFG-based analysis to give a sometimes uninitialized // warning on y. struct T { int x; int y; T(bool b) : x(b ? (y = 5) : (1 + y)), // expected-warning{{field 'y' is uninitialized when used here}} y(y + 1) {} T(int b) : x(!b ? (1 + y) : (y = 5)), // expected-warning{{field 'y' is uninitialized when used here}} y(y + 1) {} }; } namespace base_class { struct A { A (int) {} }; struct B : public A { int x; B() : A(x) {} // expected-warning{{field 'x' is uninitialized when used here}} }; struct C : public A { int x; int y; C() : A(y = 4), x(y) {} }; } namespace delegating_constructor { struct A { A(int); A(int&, int); A(char (*)[1]) : A(x) {} // expected-warning@-1 {{field 'x' is uninitialized when used here}} A(char (*)[2]) : A(x, x) {} // expected-warning@-1 {{field 'x' is uninitialized when used here}} A(char (*)[3]) : A(x, 0) {} int x; }; } namespace init_list { int num = 5; struct A { int i1, i2; }; struct B { A a1, a2; }; A a1{1,2}; A a2{a2.i1 + 2}; // expected-warning{{uninitialized}} A a3 = {a3.i1 + 2}; // expected-warning{{uninitialized}} A a4 = A{a4.i2 + 2}; // expected-warning{{uninitialized}} B b1 = { {}, {} }; B b2 = { {}, b2.a1 }; B b3 = { b3.a1 }; // expected-warning{{uninitialized}} B b4 = { {}, b4.a2} ; // expected-warning{{uninitialized}} B b5 = { b5.a2 }; // expected-warning{{uninitialized}} B b6 = { {b6.a1.i1} }; // expected-warning{{uninitialized}} B b7 = { {0, b7.a1.i1} }; B b8 = { {}, {b8.a1.i1} }; B b9 = { {}, {0, b9.a1.i1} }; B b10 = { {b10.a1.i2} }; // expected-warning{{uninitialized}} B b11 = { {0, b11.a1.i2} }; // expected-warning{{uninitialized}} B b12 = { {}, {b12.a1.i2} }; B b13 = { {}, {0, b13.a1.i2} }; B b14 = { {b14.a2.i1} }; // expected-warning{{uninitialized}} B b15 = { {0, b15.a2.i1} }; // expected-warning{{uninitialized}} B b16 = { {}, {b16.a2.i1} }; // expected-warning{{uninitialized}} B b17 = { {}, {0, b17.a2.i1} }; B b18 = { {b18.a2.i2} }; // expected-warning{{uninitialized}} B b19 = { {0, b19.a2.i2} }; // expected-warning{{uninitialized}} B b20 = { {}, {b20.a2.i2} }; // expected-warning{{uninitialized}} B b21 = { {}, {0, b21.a2.i2} }; // expected-warning{{uninitialized}} B b22 = { {b18.a2.i2 + 5} }; struct C {int a; int& b; int c; }; C c1 = { 0, num, 0 }; C c2 = { 1, num, c2.b }; C c3 = { c3.b, num }; // expected-warning{{uninitialized}} C c4 = { 0, c4.b, 0 }; // expected-warning{{uninitialized}} C c5 = { 0, c5.c, 0 }; C c6 = { c6.b, num, 0 }; // expected-warning{{uninitialized}} C c7 = { 0, c7.a, 0 }; struct D {int &a; int &b; }; D d1 = { num, num }; D d2 = { num, d2.a }; D d3 = { d3.b, num }; // expected-warning{{uninitialized}} // Same as above in member initializer form. struct Awrapper { A a1{1,2}; A a2{a2.i1 + 2}; // expected-warning{{uninitialized}} A a3 = {a3.i1 + 2}; // expected-warning{{uninitialized}} A a4 = A{a4.i2 + 2}; // expected-warning{{uninitialized}} Awrapper() {} // expected-note 3{{in this constructor}} Awrapper(int) : a1{1,2}, a2{a2.i1 + 2}, // expected-warning{{uninitialized}} a3{a3.i1 + 2}, // expected-warning{{uninitialized}} a4{a4.i2 + 2} // expected-warning{{uninitialized}} {} }; struct Bwrapper { B b1 = { {}, {} }; B b2 = { {}, b2.a1 }; B b3 = { b3.a1 }; // expected-warning{{uninitialized}} B b4 = { {}, b4.a2} ; // expected-warning{{uninitialized}} B b5 = { b5.a2 }; // expected-warning{{uninitialized}} B b6 = { {b6.a1.i1} }; // expected-warning{{uninitialized}} B b7 = { {0, b7.a1.i1} }; B b8 = { {}, {b8.a1.i1} }; B b9 = { {}, {0, b9.a1.i1} }; B b10 = { {b10.a1.i2} }; // expected-warning{{uninitialized}} B b11 = { {0, b11.a1.i2} }; // expected-warning{{uninitialized}} B b12 = { {}, {b12.a1.i2} }; B b13 = { {}, {0, b13.a1.i2} }; B b14 = { {b14.a2.i1} }; // expected-warning{{uninitialized}} B b15 = { {0, b15.a2.i1} }; // expected-warning{{uninitialized}} B b16 = { {}, {b16.a2.i1} }; // expected-warning{{uninitialized}} B b17 = { {}, {0, b17.a2.i1} }; B b18 = { {b18.a2.i2} }; // expected-warning{{uninitialized}} B b19 = { {0, b19.a2.i2} }; // expected-warning{{uninitialized}} B b20 = { {}, {b20.a2.i2} }; // expected-warning{{uninitialized}} B b21 = { {}, {0, b21.a2.i2} }; // expected-warning{{uninitialized}} B b22 = { {b18.a2.i2 + 5} }; Bwrapper() {} // expected-note 13{{in this constructor}} Bwrapper(int) : b1{ {}, {} }, b2{ {}, b2.a1 }, b3{ b3.a1 }, // expected-warning{{uninitialized}} b4{ {}, b4.a2}, // expected-warning{{uninitialized}} b5{ b5.a2 }, // expected-warning{{uninitialized}} b6{ {b6.a1.i1} }, // expected-warning{{uninitialized}} b7{ {0, b7.a1.i1} }, b8{ {}, {b8.a1.i1} }, b9{ {}, {0, b9.a1.i1} }, b10{ {b10.a1.i2} }, // expected-warning{{uninitialized}} b11{ {0, b11.a1.i2} }, // expected-warning{{uninitialized}} b12{ {}, {b12.a1.i2} }, b13{ {}, {0, b13.a1.i2} }, b14{ {b14.a2.i1} }, // expected-warning{{uninitialized}} b15{ {0, b15.a2.i1} }, // expected-warning{{uninitialized}} b16{ {}, {b16.a2.i1} }, // expected-warning{{uninitialized}} b17{ {}, {0, b17.a2.i1} }, b18{ {b18.a2.i2} }, // expected-warning{{uninitialized}} b19{ {0, b19.a2.i2} }, // expected-warning{{uninitialized}} b20{ {}, {b20.a2.i2} }, // expected-warning{{uninitialized}} b21{ {}, {0, b21.a2.i2} }, // expected-warning{{uninitialized}} b22{ {b18.a2.i2 + 5} } {} }; struct Cwrapper { C c1 = { 0, num, 0 }; C c2 = { 1, num, c2.b }; C c3 = { c3.b, num }; // expected-warning{{uninitialized}} C c4 = { 0, c4.b, 0 }; // expected-warning{{uninitialized}} C c5 = { 0, c5.c, 0 }; C c6 = { c6.b, num, 0 }; // expected-warning{{uninitialized}} C c7 = { 0, c7.a, 0 }; Cwrapper() {} // expected-note 3{{in this constructor}} Cwrapper(int) : c1{ 0, num, 0 }, c2{ 1, num, c2.b }, c3{ c3.b, num }, // expected-warning{{uninitialized}} c4{ 0, c4.b, 0 }, // expected-warning{{uninitialized}} c5{ 0, c5.c, 0 }, c6{ c6.b, num, 0 }, // expected-warning{{uninitialized}} c7{ 0, c7.a, 0 } {} }; struct Dwrapper { D d1 = { num, num }; D d2 = { num, d2.a }; D d3 = { d3.b, num }; // expected-warning{{uninitialized}} Dwrapper() {} // expected-note{{in this constructor}} Dwrapper(int) : d1{ num, num }, d2{ num, d2.a }, d3{ d3.b, num } // expected-warning{{uninitialized}} {} }; } namespace template_class { class Foo { public: int *Create() { return nullptr; } }; template <typename T> class A { public: // Don't warn on foo here. A() : ptr(foo->Create()) {} private: Foo *foo = new Foo; int *ptr; }; template <typename T> class B { public: // foo is uninitialized here, but class B is never instantiated. B() : ptr(foo->Create()) {} private: Foo *foo; int *ptr; }; template <typename T> class C { public: C() : ptr(foo->Create()) {} // expected-warning@-1 {{field 'foo' is uninitialized when used here}} private: Foo *foo; int *ptr; }; C<int> c; // expected-note@-1 {{in instantiation of member function 'template_class::C<int>::C' requested here}} } namespace base_class_access { struct A { A(); A(int); int i; int foo(); static int bar(); }; struct B : public A { B(int (*)[1]) : A() {} B(int (*)[2]) : A(bar()) {} B(int (*)[3]) : A(i) {} // expected-warning@-1 {{base class 'base_class_access::A' is uninitialized when used here to access 'base_class_access::A::i'}} B(int (*)[4]) : A(foo()) {} // expected-warning@-1 {{base_class_access::A' is uninitialized when used here to access 'base_class_access::A::foo'}} }; struct C { C(int) {} }; struct D : public C, public A { D(int (*)[1]) : C(0) {} D(int (*)[2]) : C(bar()) {} D(int (*)[3]) : C(i) {} // expected-warning@-1 {{base class 'base_class_access::A' is uninitialized when used here to access 'base_class_access::A::i'}} D(int (*)[4]) : C(foo()) {} // expected-warning@-1 {{base_class_access::A' is uninitialized when used here to access 'base_class_access::A::foo'}} }; } namespace value { template <class T> T move(T t); template <class T> T notmove(T t); } namespace lvalueref { template <class T> T move(T& t); template <class T> T notmove(T& t); } namespace rvalueref { template <class T> T move(T&& t); template <class T> T notmove(T&& t); } namespace move_test { int a1 = std::move(a1); // expected-warning {{uninitialized}} int a2 = value::move(a2); // expected-warning {{uninitialized}} int a3 = value::notmove(a3); // expected-warning {{uninitialized}} int a4 = lvalueref::move(a4); int a5 = lvalueref::notmove(a5); int a6 = rvalueref::move(a6); int a7 = rvalueref::notmove(a7); void test() { int a1 = std::move(a1); // expected-warning {{uninitialized}} int a2 = value::move(a2); // expected-warning {{uninitialized}} int a3 = value::notmove(a3); // expected-warning {{uninitialized}} int a4 = lvalueref::move(a4); int a5 = lvalueref::notmove(a5); int a6 = rvalueref::move(a6); int a7 = rvalueref::notmove(a7); } class A { int a; A(int (*) [1]) : a(std::move(a)) {} // expected-warning {{uninitialized}} A(int (*) [2]) : a(value::move(a)) {} // expected-warning {{uninitialized}} A(int (*) [3]) : a(value::notmove(a)) {} // expected-warning {{uninitialized}} A(int (*) [4]) : a(lvalueref::move(a)) {} A(int (*) [5]) : a(lvalueref::notmove(a)) {} A(int (*) [6]) : a(rvalueref::move(a)) {} A(int (*) [7]) : a(rvalueref::notmove(a)) {} }; } void array_capture(bool b) { const char fname[] = "array_capture"; if (b) { int unused; // expected-warning {{unused variable}} } else { [fname]{}; } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/vector.cpp
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s typedef char char16 __attribute__ ((__vector_size__ (16))); typedef long long longlong16 __attribute__ ((__vector_size__ (16))); typedef char char16_e __attribute__ ((__ext_vector_type__ (16))); typedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2))); // Test overloading and function calls with vector types. void f0(char16); void f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { f0(c16); f0(ll16); f0(c16e); f0(ll16e); } int &f1(char16); // expected-note 2{{candidate function}} float &f1(longlong16); // expected-note 2{{candidate function}} void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { int &ir1 = f1(c16); float &fr1 = f1(ll16); f1(c16e); // expected-error{{call to 'f1' is ambiguous}} f1(ll16e); // expected-error{{call to 'f1' is ambiguous}} } void f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) for 1st argument}} \ // expected-note{{candidate function not viable: no known conversion from 'convertible_to<longlong16_e>' to 'char16_e' (vector of 16 'char' values) for 1st argument}} void f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { f2(c16); f2(ll16); f2(c16e); f2(ll16e); // expected-error{{no matching function}} f2('a'); f2(17); } // Test the conditional operator with vector types. void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { // Conditional operators with the same type. __typeof__(Cond? c16 : c16) *c16p1 = &c16; __typeof__(Cond? ll16 : ll16) *ll16p1 = &ll16; __typeof__(Cond? c16e : c16e) *c16ep1 = &c16e; __typeof__(Cond? ll16e : ll16e) *ll16ep1 = &ll16e; // Conditional operators with similar types. __typeof__(Cond? c16 : c16e) *c16ep2 = &c16e; __typeof__(Cond? c16e : c16) *c16ep3 = &c16e; __typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e; __typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e; // Conditional operators with compatible types under -flax-vector-conversions (default) (void)(Cond? c16 : ll16); (void)(Cond? ll16e : c16e); (void)(Cond? ll16e : c16); } // Test C++ cast'ing of vector types. void casts(longlong16 ll16, longlong16_e ll16e) { // C-style casts. (void)(char16)ll16; (void)(char16_e)ll16; (void)(longlong16)ll16; (void)(longlong16_e)ll16; (void)(char16)ll16e; (void)(char16_e)ll16e; (void)(longlong16)ll16e; (void)(longlong16_e)ll16e; // Function-style casts. (void)char16(ll16); (void)char16_e(ll16); (void)longlong16(ll16); (void)longlong16_e(ll16); (void)char16(ll16e); (void)char16_e(ll16e); (void)longlong16(ll16e); (void)longlong16_e(ll16e); // static_cast (void)static_cast<char16>(ll16); (void)static_cast<char16_e>(ll16); (void)static_cast<longlong16>(ll16); (void)static_cast<longlong16_e>(ll16); (void)static_cast<char16>(ll16e); (void)static_cast<char16_e>(ll16e); // expected-error{{static_cast from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) is not allowed}} (void)static_cast<longlong16>(ll16e); (void)static_cast<longlong16_e>(ll16e); // reinterpret_cast (void)reinterpret_cast<char16>(ll16); (void)reinterpret_cast<char16_e>(ll16); (void)reinterpret_cast<longlong16>(ll16); (void)reinterpret_cast<longlong16_e>(ll16); (void)reinterpret_cast<char16>(ll16e); (void)reinterpret_cast<char16_e>(ll16e); (void)reinterpret_cast<longlong16>(ll16e); (void)reinterpret_cast<longlong16_e>(ll16e); } template<typename T> struct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator)}} operator T() const; }; void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e, convertible_to<char16> to_c16, convertible_to<longlong16> to_ll16, convertible_to<char16_e> to_c16e, convertible_to<longlong16_e> to_ll16e, convertible_to<char16&> rto_c16, convertible_to<char16_e&> rto_c16e) { f0(to_c16); f0(to_ll16); f0(to_c16e); f0(to_ll16e); f2(to_c16); f2(to_ll16); f2(to_c16e); f2(to_ll16e); // expected-error{{no matching function}} (void)(c16 == c16e); (void)(c16 == to_c16); (void)+to_c16; (void)-to_c16; (void)~to_c16; (void)(to_c16 == to_c16e); (void)(to_c16 != to_c16e); (void)(to_c16 < to_c16e); (void)(to_c16 <= to_c16e); (void)(to_c16 > to_c16e); (void)(to_c16 >= to_c16e); (void)(to_c16 + to_c16); (void)(to_c16 - to_c16); (void)(to_c16 * to_c16); (void)(to_c16 / to_c16); (void)(rto_c16 = to_c16); // expected-error{{no viable overloaded '='}} (void)(rto_c16 += to_c16); (void)(rto_c16 -= to_c16); (void)(rto_c16 *= to_c16); (void)(rto_c16 /= to_c16); (void)+to_c16e; (void)-to_c16e; (void)~to_c16e; (void)(to_c16e == to_c16e); (void)(to_c16e != to_c16e); (void)(to_c16e < to_c16e); (void)(to_c16e <= to_c16e); (void)(to_c16e > to_c16e); (void)(to_c16e >= to_c16e); (void)(to_c16e + to_c16); (void)(to_c16e - to_c16); (void)(to_c16e * to_c16); (void)(to_c16e / to_c16); (void)(rto_c16e = to_c16); // expected-error{{no viable overloaded '='}} (void)(rto_c16e += to_c16); (void)(rto_c16e -= to_c16); (void)(rto_c16e *= to_c16); (void)(rto_c16e /= to_c16); (void)+to_c16; (void)-to_c16; (void)~to_c16; (void)(to_c16 == to_c16e); (void)(to_c16 != to_c16e); (void)(to_c16 < to_c16e); (void)(to_c16 <= to_c16e); (void)(to_c16 > to_c16e); (void)(to_c16 >= to_c16e); (void)(to_c16 + to_c16e); (void)(to_c16 - to_c16e); (void)(to_c16 * to_c16e); (void)(to_c16 / to_c16e); (void)(rto_c16 = c16e); // expected-error{{no viable overloaded '='}} (void)(rto_c16 += to_c16e); (void)(rto_c16 -= to_c16e); (void)(rto_c16 *= to_c16e); (void)(rto_c16 /= to_c16e); (void)(Cond? to_c16 : to_c16e); (void)(Cond? to_ll16e : to_ll16); // These 2 are convertable with -flax-vector-conversions (default) (void)(Cond? to_c16 : to_ll16); (void)(Cond? to_c16e : to_ll16e); } typedef float fltx2 __attribute__((__vector_size__(8))); typedef float fltx4 __attribute__((__vector_size__(16))); typedef double dblx2 __attribute__((__vector_size__(16))); typedef double dblx4 __attribute__((__vector_size__(32))); void accept_fltx2(fltx2); // expected-note{{candidate function not viable: no known conversion from 'double' to 'fltx2' (vector of 2 'float' values) for 1st argument}} void accept_fltx4(fltx4); void accept_dblx2(dblx2); void accept_dblx4(dblx4); void accept_bool(bool); // expected-note{{candidate function not viable: no known conversion from 'fltx2' (vector of 2 'float' values) to 'bool' for 1st argument}} void test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) { // Exact matches accept_fltx2(fltx2_val); accept_fltx4(fltx4_val); accept_dblx2(dblx2_val); accept_dblx4(dblx4_val); // Same-size conversions // FIXME: G++ rejects these conversions, we accept them. Revisit this! accept_fltx4(dblx2_val); accept_dblx2(fltx4_val); // Conversion to bool. accept_bool(fltx2_val); // expected-error{{no matching function for call to 'accept_bool'}} // Scalar-to-vector conversions. accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}} } typedef int intx4 __attribute__((__vector_size__(16))); typedef int inte4 __attribute__((__ext_vector_type__(4))); typedef int flte4 __attribute__((__ext_vector_type__(4))); void test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, flte4 m) { (void)(f == g); (void)(g != f); (void)(f <= g); (void)(g >= f); (void)(f < g); (void)(g > f); (void)(+g); (void)(-g); (void)(f + g); (void)(f - g); (void)(f * g); (void)(f / g); (void)(f = g); (void)(f += g); (void)(f -= g); (void)(f *= g); (void)(f /= g); (void)(n == m); (void)(m != n); (void)(n <= m); (void)(m >= n); (void)(n < m); (void)(m > n); (void)(+m); (void)(-m); (void)(~m); (void)(n + m); (void)(n - m); (void)(n * m); (void)(n / m); (void)(n % m); (void)(n = m); (void)(n += m); (void)(n -= m); (void)(n *= m); (void)(n /= m); } template<typename T> void test_pseudo_dtor_tmpl(T *ptr) { ptr->~T(); (*ptr).~T(); } void test_pseudo_dtor(fltx4 *f) { f->~fltx4(); (*f).~fltx4(); test_pseudo_dtor_tmpl(f); } // PR16204 typedef __attribute__((ext_vector_type(4))) int vi4; const int &reference_to_vec_element = vi4(1).x; // PR12649 typedef bool bad __attribute__((__vector_size__(16))); // expected-error {{invalid vector element type 'bool'}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/ms_wide_bitfield.cpp
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1 struct A { char a : 9; // expected-error{{size of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}} int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}} bool c : 9; // expected-error{{size of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}} }; int a[sizeof(A) == 1 ? 1 : -1];
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overload-value-dep-arg.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics class C { C(void*); }; int f(const C&); int f(unsigned long); template<typename T> int f(const T* t) { return f(reinterpret_cast<unsigned long>(t)); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-infinite-recursion.cpp
// RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion void a() { // expected-warning{{call itself}} a(); } void b(int x) { // expected-warning{{call itself}} if (x) b(x); else b(x+1); } void c(int x) { if (x) c(5); } void d(int x) { // expected-warning{{call itself}} if (x) ++x; return d(x); } // Doesn't warn on mutually recursive functions void e(); void f(); void e() { f(); } void f() { e(); } // Don't warn on infinite loops void g() { while (true) g(); g(); } void h(int x) { while (x < 5) { h(x+1); } } void i(int x) { // expected-warning{{call itself}} while (x < 5) { --x; } i(0); } int j() { // expected-warning{{call itself}} return 5 + j(); } class S { static void a(); void b(); }; void S::a() { // expected-warning{{call itself}} return a(); } void S::b() { // expected-warning{{call itself}} int i = 0; do { ++i; b(); } while (i > 5); } template<class member> struct T { member m; void a() { return a(); } // expected-warning{{call itself}} static void b() { return b(); } // expected-warning{{call itself}} }; void test_T() { T<int> foo; foo.a(); // expected-note{{in instantiation}} foo.b(); // expected-note{{in instantiation}} } class U { U* u; void Fun() { // expected-warning{{call itself}} u->Fun(); } }; // No warnings on templated functions // sum<0>() is instantiated, does recursively call itself, but never runs. template <int value> int sum() { return value + sum<value/2>(); } template<> int sum<1>() { return 1; } template<int x, int y> int calculate_value() { if (x != y) return sum<x - y>(); // This instantiates sum<0>() even if never called. else return 0; } int value = calculate_value<1,1>(); void DoSomethingHere(); // DoStuff<0,0>() is instantiated, but never called. template<int First, int Last> int DoStuff() { if (First + 1 == Last) { // This branch gets removed during <0, 0> instantiation in so CFG for this // function goes straight to the else branch. DoSomethingHere(); } else { DoStuff<First, (First + Last)/2>(); DoStuff<(First + Last)/2, Last>(); } return 0; } int stuff = DoStuff<0, 1>(); template<int x> struct Wrapper { static int run() { // Similar to the above, Wrapper<0>::run() will discard the if statement. if (x == 1) return 0; return Wrapper<x/2>::run(); } static int run2() { // expected-warning{{call itself}} return run2(); } }; template <int x> int test_wrapper() { if (x != 0) return Wrapper<x>::run() + Wrapper<x>::run2(); // expected-note{{instantiation}} return 0; } int wrapper_sum = test_wrapper<2>(); // expected-note{{instantiation}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-format.cpp
// RUN: %clang_cc1 -fsyntax-only -Wformat-nonliteral -verify %s struct S { static void f(const char*, ...) __attribute__((format(printf, 1, 2))); static const char* f2(const char*) __attribute__((format_arg(1))); // GCC has a hidden 'this' argument in member functions which is why // the format argument is argument 2 here. void g(const char*, ...) __attribute__((format(printf, 2, 3))); const char* g2(const char*) __attribute__((format_arg(2))); void h(const char*, ...) __attribute__((format(printf, 1, 4))); // \ expected-error{{implicit this argument as the format string}} void h2(const char*, ...) __attribute__((format(printf, 2, 1))); // \ expected-error{{out of bounds}} const char* h3(const char*) __attribute__((format_arg(1))); // \ expected-error{{invalid for the implicit this argument}} void operator() (const char*, ...) __attribute__((format(printf, 2, 3))); }; // PR5521 struct A { void a(const char*,...) __attribute((format(printf,2,3))); }; void b(A x) { x.a("%d", 3); } // PR8625: correctly interpret static member calls as not having an implicit // 'this' argument. namespace PR8625 { struct S { static void f(const char*, const char*, ...) __attribute__((format(printf, 2, 3))); }; void test(S s, const char* str) { s.f(str, "%s", str); } } // Make sure we interpret member operator calls as having an implicit // this argument. void test_operator_call(S s, const char* str) { s("%s", str); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/access.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s class C { struct S; // expected-note {{previously declared 'private' here}} public: struct S {}; // expected-error {{'S' redeclared with 'public' access}} }; struct S { class C; // expected-note {{previously declared 'public' here}} private: class C { }; // expected-error {{'C' redeclared with 'private' access}} }; class T { protected: template<typename T> struct A; // expected-note {{previously declared 'protected' here}} private: template<typename T> struct A {}; // expected-error {{'A' redeclared with 'private' access}} }; // PR5573 namespace test1 { class A { private: class X; // expected-note {{previously declared 'private' here}} \ // expected-note {{previous declaration is here}} public: class X; // expected-error {{'X' redeclared with 'public' access}} \ // expected-warning {{class member cannot be redeclared}} class X {}; }; } // PR15209 namespace PR15209 { namespace alias_templates { template<typename T1, typename T2> struct U { }; template<typename T1> using W = U<T1, float>; class A { typedef int I; static constexpr I x = 0; // expected-note {{implicitly declared private here}} static constexpr I y = 42; // expected-note {{implicitly declared private here}} friend W<int>; }; template<typename T1> struct U<T1, float> { int v_; // the following will trigger for U<float, float> instantiation, via W<float> U() : v_(A::x) { } // expected-error {{'x' is a private member of 'PR15209::alias_templates::A'}} }; template<typename T1> struct U<T1, int> { int v_; U() : v_(A::y) { } // expected-error {{'y' is a private member of 'PR15209::alias_templates::A'}} }; template struct U<int, int>; // expected-note {{in instantiation of member function 'PR15209::alias_templates::U<int, int>::U' requested here}} void f() { W<int>(); // we should issue diagnostics for the following W<float>(); // expected-note {{in instantiation of member function 'PR15209::alias_templates::U<float, float>::U' requested here}} } } namespace templates { class A { typedef int I; // expected-note {{implicitly declared private here}} static constexpr I x = 0; // expected-note {{implicitly declared private here}} template<int> friend struct B; template<int> struct C; template<template<int> class T> friend struct TT; template<typename T> friend void funct(T); }; template<A::I> struct B { }; template<A::I> struct A::C { }; template<template<A::I> class T> struct TT { T<A::x> t; }; template struct TT<B>; template<A::I> struct D { }; // expected-error {{'I' is a private member of 'PR15209::templates::A'}} template struct TT<D>; // function template case template<typename T> void funct(T) { (void)A::x; } template void funct<int>(int); void f() { (void)A::x; // expected-error {{'x' is a private member of 'PR15209::templates::A'}} } } } namespace PR7434 { namespace comment0 { template <typename T> struct X; namespace N { class Y { template<typename T> friend struct X; int t; // expected-note {{here}} }; } template<typename T> struct X { X() { (void)N::Y().t; } // expected-error {{private}} }; X<char> x; } namespace comment2 { struct X; namespace N { class Y { friend struct X; int t; // expected-note {{here}} }; } struct X { X() { (void)N::Y().t; } // expected-error {{private}} }; } } namespace LocalExternVar { class test { private: struct private_struct { // expected-note 2{{here}} int x; }; int use_private(); }; int test::use_private() { extern int array[sizeof(test::private_struct)]; // ok return array[0]; } int f() { extern int array[sizeof(test::private_struct)]; // expected-error {{private}} return array[0]; } int array[sizeof(test::private_struct)]; // expected-error {{private}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-after-definition.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct X { }; struct Y { }; bool f0(X) { return true; } // expected-note{{definition}} bool f1(X) { return true; } __attribute__ ((__visibility__("hidden"))) bool f0(X); // expected-warning{{attribute}} __attribute__ ((__visibility__("hidden"))) bool f1(Y);
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/type-traits.cpp
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s #define T(b) (b) ? 1 : -1 #define F(b) (b) ? -1 : 1 struct NonPOD { NonPOD(int); }; // PODs enum Enum { EV }; struct POD { Enum e; int i; float f; NonPOD* p; }; struct Empty {}; typedef Empty EmptyAr[10]; typedef int Int; typedef Int IntAr[10]; typedef Int IntArNB[]; class Statics { static int priv; static NonPOD np; }; union EmptyUnion {}; union Union { int i; float f; }; struct HasFunc { void f (); }; struct HasOp { void operator *(); }; struct HasConv { operator int(); }; struct HasAssign { void operator =(int); }; struct HasAnonymousUnion { union { int i; float f; }; }; typedef int Vector __attribute__((vector_size(16))); typedef int VectorExt __attribute__((ext_vector_type(4))); // Not PODs typedef const void cvoid; struct Derives : POD {}; typedef Derives DerivesAr[10]; typedef Derives DerivesArNB[]; struct DerivesEmpty : Empty {}; struct HasCons { HasCons(int); }; struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); }; struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); }; struct HasNoThrowMoveAssign { HasNoThrowMoveAssign& operator=( const HasNoThrowMoveAssign&&) throw(); }; struct HasNoExceptNoThrowMoveAssign { HasNoExceptNoThrowMoveAssign& operator=( const HasNoExceptNoThrowMoveAssign&&) noexcept; }; struct HasThrowMoveAssign { HasThrowMoveAssign& operator=( const HasThrowMoveAssign&&) throw(POD); }; struct HasNoExceptFalseMoveAssign { HasNoExceptFalseMoveAssign& operator=( const HasNoExceptFalseMoveAssign&&) noexcept(false); }; struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); }; struct HasMemberMoveCtor { HasMoveCtor member; }; struct HasMemberMoveAssign { HasMoveAssign member; }; struct HasStaticMemberMoveCtor { static HasMoveCtor member; }; struct HasStaticMemberMoveAssign { static HasMoveAssign member; }; struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; }; struct HasMemberNoExceptFalseMoveAssign { HasNoExceptFalseMoveAssign member; }; struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; }; struct HasMemberNoExceptNoThrowMoveAssign { HasNoExceptNoThrowMoveAssign member; }; struct HasDefaultTrivialCopyAssign { HasDefaultTrivialCopyAssign &operator=( const HasDefaultTrivialCopyAssign&) = default; }; struct TrivialMoveButNotCopy { TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default; TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&); }; struct NonTrivialDefault { NonTrivialDefault(); }; struct HasDest { ~HasDest(); }; class HasPriv { int priv; }; class HasProt { protected: int prot; }; struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} }; struct HasNonPOD { NonPOD np; }; struct HasVirt { virtual void Virt() {}; }; typedef NonPOD NonPODAr[10]; typedef HasVirt VirtAr[10]; typedef NonPOD NonPODArNB[]; union NonPODUnion { int i; Derives n; }; struct DerivesHasCons : HasCons {}; struct DerivesHasCopyAssign : HasCopyAssign {}; struct DerivesHasMoveAssign : HasMoveAssign {}; struct DerivesHasDest : HasDest {}; struct DerivesHasPriv : HasPriv {}; struct DerivesHasProt : HasProt {}; struct DerivesHasRef : HasRef {}; struct DerivesHasVirt : HasVirt {}; struct DerivesHasMoveCtor : HasMoveCtor {}; struct HasNoThrowCopyAssign { void operator =(const HasNoThrowCopyAssign&) throw(); }; struct HasMultipleCopyAssign { void operator =(const HasMultipleCopyAssign&) throw(); void operator =(volatile HasMultipleCopyAssign&); }; struct HasMultipleNoThrowCopyAssign { void operator =(const HasMultipleNoThrowCopyAssign&) throw(); void operator =(volatile HasMultipleNoThrowCopyAssign&) throw(); }; struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); }; struct HasNoThrowConstructorWithArgs { HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw(); }; struct HasMultipleDefaultConstructor1 { HasMultipleDefaultConstructor1() throw(); HasMultipleDefaultConstructor1(int i = 0); }; struct HasMultipleDefaultConstructor2 { HasMultipleDefaultConstructor2(int i = 0); HasMultipleDefaultConstructor2() throw(); }; struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); }; struct HasMultipleCopy { HasMultipleCopy(const HasMultipleCopy&) throw(); HasMultipleCopy(volatile HasMultipleCopy&); }; struct HasMultipleNoThrowCopy { HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw(); HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw(); }; struct HasVirtDest { virtual ~HasVirtDest(); }; struct DerivedVirtDest : HasVirtDest {}; typedef HasVirtDest VirtDestAr[1]; class AllPrivate { AllPrivate() throw(); AllPrivate(const AllPrivate&) throw(); AllPrivate &operator=(const AllPrivate &) throw(); ~AllPrivate() throw(); }; struct ThreeArgCtor { ThreeArgCtor(int*, char*, int); }; struct VariadicCtor { template<typename...T> VariadicCtor(T...); }; void is_pod() { { int arr[T(__is_pod(int))]; } { int arr[T(__is_pod(Enum))]; } { int arr[T(__is_pod(POD))]; } { int arr[T(__is_pod(Int))]; } { int arr[T(__is_pod(IntAr))]; } { int arr[T(__is_pod(Statics))]; } { int arr[T(__is_pod(Empty))]; } { int arr[T(__is_pod(EmptyUnion))]; } { int arr[T(__is_pod(Union))]; } { int arr[T(__is_pod(HasFunc))]; } { int arr[T(__is_pod(HasOp))]; } { int arr[T(__is_pod(HasConv))]; } { int arr[T(__is_pod(HasAssign))]; } { int arr[T(__is_pod(IntArNB))]; } { int arr[T(__is_pod(HasAnonymousUnion))]; } { int arr[T(__is_pod(Vector))]; } { int arr[T(__is_pod(VectorExt))]; } { int arr[T(__is_pod(Derives))]; } { int arr[T(__is_pod(DerivesAr))]; } { int arr[T(__is_pod(DerivesArNB))]; } { int arr[T(__is_pod(DerivesEmpty))]; } { int arr[T(__is_pod(HasPriv))]; } { int arr[T(__is_pod(HasProt))]; } { int arr[T(__is_pod(DerivesHasPriv))]; } { int arr[T(__is_pod(DerivesHasProt))]; } { int arr[F(__is_pod(HasCons))]; } { int arr[F(__is_pod(HasCopyAssign))]; } { int arr[F(__is_pod(HasMoveAssign))]; } { int arr[F(__is_pod(HasDest))]; } { int arr[F(__is_pod(HasRef))]; } { int arr[F(__is_pod(HasVirt))]; } { int arr[F(__is_pod(DerivesHasCons))]; } { int arr[F(__is_pod(DerivesHasCopyAssign))]; } { int arr[F(__is_pod(DerivesHasMoveAssign))]; } { int arr[F(__is_pod(DerivesHasDest))]; } { int arr[F(__is_pod(DerivesHasRef))]; } { int arr[F(__is_pod(DerivesHasVirt))]; } { int arr[F(__is_pod(NonPOD))]; } { int arr[F(__is_pod(HasNonPOD))]; } { int arr[F(__is_pod(NonPODAr))]; } { int arr[F(__is_pod(NonPODArNB))]; } { int arr[F(__is_pod(void))]; } { int arr[F(__is_pod(cvoid))]; } // { int arr[F(__is_pod(NonPODUnion))]; } } typedef Empty EmptyAr[10]; struct Bit0 { int : 0; }; struct Bit0Cons { int : 0; Bit0Cons(); }; struct BitOnly { int x : 3; }; struct DerivesVirt : virtual POD {}; void is_empty() { { int arr[T(__is_empty(Empty))]; } { int arr[T(__is_empty(DerivesEmpty))]; } { int arr[T(__is_empty(HasCons))]; } { int arr[T(__is_empty(HasCopyAssign))]; } { int arr[T(__is_empty(HasMoveAssign))]; } { int arr[T(__is_empty(HasDest))]; } { int arr[T(__is_empty(HasFunc))]; } { int arr[T(__is_empty(HasOp))]; } { int arr[T(__is_empty(HasConv))]; } { int arr[T(__is_empty(HasAssign))]; } { int arr[T(__is_empty(Bit0))]; } { int arr[T(__is_empty(Bit0Cons))]; } { int arr[F(__is_empty(Int))]; } { int arr[F(__is_empty(POD))]; } { int arr[F(__is_empty(EmptyUnion))]; } { int arr[F(__is_empty(EmptyAr))]; } { int arr[F(__is_empty(HasRef))]; } { int arr[F(__is_empty(HasVirt))]; } { int arr[F(__is_empty(BitOnly))]; } { int arr[F(__is_empty(void))]; } { int arr[F(__is_empty(IntArNB))]; } { int arr[F(__is_empty(HasAnonymousUnion))]; } // { int arr[F(__is_empty(DerivesVirt))]; } } typedef Derives ClassType; void is_class() { { int arr[T(__is_class(Derives))]; } { int arr[T(__is_class(HasPriv))]; } { int arr[T(__is_class(ClassType))]; } { int arr[T(__is_class(HasAnonymousUnion))]; } { int arr[F(__is_class(int))]; } { int arr[F(__is_class(Enum))]; } { int arr[F(__is_class(Int))]; } { int arr[F(__is_class(IntAr))]; } { int arr[F(__is_class(DerivesAr))]; } { int arr[F(__is_class(Union))]; } { int arr[F(__is_class(cvoid))]; } { int arr[F(__is_class(IntArNB))]; } } typedef Union UnionAr[10]; typedef Union UnionType; void is_union() { { int arr[T(__is_union(Union))]; } { int arr[T(__is_union(UnionType))]; } { int arr[F(__is_union(int))]; } { int arr[F(__is_union(Enum))]; } { int arr[F(__is_union(Int))]; } { int arr[F(__is_union(IntAr))]; } { int arr[F(__is_union(UnionAr))]; } { int arr[F(__is_union(cvoid))]; } { int arr[F(__is_union(IntArNB))]; } { int arr[F(__is_union(HasAnonymousUnion))]; } } typedef Enum EnumType; void is_enum() { { int arr[T(__is_enum(Enum))]; } { int arr[T(__is_enum(EnumType))]; } { int arr[F(__is_enum(int))]; } { int arr[F(__is_enum(Union))]; } { int arr[F(__is_enum(Int))]; } { int arr[F(__is_enum(IntAr))]; } { int arr[F(__is_enum(UnionAr))]; } { int arr[F(__is_enum(Derives))]; } { int arr[F(__is_enum(ClassType))]; } { int arr[F(__is_enum(cvoid))]; } { int arr[F(__is_enum(IntArNB))]; } { int arr[F(__is_enum(HasAnonymousUnion))]; } } struct FinalClass final { }; template<typename T> struct PotentiallyFinal { }; template<typename T> struct PotentiallyFinal<T*> final { }; template<> struct PotentiallyFinal<int> final { }; void is_final() { { int arr[T(__is_final(FinalClass))]; } { int arr[T(__is_final(PotentiallyFinal<float*>))]; } { int arr[T(__is_final(PotentiallyFinal<int>))]; } { int arr[F(__is_final(int))]; } { int arr[F(__is_final(Union))]; } { int arr[F(__is_final(Int))]; } { int arr[F(__is_final(IntAr))]; } { int arr[F(__is_final(UnionAr))]; } { int arr[F(__is_final(Derives))]; } { int arr[F(__is_final(ClassType))]; } { int arr[F(__is_final(cvoid))]; } { int arr[F(__is_final(IntArNB))]; } { int arr[F(__is_final(HasAnonymousUnion))]; } { int arr[F(__is_final(PotentiallyFinal<float>))]; } } struct SealedClass sealed { }; template<typename T> struct PotentiallySealed { }; template<typename T> struct PotentiallySealed<T*> sealed { }; template<> struct PotentiallySealed<int> sealed { }; void is_sealed() { { int arr[T(__is_sealed(SealedClass))]; } { int arr[T(__is_sealed(PotentiallySealed<float*>))]; } { int arr[T(__is_sealed(PotentiallySealed<int>))]; } { int arr[F(__is_sealed(int))]; } { int arr[F(__is_sealed(Union))]; } { int arr[F(__is_sealed(Int))]; } { int arr[F(__is_sealed(IntAr))]; } { int arr[F(__is_sealed(UnionAr))]; } { int arr[F(__is_sealed(Derives))]; } { int arr[F(__is_sealed(ClassType))]; } { int arr[F(__is_sealed(cvoid))]; } { int arr[F(__is_sealed(IntArNB))]; } { int arr[F(__is_sealed(HasAnonymousUnion))]; } { int arr[F(__is_sealed(PotentiallyFinal<float>))]; } } typedef HasVirt Polymorph; struct InheritPolymorph : Polymorph {}; void is_polymorphic() { { int arr[T(__is_polymorphic(Polymorph))]; } { int arr[T(__is_polymorphic(InheritPolymorph))]; } { int arr[F(__is_polymorphic(int))]; } { int arr[F(__is_polymorphic(Union))]; } { int arr[F(__is_polymorphic(Int))]; } { int arr[F(__is_polymorphic(IntAr))]; } { int arr[F(__is_polymorphic(UnionAr))]; } { int arr[F(__is_polymorphic(Derives))]; } { int arr[F(__is_polymorphic(ClassType))]; } { int arr[F(__is_polymorphic(Enum))]; } { int arr[F(__is_polymorphic(cvoid))]; } { int arr[F(__is_polymorphic(IntArNB))]; } } void is_integral() { int t01[T(__is_integral(bool))]; int t02[T(__is_integral(char))]; int t03[T(__is_integral(signed char))]; int t04[T(__is_integral(unsigned char))]; //int t05[T(__is_integral(char16_t))]; //int t06[T(__is_integral(char32_t))]; int t07[T(__is_integral(wchar_t))]; int t08[T(__is_integral(short))]; int t09[T(__is_integral(unsigned short))]; int t10[T(__is_integral(int))]; int t11[T(__is_integral(unsigned int))]; int t12[T(__is_integral(long))]; int t13[T(__is_integral(unsigned long))]; int t21[F(__is_integral(float))]; int t22[F(__is_integral(double))]; int t23[F(__is_integral(long double))]; int t24[F(__is_integral(Union))]; int t25[F(__is_integral(UnionAr))]; int t26[F(__is_integral(Derives))]; int t27[F(__is_integral(ClassType))]; int t28[F(__is_integral(Enum))]; int t29[F(__is_integral(void))]; int t30[F(__is_integral(cvoid))]; int t31[F(__is_integral(IntArNB))]; } void is_floating_point() { int t01[T(__is_floating_point(float))]; int t02[T(__is_floating_point(double))]; int t03[T(__is_floating_point(long double))]; int t11[F(__is_floating_point(bool))]; int t12[F(__is_floating_point(char))]; int t13[F(__is_floating_point(signed char))]; int t14[F(__is_floating_point(unsigned char))]; //int t15[F(__is_floating_point(char16_t))]; //int t16[F(__is_floating_point(char32_t))]; int t17[F(__is_floating_point(wchar_t))]; int t18[F(__is_floating_point(short))]; int t19[F(__is_floating_point(unsigned short))]; int t20[F(__is_floating_point(int))]; int t21[F(__is_floating_point(unsigned int))]; int t22[F(__is_floating_point(long))]; int t23[F(__is_floating_point(unsigned long))]; int t24[F(__is_floating_point(Union))]; int t25[F(__is_floating_point(UnionAr))]; int t26[F(__is_floating_point(Derives))]; int t27[F(__is_floating_point(ClassType))]; int t28[F(__is_floating_point(Enum))]; int t29[F(__is_floating_point(void))]; int t30[F(__is_floating_point(cvoid))]; int t31[F(__is_floating_point(IntArNB))]; } void is_arithmetic() { int t01[T(__is_arithmetic(float))]; int t02[T(__is_arithmetic(double))]; int t03[T(__is_arithmetic(long double))]; int t11[T(__is_arithmetic(bool))]; int t12[T(__is_arithmetic(char))]; int t13[T(__is_arithmetic(signed char))]; int t14[T(__is_arithmetic(unsigned char))]; //int t15[T(__is_arithmetic(char16_t))]; //int t16[T(__is_arithmetic(char32_t))]; int t17[T(__is_arithmetic(wchar_t))]; int t18[T(__is_arithmetic(short))]; int t19[T(__is_arithmetic(unsigned short))]; int t20[T(__is_arithmetic(int))]; int t21[T(__is_arithmetic(unsigned int))]; int t22[T(__is_arithmetic(long))]; int t23[T(__is_arithmetic(unsigned long))]; int t24[F(__is_arithmetic(Union))]; int t25[F(__is_arithmetic(UnionAr))]; int t26[F(__is_arithmetic(Derives))]; int t27[F(__is_arithmetic(ClassType))]; int t28[F(__is_arithmetic(Enum))]; int t29[F(__is_arithmetic(void))]; int t30[F(__is_arithmetic(cvoid))]; int t31[F(__is_arithmetic(IntArNB))]; } struct ACompleteType {}; struct AnIncompleteType; void is_complete_type() { int t01[T(__is_complete_type(float))]; int t02[T(__is_complete_type(double))]; int t03[T(__is_complete_type(long double))]; int t11[T(__is_complete_type(bool))]; int t12[T(__is_complete_type(char))]; int t13[T(__is_complete_type(signed char))]; int t14[T(__is_complete_type(unsigned char))]; //int t15[T(__is_complete_type(char16_t))]; //int t16[T(__is_complete_type(char32_t))]; int t17[T(__is_complete_type(wchar_t))]; int t18[T(__is_complete_type(short))]; int t19[T(__is_complete_type(unsigned short))]; int t20[T(__is_complete_type(int))]; int t21[T(__is_complete_type(unsigned int))]; int t22[T(__is_complete_type(long))]; int t23[T(__is_complete_type(unsigned long))]; int t24[T(__is_complete_type(ACompleteType))]; int t30[F(__is_complete_type(AnIncompleteType))]; } void is_void() { int t01[T(__is_void(void))]; int t02[T(__is_void(cvoid))]; int t10[F(__is_void(float))]; int t11[F(__is_void(double))]; int t12[F(__is_void(long double))]; int t13[F(__is_void(bool))]; int t14[F(__is_void(char))]; int t15[F(__is_void(signed char))]; int t16[F(__is_void(unsigned char))]; int t17[F(__is_void(wchar_t))]; int t18[F(__is_void(short))]; int t19[F(__is_void(unsigned short))]; int t20[F(__is_void(int))]; int t21[F(__is_void(unsigned int))]; int t22[F(__is_void(long))]; int t23[F(__is_void(unsigned long))]; int t24[F(__is_void(Union))]; int t25[F(__is_void(UnionAr))]; int t26[F(__is_void(Derives))]; int t27[F(__is_void(ClassType))]; int t28[F(__is_void(Enum))]; int t29[F(__is_void(IntArNB))]; int t30[F(__is_void(void*))]; int t31[F(__is_void(cvoid*))]; } void is_array() { int t01[T(__is_array(IntAr))]; int t02[T(__is_array(IntArNB))]; int t03[T(__is_array(UnionAr))]; int t10[F(__is_array(void))]; int t11[F(__is_array(cvoid))]; int t12[F(__is_array(float))]; int t13[F(__is_array(double))]; int t14[F(__is_array(long double))]; int t15[F(__is_array(bool))]; int t16[F(__is_array(char))]; int t17[F(__is_array(signed char))]; int t18[F(__is_array(unsigned char))]; int t19[F(__is_array(wchar_t))]; int t20[F(__is_array(short))]; int t21[F(__is_array(unsigned short))]; int t22[F(__is_array(int))]; int t23[F(__is_array(unsigned int))]; int t24[F(__is_array(long))]; int t25[F(__is_array(unsigned long))]; int t26[F(__is_array(Union))]; int t27[F(__is_array(Derives))]; int t28[F(__is_array(ClassType))]; int t29[F(__is_array(Enum))]; int t30[F(__is_array(void*))]; int t31[F(__is_array(cvoid*))]; } template <typename T> void tmpl_func(T&) {} template <typename T> struct type_wrapper { typedef T type; typedef T* ptrtype; typedef T& reftype; }; void is_function() { int t01[T(__is_function(type_wrapper<void(void)>::type))]; int t02[T(__is_function(typeof(tmpl_func<int>)))]; typedef void (*ptr_to_func_type)(void); int t10[F(__is_function(void))]; int t11[F(__is_function(cvoid))]; int t12[F(__is_function(float))]; int t13[F(__is_function(double))]; int t14[F(__is_function(long double))]; int t15[F(__is_function(bool))]; int t16[F(__is_function(char))]; int t17[F(__is_function(signed char))]; int t18[F(__is_function(unsigned char))]; int t19[F(__is_function(wchar_t))]; int t20[F(__is_function(short))]; int t21[F(__is_function(unsigned short))]; int t22[F(__is_function(int))]; int t23[F(__is_function(unsigned int))]; int t24[F(__is_function(long))]; int t25[F(__is_function(unsigned long))]; int t26[F(__is_function(Union))]; int t27[F(__is_function(Derives))]; int t28[F(__is_function(ClassType))]; int t29[F(__is_function(Enum))]; int t30[F(__is_function(void*))]; int t31[F(__is_function(cvoid*))]; int t32[F(__is_function(void(*)()))]; int t33[F(__is_function(ptr_to_func_type))]; int t34[F(__is_function(type_wrapper<void(void)>::ptrtype))]; int t35[F(__is_function(type_wrapper<void(void)>::reftype))]; } void is_reference() { int t01[T(__is_reference(int&))]; int t02[T(__is_reference(const int&))]; int t03[T(__is_reference(void *&))]; int t10[F(__is_reference(int))]; int t11[F(__is_reference(const int))]; int t12[F(__is_reference(void *))]; } void is_lvalue_reference() { int t01[T(__is_lvalue_reference(int&))]; int t02[T(__is_lvalue_reference(void *&))]; int t03[T(__is_lvalue_reference(const int&))]; int t04[T(__is_lvalue_reference(void * const &))]; int t10[F(__is_lvalue_reference(int))]; int t11[F(__is_lvalue_reference(const int))]; int t12[F(__is_lvalue_reference(void *))]; } #if __has_feature(cxx_rvalue_references) void is_rvalue_reference() { int t01[T(__is_rvalue_reference(const int&&))]; int t02[T(__is_rvalue_reference(void * const &&))]; int t10[F(__is_rvalue_reference(int&))]; int t11[F(__is_rvalue_reference(void *&))]; int t12[F(__is_rvalue_reference(const int&))]; int t13[F(__is_rvalue_reference(void * const &))]; int t14[F(__is_rvalue_reference(int))]; int t15[F(__is_rvalue_reference(const int))]; int t16[F(__is_rvalue_reference(void *))]; } #endif void is_fundamental() { int t01[T(__is_fundamental(float))]; int t02[T(__is_fundamental(double))]; int t03[T(__is_fundamental(long double))]; int t11[T(__is_fundamental(bool))]; int t12[T(__is_fundamental(char))]; int t13[T(__is_fundamental(signed char))]; int t14[T(__is_fundamental(unsigned char))]; //int t15[T(__is_fundamental(char16_t))]; //int t16[T(__is_fundamental(char32_t))]; int t17[T(__is_fundamental(wchar_t))]; int t18[T(__is_fundamental(short))]; int t19[T(__is_fundamental(unsigned short))]; int t20[T(__is_fundamental(int))]; int t21[T(__is_fundamental(unsigned int))]; int t22[T(__is_fundamental(long))]; int t23[T(__is_fundamental(unsigned long))]; int t24[T(__is_fundamental(void))]; int t25[T(__is_fundamental(cvoid))]; int t30[F(__is_fundamental(Union))]; int t31[F(__is_fundamental(UnionAr))]; int t32[F(__is_fundamental(Derives))]; int t33[F(__is_fundamental(ClassType))]; int t34[F(__is_fundamental(Enum))]; int t35[F(__is_fundamental(IntArNB))]; } void is_object() { int t01[T(__is_object(int))]; int t02[T(__is_object(int *))]; int t03[T(__is_object(void *))]; int t04[T(__is_object(Union))]; int t05[T(__is_object(UnionAr))]; int t06[T(__is_object(ClassType))]; int t07[T(__is_object(Enum))]; int t10[F(__is_object(type_wrapper<void(void)>::type))]; int t11[F(__is_object(int&))]; int t12[F(__is_object(void))]; } void is_scalar() { int t01[T(__is_scalar(float))]; int t02[T(__is_scalar(double))]; int t03[T(__is_scalar(long double))]; int t04[T(__is_scalar(bool))]; int t05[T(__is_scalar(char))]; int t06[T(__is_scalar(signed char))]; int t07[T(__is_scalar(unsigned char))]; int t08[T(__is_scalar(wchar_t))]; int t09[T(__is_scalar(short))]; int t10[T(__is_scalar(unsigned short))]; int t11[T(__is_scalar(int))]; int t12[T(__is_scalar(unsigned int))]; int t13[T(__is_scalar(long))]; int t14[T(__is_scalar(unsigned long))]; int t15[T(__is_scalar(Enum))]; int t16[T(__is_scalar(void*))]; int t17[T(__is_scalar(cvoid*))]; int t20[F(__is_scalar(void))]; int t21[F(__is_scalar(cvoid))]; int t22[F(__is_scalar(Union))]; int t23[F(__is_scalar(UnionAr))]; int t24[F(__is_scalar(Derives))]; int t25[F(__is_scalar(ClassType))]; int t26[F(__is_scalar(IntArNB))]; } struct StructWithMembers { int member; void method() {} }; void is_compound() { int t01[T(__is_compound(void*))]; int t02[T(__is_compound(cvoid*))]; int t03[T(__is_compound(void (*)()))]; int t04[T(__is_compound(int StructWithMembers::*))]; int t05[T(__is_compound(void (StructWithMembers::*)()))]; int t06[T(__is_compound(int&))]; int t07[T(__is_compound(Union))]; int t08[T(__is_compound(UnionAr))]; int t09[T(__is_compound(Derives))]; int t10[T(__is_compound(ClassType))]; int t11[T(__is_compound(IntArNB))]; int t12[T(__is_compound(Enum))]; int t20[F(__is_compound(float))]; int t21[F(__is_compound(double))]; int t22[F(__is_compound(long double))]; int t23[F(__is_compound(bool))]; int t24[F(__is_compound(char))]; int t25[F(__is_compound(signed char))]; int t26[F(__is_compound(unsigned char))]; int t27[F(__is_compound(wchar_t))]; int t28[F(__is_compound(short))]; int t29[F(__is_compound(unsigned short))]; int t30[F(__is_compound(int))]; int t31[F(__is_compound(unsigned int))]; int t32[F(__is_compound(long))]; int t33[F(__is_compound(unsigned long))]; int t34[F(__is_compound(void))]; int t35[F(__is_compound(cvoid))]; } void is_pointer() { StructWithMembers x; int t01[T(__is_pointer(void*))]; int t02[T(__is_pointer(cvoid*))]; int t03[T(__is_pointer(cvoid*))]; int t04[T(__is_pointer(char*))]; int t05[T(__is_pointer(int*))]; int t06[T(__is_pointer(int**))]; int t07[T(__is_pointer(ClassType*))]; int t08[T(__is_pointer(Derives*))]; int t09[T(__is_pointer(Enum*))]; int t10[T(__is_pointer(IntArNB*))]; int t11[T(__is_pointer(Union*))]; int t12[T(__is_pointer(UnionAr*))]; int t13[T(__is_pointer(StructWithMembers*))]; int t14[T(__is_pointer(void (*)()))]; int t20[F(__is_pointer(void))]; int t21[F(__is_pointer(cvoid))]; int t22[F(__is_pointer(cvoid))]; int t23[F(__is_pointer(char))]; int t24[F(__is_pointer(int))]; int t25[F(__is_pointer(int))]; int t26[F(__is_pointer(ClassType))]; int t27[F(__is_pointer(Derives))]; int t28[F(__is_pointer(Enum))]; int t29[F(__is_pointer(IntArNB))]; int t30[F(__is_pointer(Union))]; int t31[F(__is_pointer(UnionAr))]; int t32[F(__is_pointer(StructWithMembers))]; int t33[F(__is_pointer(int StructWithMembers::*))]; int t34[F(__is_pointer(void (StructWithMembers::*) ()))]; } void is_member_object_pointer() { StructWithMembers x; int t01[T(__is_member_object_pointer(int StructWithMembers::*))]; int t10[F(__is_member_object_pointer(void (StructWithMembers::*) ()))]; int t11[F(__is_member_object_pointer(void*))]; int t12[F(__is_member_object_pointer(cvoid*))]; int t13[F(__is_member_object_pointer(cvoid*))]; int t14[F(__is_member_object_pointer(char*))]; int t15[F(__is_member_object_pointer(int*))]; int t16[F(__is_member_object_pointer(int**))]; int t17[F(__is_member_object_pointer(ClassType*))]; int t18[F(__is_member_object_pointer(Derives*))]; int t19[F(__is_member_object_pointer(Enum*))]; int t20[F(__is_member_object_pointer(IntArNB*))]; int t21[F(__is_member_object_pointer(Union*))]; int t22[F(__is_member_object_pointer(UnionAr*))]; int t23[F(__is_member_object_pointer(StructWithMembers*))]; int t24[F(__is_member_object_pointer(void))]; int t25[F(__is_member_object_pointer(cvoid))]; int t26[F(__is_member_object_pointer(cvoid))]; int t27[F(__is_member_object_pointer(char))]; int t28[F(__is_member_object_pointer(int))]; int t29[F(__is_member_object_pointer(int))]; int t30[F(__is_member_object_pointer(ClassType))]; int t31[F(__is_member_object_pointer(Derives))]; int t32[F(__is_member_object_pointer(Enum))]; int t33[F(__is_member_object_pointer(IntArNB))]; int t34[F(__is_member_object_pointer(Union))]; int t35[F(__is_member_object_pointer(UnionAr))]; int t36[F(__is_member_object_pointer(StructWithMembers))]; int t37[F(__is_member_object_pointer(void (*)()))]; } void is_member_function_pointer() { StructWithMembers x; int t01[T(__is_member_function_pointer(void (StructWithMembers::*) ()))]; int t10[F(__is_member_function_pointer(int StructWithMembers::*))]; int t11[F(__is_member_function_pointer(void*))]; int t12[F(__is_member_function_pointer(cvoid*))]; int t13[F(__is_member_function_pointer(cvoid*))]; int t14[F(__is_member_function_pointer(char*))]; int t15[F(__is_member_function_pointer(int*))]; int t16[F(__is_member_function_pointer(int**))]; int t17[F(__is_member_function_pointer(ClassType*))]; int t18[F(__is_member_function_pointer(Derives*))]; int t19[F(__is_member_function_pointer(Enum*))]; int t20[F(__is_member_function_pointer(IntArNB*))]; int t21[F(__is_member_function_pointer(Union*))]; int t22[F(__is_member_function_pointer(UnionAr*))]; int t23[F(__is_member_function_pointer(StructWithMembers*))]; int t24[F(__is_member_function_pointer(void))]; int t25[F(__is_member_function_pointer(cvoid))]; int t26[F(__is_member_function_pointer(cvoid))]; int t27[F(__is_member_function_pointer(char))]; int t28[F(__is_member_function_pointer(int))]; int t29[F(__is_member_function_pointer(int))]; int t30[F(__is_member_function_pointer(ClassType))]; int t31[F(__is_member_function_pointer(Derives))]; int t32[F(__is_member_function_pointer(Enum))]; int t33[F(__is_member_function_pointer(IntArNB))]; int t34[F(__is_member_function_pointer(Union))]; int t35[F(__is_member_function_pointer(UnionAr))]; int t36[F(__is_member_function_pointer(StructWithMembers))]; int t37[F(__is_member_function_pointer(void (*)()))]; } void is_member_pointer() { StructWithMembers x; int t01[T(__is_member_pointer(int StructWithMembers::*))]; int t02[T(__is_member_pointer(void (StructWithMembers::*) ()))]; int t10[F(__is_member_pointer(void*))]; int t11[F(__is_member_pointer(cvoid*))]; int t12[F(__is_member_pointer(cvoid*))]; int t13[F(__is_member_pointer(char*))]; int t14[F(__is_member_pointer(int*))]; int t15[F(__is_member_pointer(int**))]; int t16[F(__is_member_pointer(ClassType*))]; int t17[F(__is_member_pointer(Derives*))]; int t18[F(__is_member_pointer(Enum*))]; int t19[F(__is_member_pointer(IntArNB*))]; int t20[F(__is_member_pointer(Union*))]; int t21[F(__is_member_pointer(UnionAr*))]; int t22[F(__is_member_pointer(StructWithMembers*))]; int t23[F(__is_member_pointer(void))]; int t24[F(__is_member_pointer(cvoid))]; int t25[F(__is_member_pointer(cvoid))]; int t26[F(__is_member_pointer(char))]; int t27[F(__is_member_pointer(int))]; int t28[F(__is_member_pointer(int))]; int t29[F(__is_member_pointer(ClassType))]; int t30[F(__is_member_pointer(Derives))]; int t31[F(__is_member_pointer(Enum))]; int t32[F(__is_member_pointer(IntArNB))]; int t33[F(__is_member_pointer(Union))]; int t34[F(__is_member_pointer(UnionAr))]; int t35[F(__is_member_pointer(StructWithMembers))]; int t36[F(__is_member_pointer(void (*)()))]; } void is_const() { int t01[T(__is_const(cvoid))]; int t02[T(__is_const(const char))]; int t03[T(__is_const(const int))]; int t04[T(__is_const(const long))]; int t05[T(__is_const(const short))]; int t06[T(__is_const(const signed char))]; int t07[T(__is_const(const wchar_t))]; int t08[T(__is_const(const bool))]; int t09[T(__is_const(const float))]; int t10[T(__is_const(const double))]; int t11[T(__is_const(const long double))]; int t12[T(__is_const(const unsigned char))]; int t13[T(__is_const(const unsigned int))]; int t14[T(__is_const(const unsigned long long))]; int t15[T(__is_const(const unsigned long))]; int t16[T(__is_const(const unsigned short))]; int t17[T(__is_const(const void))]; int t18[T(__is_const(const ClassType))]; int t19[T(__is_const(const Derives))]; int t20[T(__is_const(const Enum))]; int t21[T(__is_const(const IntArNB))]; int t22[T(__is_const(const Union))]; int t23[T(__is_const(const UnionAr))]; int t30[F(__is_const(char))]; int t31[F(__is_const(int))]; int t32[F(__is_const(long))]; int t33[F(__is_const(short))]; int t34[F(__is_const(signed char))]; int t35[F(__is_const(wchar_t))]; int t36[F(__is_const(bool))]; int t37[F(__is_const(float))]; int t38[F(__is_const(double))]; int t39[F(__is_const(long double))]; int t40[F(__is_const(unsigned char))]; int t41[F(__is_const(unsigned int))]; int t42[F(__is_const(unsigned long long))]; int t43[F(__is_const(unsigned long))]; int t44[F(__is_const(unsigned short))]; int t45[F(__is_const(void))]; int t46[F(__is_const(ClassType))]; int t47[F(__is_const(Derives))]; int t48[F(__is_const(Enum))]; int t49[F(__is_const(IntArNB))]; int t50[F(__is_const(Union))]; int t51[F(__is_const(UnionAr))]; } void is_volatile() { int t02[T(__is_volatile(volatile char))]; int t03[T(__is_volatile(volatile int))]; int t04[T(__is_volatile(volatile long))]; int t05[T(__is_volatile(volatile short))]; int t06[T(__is_volatile(volatile signed char))]; int t07[T(__is_volatile(volatile wchar_t))]; int t08[T(__is_volatile(volatile bool))]; int t09[T(__is_volatile(volatile float))]; int t10[T(__is_volatile(volatile double))]; int t11[T(__is_volatile(volatile long double))]; int t12[T(__is_volatile(volatile unsigned char))]; int t13[T(__is_volatile(volatile unsigned int))]; int t14[T(__is_volatile(volatile unsigned long long))]; int t15[T(__is_volatile(volatile unsigned long))]; int t16[T(__is_volatile(volatile unsigned short))]; int t17[T(__is_volatile(volatile void))]; int t18[T(__is_volatile(volatile ClassType))]; int t19[T(__is_volatile(volatile Derives))]; int t20[T(__is_volatile(volatile Enum))]; int t21[T(__is_volatile(volatile IntArNB))]; int t22[T(__is_volatile(volatile Union))]; int t23[T(__is_volatile(volatile UnionAr))]; int t30[F(__is_volatile(char))]; int t31[F(__is_volatile(int))]; int t32[F(__is_volatile(long))]; int t33[F(__is_volatile(short))]; int t34[F(__is_volatile(signed char))]; int t35[F(__is_volatile(wchar_t))]; int t36[F(__is_volatile(bool))]; int t37[F(__is_volatile(float))]; int t38[F(__is_volatile(double))]; int t39[F(__is_volatile(long double))]; int t40[F(__is_volatile(unsigned char))]; int t41[F(__is_volatile(unsigned int))]; int t42[F(__is_volatile(unsigned long long))]; int t43[F(__is_volatile(unsigned long))]; int t44[F(__is_volatile(unsigned short))]; int t45[F(__is_volatile(void))]; int t46[F(__is_volatile(ClassType))]; int t47[F(__is_volatile(Derives))]; int t48[F(__is_volatile(Enum))]; int t49[F(__is_volatile(IntArNB))]; int t50[F(__is_volatile(Union))]; int t51[F(__is_volatile(UnionAr))]; } struct TrivialStruct { int member; }; struct NonTrivialStruct { int member; NonTrivialStruct() { member = 0; } }; struct SuperNonTrivialStruct { SuperNonTrivialStruct() { } ~SuperNonTrivialStruct() { } }; struct NonTCStruct { NonTCStruct(const NonTCStruct&) {} }; struct AllDefaulted { AllDefaulted() = default; AllDefaulted(const AllDefaulted &) = default; AllDefaulted(AllDefaulted &&) = default; AllDefaulted &operator=(const AllDefaulted &) = default; AllDefaulted &operator=(AllDefaulted &&) = default; ~AllDefaulted() = default; }; struct NoDefaultMoveAssignDueToUDCopyCtor { NoDefaultMoveAssignDueToUDCopyCtor(const NoDefaultMoveAssignDueToUDCopyCtor&); }; struct NoDefaultMoveAssignDueToUDCopyAssign { NoDefaultMoveAssignDueToUDCopyAssign& operator=( const NoDefaultMoveAssignDueToUDCopyAssign&); }; struct NoDefaultMoveAssignDueToDtor { ~NoDefaultMoveAssignDueToDtor(); }; struct AllDeleted { AllDeleted() = delete; AllDeleted(const AllDeleted &) = delete; AllDeleted(AllDeleted &&) = delete; AllDeleted &operator=(const AllDeleted &) = delete; AllDeleted &operator=(AllDeleted &&) = delete; ~AllDeleted() = delete; }; struct ExtDefaulted { ExtDefaulted(); ExtDefaulted(const ExtDefaulted &); ExtDefaulted(ExtDefaulted &&); ExtDefaulted &operator=(const ExtDefaulted &); ExtDefaulted &operator=(ExtDefaulted &&); ~ExtDefaulted(); }; // Despite being defaulted, these functions are not trivial. ExtDefaulted::ExtDefaulted() = default; ExtDefaulted::ExtDefaulted(const ExtDefaulted &) = default; ExtDefaulted::ExtDefaulted(ExtDefaulted &&) = default; ExtDefaulted &ExtDefaulted::operator=(const ExtDefaulted &) = default; ExtDefaulted &ExtDefaulted::operator=(ExtDefaulted &&) = default; ExtDefaulted::~ExtDefaulted() = default; void is_trivial2() { int t01[T(__is_trivial(char))]; int t02[T(__is_trivial(int))]; int t03[T(__is_trivial(long))]; int t04[T(__is_trivial(short))]; int t05[T(__is_trivial(signed char))]; int t06[T(__is_trivial(wchar_t))]; int t07[T(__is_trivial(bool))]; int t08[T(__is_trivial(float))]; int t09[T(__is_trivial(double))]; int t10[T(__is_trivial(long double))]; int t11[T(__is_trivial(unsigned char))]; int t12[T(__is_trivial(unsigned int))]; int t13[T(__is_trivial(unsigned long long))]; int t14[T(__is_trivial(unsigned long))]; int t15[T(__is_trivial(unsigned short))]; int t16[T(__is_trivial(ClassType))]; int t17[T(__is_trivial(Derives))]; int t18[T(__is_trivial(Enum))]; int t19[T(__is_trivial(IntAr))]; int t20[T(__is_trivial(Union))]; int t21[T(__is_trivial(UnionAr))]; int t22[T(__is_trivial(TrivialStruct))]; int t23[T(__is_trivial(AllDefaulted))]; int t24[T(__is_trivial(AllDeleted))]; int t30[F(__is_trivial(void))]; int t31[F(__is_trivial(NonTrivialStruct))]; int t32[F(__is_trivial(SuperNonTrivialStruct))]; int t33[F(__is_trivial(NonTCStruct))]; int t34[F(__is_trivial(ExtDefaulted))]; } void is_trivially_copyable2() { int t01[T(__is_trivially_copyable(char))]; int t02[T(__is_trivially_copyable(int))]; int t03[T(__is_trivially_copyable(long))]; int t04[T(__is_trivially_copyable(short))]; int t05[T(__is_trivially_copyable(signed char))]; int t06[T(__is_trivially_copyable(wchar_t))]; int t07[T(__is_trivially_copyable(bool))]; int t08[T(__is_trivially_copyable(float))]; int t09[T(__is_trivially_copyable(double))]; int t10[T(__is_trivially_copyable(long double))]; int t11[T(__is_trivially_copyable(unsigned char))]; int t12[T(__is_trivially_copyable(unsigned int))]; int t13[T(__is_trivially_copyable(unsigned long long))]; int t14[T(__is_trivially_copyable(unsigned long))]; int t15[T(__is_trivially_copyable(unsigned short))]; int t16[T(__is_trivially_copyable(ClassType))]; int t17[T(__is_trivially_copyable(Derives))]; int t18[T(__is_trivially_copyable(Enum))]; int t19[T(__is_trivially_copyable(IntAr))]; int t20[T(__is_trivially_copyable(Union))]; int t21[T(__is_trivially_copyable(UnionAr))]; int t22[T(__is_trivially_copyable(TrivialStruct))]; int t23[T(__is_trivially_copyable(NonTrivialStruct))]; int t24[T(__is_trivially_copyable(AllDefaulted))]; int t25[T(__is_trivially_copyable(AllDeleted))]; int t30[F(__is_trivially_copyable(void))]; int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))]; int t32[F(__is_trivially_copyable(NonTCStruct))]; int t33[F(__is_trivially_copyable(ExtDefaulted))]; int t34[T(__is_trivially_copyable(const int))]; int t35[F(__is_trivially_copyable(volatile int))]; } struct CStruct { int one; int two; }; struct CEmptyStruct {}; struct CppEmptyStruct : CStruct {}; struct CppStructStandard : CEmptyStruct { int three; int four; }; struct CppStructNonStandardByBase : CStruct { int three; int four; }; struct CppStructNonStandardByVirt : CStruct { virtual void method() {} }; struct CppStructNonStandardByMemb : CStruct { CppStructNonStandardByVirt member; }; struct CppStructNonStandardByProt : CStruct { int five; protected: int six; }; struct CppStructNonStandardByVirtBase : virtual CStruct { }; struct CppStructNonStandardBySameBase : CEmptyStruct { CEmptyStruct member; }; struct CppStructNonStandardBy2ndVirtBase : CEmptyStruct { CEmptyStruct member; }; void is_standard_layout() { typedef const int ConstInt; typedef ConstInt ConstIntAr[4]; typedef CppStructStandard CppStructStandardAr[4]; int t01[T(__is_standard_layout(int))]; int t02[T(__is_standard_layout(ConstInt))]; int t03[T(__is_standard_layout(ConstIntAr))]; int t04[T(__is_standard_layout(CStruct))]; int t05[T(__is_standard_layout(CppStructStandard))]; int t06[T(__is_standard_layout(CppStructStandardAr))]; int t07[T(__is_standard_layout(Vector))]; int t08[T(__is_standard_layout(VectorExt))]; typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4]; int t10[F(__is_standard_layout(CppStructNonStandardByVirt))]; int t11[F(__is_standard_layout(CppStructNonStandardByMemb))]; int t12[F(__is_standard_layout(CppStructNonStandardByProt))]; int t13[F(__is_standard_layout(CppStructNonStandardByVirtBase))]; int t14[F(__is_standard_layout(CppStructNonStandardByBase))]; int t15[F(__is_standard_layout(CppStructNonStandardByBaseAr))]; int t16[F(__is_standard_layout(CppStructNonStandardBySameBase))]; int t17[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase))]; } void is_signed() { //int t01[T(__is_signed(char))]; int t02[T(__is_signed(int))]; int t03[T(__is_signed(long))]; int t04[T(__is_signed(short))]; int t05[T(__is_signed(signed char))]; int t06[T(__is_signed(wchar_t))]; int t10[F(__is_signed(bool))]; int t11[F(__is_signed(cvoid))]; int t12[F(__is_signed(float))]; int t13[F(__is_signed(double))]; int t14[F(__is_signed(long double))]; int t15[F(__is_signed(unsigned char))]; int t16[F(__is_signed(unsigned int))]; int t17[F(__is_signed(unsigned long long))]; int t18[F(__is_signed(unsigned long))]; int t19[F(__is_signed(unsigned short))]; int t20[F(__is_signed(void))]; int t21[F(__is_signed(ClassType))]; int t22[F(__is_signed(Derives))]; int t23[F(__is_signed(Enum))]; int t24[F(__is_signed(IntArNB))]; int t25[F(__is_signed(Union))]; int t26[F(__is_signed(UnionAr))]; } void is_unsigned() { int t01[T(__is_unsigned(bool))]; int t02[T(__is_unsigned(unsigned char))]; int t03[T(__is_unsigned(unsigned short))]; int t04[T(__is_unsigned(unsigned int))]; int t05[T(__is_unsigned(unsigned long))]; int t06[T(__is_unsigned(unsigned long long))]; int t07[T(__is_unsigned(Enum))]; int t10[F(__is_unsigned(void))]; int t11[F(__is_unsigned(cvoid))]; int t12[F(__is_unsigned(float))]; int t13[F(__is_unsigned(double))]; int t14[F(__is_unsigned(long double))]; int t16[F(__is_unsigned(char))]; int t17[F(__is_unsigned(signed char))]; int t18[F(__is_unsigned(wchar_t))]; int t19[F(__is_unsigned(short))]; int t20[F(__is_unsigned(int))]; int t21[F(__is_unsigned(long))]; int t22[F(__is_unsigned(Union))]; int t23[F(__is_unsigned(UnionAr))]; int t24[F(__is_unsigned(Derives))]; int t25[F(__is_unsigned(ClassType))]; int t26[F(__is_unsigned(IntArNB))]; } typedef Int& IntRef; typedef const IntAr ConstIntAr; typedef ConstIntAr ConstIntArAr[4]; struct HasCopy { HasCopy(HasCopy& cp); }; struct HasMove { HasMove(HasMove&& cp); }; struct HasTemplateCons { HasVirt Annoying; template <typename T> HasTemplateCons(const T&); }; void has_trivial_default_constructor() { { int arr[T(__has_trivial_constructor(Int))]; } { int arr[T(__has_trivial_constructor(IntAr))]; } { int arr[T(__has_trivial_constructor(Union))]; } { int arr[T(__has_trivial_constructor(UnionAr))]; } { int arr[T(__has_trivial_constructor(POD))]; } { int arr[T(__has_trivial_constructor(Derives))]; } { int arr[T(__has_trivial_constructor(DerivesAr))]; } { int arr[T(__has_trivial_constructor(ConstIntAr))]; } { int arr[T(__has_trivial_constructor(ConstIntArAr))]; } { int arr[T(__has_trivial_constructor(HasDest))]; } { int arr[T(__has_trivial_constructor(HasPriv))]; } { int arr[T(__has_trivial_constructor(HasCopyAssign))]; } { int arr[T(__has_trivial_constructor(HasMoveAssign))]; } { int arr[T(__has_trivial_constructor(const Int))]; } { int arr[T(__has_trivial_constructor(AllDefaulted))]; } { int arr[T(__has_trivial_constructor(AllDeleted))]; } { int arr[F(__has_trivial_constructor(HasCons))]; } { int arr[F(__has_trivial_constructor(HasRef))]; } { int arr[F(__has_trivial_constructor(HasCopy))]; } { int arr[F(__has_trivial_constructor(IntRef))]; } { int arr[F(__has_trivial_constructor(VirtAr))]; } { int arr[F(__has_trivial_constructor(void))]; } { int arr[F(__has_trivial_constructor(cvoid))]; } { int arr[F(__has_trivial_constructor(HasTemplateCons))]; } { int arr[F(__has_trivial_constructor(AllPrivate))]; } { int arr[F(__has_trivial_constructor(ExtDefaulted))]; } } void has_trivial_move_constructor() { // n3376 12.8 [class.copy]/12 // A copy/move constructor for class X is trivial if it is not // user-provided, its declared parameter type is the same as // if it had been implicitly declared, and if // - class X has no virtual functions (10.3) and no virtual // base classes (10.1), and // - the constructor selected to copy/move each direct base // class subobject is trivial, and // - for each non-static data member of X that is of class // type (or array thereof), the constructor selected // to copy/move that member is trivial; // otherwise the copy/move constructor is non-trivial. { int arr[T(__has_trivial_move_constructor(POD))]; } { int arr[T(__has_trivial_move_constructor(Union))]; } { int arr[T(__has_trivial_move_constructor(HasCons))]; } { int arr[T(__has_trivial_move_constructor(HasStaticMemberMoveCtor))]; } { int arr[T(__has_trivial_move_constructor(AllDeleted))]; } { int arr[F(__has_trivial_move_constructor(HasVirt))]; } { int arr[F(__has_trivial_move_constructor(DerivesVirt))]; } { int arr[F(__has_trivial_move_constructor(HasMoveCtor))]; } { int arr[F(__has_trivial_move_constructor(DerivesHasMoveCtor))]; } { int arr[F(__has_trivial_move_constructor(HasMemberMoveCtor))]; } } void has_trivial_copy_constructor() { { int arr[T(__has_trivial_copy(Int))]; } { int arr[T(__has_trivial_copy(IntAr))]; } { int arr[T(__has_trivial_copy(Union))]; } { int arr[T(__has_trivial_copy(UnionAr))]; } { int arr[T(__has_trivial_copy(POD))]; } { int arr[T(__has_trivial_copy(Derives))]; } { int arr[T(__has_trivial_copy(ConstIntAr))]; } { int arr[T(__has_trivial_copy(ConstIntArAr))]; } { int arr[T(__has_trivial_copy(HasDest))]; } { int arr[T(__has_trivial_copy(HasPriv))]; } { int arr[T(__has_trivial_copy(HasCons))]; } { int arr[T(__has_trivial_copy(HasRef))]; } { int arr[T(__has_trivial_copy(HasMove))]; } { int arr[T(__has_trivial_copy(IntRef))]; } { int arr[T(__has_trivial_copy(HasCopyAssign))]; } { int arr[T(__has_trivial_copy(HasMoveAssign))]; } { int arr[T(__has_trivial_copy(const Int))]; } { int arr[T(__has_trivial_copy(AllDefaulted))]; } { int arr[T(__has_trivial_copy(AllDeleted))]; } { int arr[T(__has_trivial_copy(DerivesAr))]; } { int arr[T(__has_trivial_copy(DerivesHasRef))]; } { int arr[F(__has_trivial_copy(HasCopy))]; } { int arr[F(__has_trivial_copy(HasTemplateCons))]; } { int arr[F(__has_trivial_copy(VirtAr))]; } { int arr[F(__has_trivial_copy(void))]; } { int arr[F(__has_trivial_copy(cvoid))]; } { int arr[F(__has_trivial_copy(AllPrivate))]; } { int arr[F(__has_trivial_copy(ExtDefaulted))]; } } void has_trivial_copy_assignment() { { int arr[T(__has_trivial_assign(Int))]; } { int arr[T(__has_trivial_assign(IntAr))]; } { int arr[T(__has_trivial_assign(Union))]; } { int arr[T(__has_trivial_assign(UnionAr))]; } { int arr[T(__has_trivial_assign(POD))]; } { int arr[T(__has_trivial_assign(Derives))]; } { int arr[T(__has_trivial_assign(HasDest))]; } { int arr[T(__has_trivial_assign(HasPriv))]; } { int arr[T(__has_trivial_assign(HasCons))]; } { int arr[T(__has_trivial_assign(HasRef))]; } { int arr[T(__has_trivial_assign(HasCopy))]; } { int arr[T(__has_trivial_assign(HasMove))]; } { int arr[T(__has_trivial_assign(HasMoveAssign))]; } { int arr[T(__has_trivial_assign(AllDefaulted))]; } { int arr[T(__has_trivial_assign(AllDeleted))]; } { int arr[T(__has_trivial_assign(DerivesAr))]; } { int arr[T(__has_trivial_assign(DerivesHasRef))]; } { int arr[F(__has_trivial_assign(IntRef))]; } { int arr[F(__has_trivial_assign(HasCopyAssign))]; } { int arr[F(__has_trivial_assign(const Int))]; } { int arr[F(__has_trivial_assign(ConstIntAr))]; } { int arr[F(__has_trivial_assign(ConstIntArAr))]; } { int arr[F(__has_trivial_assign(VirtAr))]; } { int arr[F(__has_trivial_assign(void))]; } { int arr[F(__has_trivial_assign(cvoid))]; } { int arr[F(__has_trivial_assign(AllPrivate))]; } { int arr[F(__has_trivial_assign(ExtDefaulted))]; } } void has_trivial_destructor() { { int arr[T(__has_trivial_destructor(Int))]; } { int arr[T(__has_trivial_destructor(IntAr))]; } { int arr[T(__has_trivial_destructor(Union))]; } { int arr[T(__has_trivial_destructor(UnionAr))]; } { int arr[T(__has_trivial_destructor(POD))]; } { int arr[T(__has_trivial_destructor(Derives))]; } { int arr[T(__has_trivial_destructor(ConstIntAr))]; } { int arr[T(__has_trivial_destructor(ConstIntArAr))]; } { int arr[T(__has_trivial_destructor(HasPriv))]; } { int arr[T(__has_trivial_destructor(HasCons))]; } { int arr[T(__has_trivial_destructor(HasRef))]; } { int arr[T(__has_trivial_destructor(HasCopy))]; } { int arr[T(__has_trivial_destructor(HasMove))]; } { int arr[T(__has_trivial_destructor(IntRef))]; } { int arr[T(__has_trivial_destructor(HasCopyAssign))]; } { int arr[T(__has_trivial_destructor(HasMoveAssign))]; } { int arr[T(__has_trivial_destructor(const Int))]; } { int arr[T(__has_trivial_destructor(DerivesAr))]; } { int arr[T(__has_trivial_destructor(VirtAr))]; } { int arr[T(__has_trivial_destructor(AllDefaulted))]; } { int arr[T(__has_trivial_destructor(AllDeleted))]; } { int arr[T(__has_trivial_destructor(DerivesHasRef))]; } { int arr[F(__has_trivial_destructor(HasDest))]; } { int arr[F(__has_trivial_destructor(void))]; } { int arr[F(__has_trivial_destructor(cvoid))]; } { int arr[F(__has_trivial_destructor(AllPrivate))]; } { int arr[F(__has_trivial_destructor(ExtDefaulted))]; } } struct A { ~A() {} }; template<typename> struct B : A { }; void f() { { int arr[F(__has_trivial_destructor(A))]; } { int arr[F(__has_trivial_destructor(B<int>))]; } } class PR11110 { template <int> int operator=( int ); int operator=(PR11110); }; class UsingAssign; class UsingAssignBase { protected: UsingAssign &operator=(const UsingAssign&) throw(); }; class UsingAssign : public UsingAssignBase { public: using UsingAssignBase::operator=; }; void has_nothrow_assign() { { int arr[T(__has_nothrow_assign(Int))]; } { int arr[T(__has_nothrow_assign(IntAr))]; } { int arr[T(__has_nothrow_assign(Union))]; } { int arr[T(__has_nothrow_assign(UnionAr))]; } { int arr[T(__has_nothrow_assign(POD))]; } { int arr[T(__has_nothrow_assign(Derives))]; } { int arr[T(__has_nothrow_assign(HasDest))]; } { int arr[T(__has_nothrow_assign(HasPriv))]; } { int arr[T(__has_nothrow_assign(HasCons))]; } { int arr[T(__has_nothrow_assign(HasRef))]; } { int arr[T(__has_nothrow_assign(HasCopy))]; } { int arr[T(__has_nothrow_assign(HasMove))]; } { int arr[T(__has_nothrow_assign(HasMoveAssign))]; } { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; } { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; } { int arr[T(__has_nothrow_assign(HasVirtDest))]; } { int arr[T(__has_nothrow_assign(AllPrivate))]; } { int arr[T(__has_nothrow_assign(UsingAssign))]; } { int arr[T(__has_nothrow_assign(DerivesAr))]; } { int arr[F(__has_nothrow_assign(IntRef))]; } { int arr[F(__has_nothrow_assign(HasCopyAssign))]; } { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; } { int arr[F(__has_nothrow_assign(const Int))]; } { int arr[F(__has_nothrow_assign(ConstIntAr))]; } { int arr[F(__has_nothrow_assign(ConstIntArAr))]; } { int arr[F(__has_nothrow_assign(VirtAr))]; } { int arr[F(__has_nothrow_assign(void))]; } { int arr[F(__has_nothrow_assign(cvoid))]; } { int arr[F(__has_nothrow_assign(PR11110))]; } } void has_nothrow_move_assign() { { int arr[T(__has_nothrow_move_assign(Int))]; } { int arr[T(__has_nothrow_move_assign(Enum))]; } { int arr[T(__has_nothrow_move_assign(Int*))]; } { int arr[T(__has_nothrow_move_assign(Enum POD::*))]; } { int arr[T(__has_nothrow_move_assign(POD))]; } { int arr[T(__has_nothrow_move_assign(HasPriv))]; } { int arr[T(__has_nothrow_move_assign(HasNoThrowMoveAssign))]; } { int arr[T(__has_nothrow_move_assign(HasNoExceptNoThrowMoveAssign))]; } { int arr[T(__has_nothrow_move_assign(HasMemberNoThrowMoveAssign))]; } { int arr[T(__has_nothrow_move_assign(HasMemberNoExceptNoThrowMoveAssign))]; } { int arr[T(__has_nothrow_move_assign(AllDeleted))]; } { int arr[F(__has_nothrow_move_assign(HasThrowMoveAssign))]; } { int arr[F(__has_nothrow_move_assign(HasNoExceptFalseMoveAssign))]; } { int arr[F(__has_nothrow_move_assign(HasMemberThrowMoveAssign))]; } { int arr[F(__has_nothrow_move_assign(HasMemberNoExceptFalseMoveAssign))]; } { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; } { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; } { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToDtor))]; } { int arr[T(__is_nothrow_assignable(HasNoThrowMoveAssign, HasNoThrowMoveAssign))]; } { int arr[F(__is_nothrow_assignable(HasThrowMoveAssign, HasThrowMoveAssign))]; } } void has_trivial_move_assign() { // n3376 12.8 [class.copy]/25 // A copy/move assignment operator for class X is trivial if it // is not user-provided, its declared parameter type is the same // as if it had been implicitly declared, and if: // - class X has no virtual functions (10.3) and no virtual base // classes (10.1), and // - the assignment operator selected to copy/move each direct // base class subobject is trivial, and // - for each non-static data member of X that is of class type // (or array thereof), the assignment operator // selected to copy/move that member is trivial; { int arr[T(__has_trivial_move_assign(Int))]; } { int arr[T(__has_trivial_move_assign(HasStaticMemberMoveAssign))]; } { int arr[T(__has_trivial_move_assign(AllDeleted))]; } { int arr[F(__has_trivial_move_assign(HasVirt))]; } { int arr[F(__has_trivial_move_assign(DerivesVirt))]; } { int arr[F(__has_trivial_move_assign(HasMoveAssign))]; } { int arr[F(__has_trivial_move_assign(DerivesHasMoveAssign))]; } { int arr[F(__has_trivial_move_assign(HasMemberMoveAssign))]; } { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; } { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; } } void has_nothrow_copy() { { int arr[T(__has_nothrow_copy(Int))]; } { int arr[T(__has_nothrow_copy(IntAr))]; } { int arr[T(__has_nothrow_copy(Union))]; } { int arr[T(__has_nothrow_copy(UnionAr))]; } { int arr[T(__has_nothrow_copy(POD))]; } { int arr[T(__has_nothrow_copy(const Int))]; } { int arr[T(__has_nothrow_copy(ConstIntAr))]; } { int arr[T(__has_nothrow_copy(ConstIntArAr))]; } { int arr[T(__has_nothrow_copy(Derives))]; } { int arr[T(__has_nothrow_copy(IntRef))]; } { int arr[T(__has_nothrow_copy(HasDest))]; } { int arr[T(__has_nothrow_copy(HasPriv))]; } { int arr[T(__has_nothrow_copy(HasCons))]; } { int arr[T(__has_nothrow_copy(HasRef))]; } { int arr[T(__has_nothrow_copy(HasMove))]; } { int arr[T(__has_nothrow_copy(HasCopyAssign))]; } { int arr[T(__has_nothrow_copy(HasMoveAssign))]; } { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; } { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; } { int arr[T(__has_nothrow_copy(HasVirtDest))]; } { int arr[T(__has_nothrow_copy(HasTemplateCons))]; } { int arr[T(__has_nothrow_copy(AllPrivate))]; } { int arr[T(__has_nothrow_copy(DerivesAr))]; } { int arr[F(__has_nothrow_copy(HasCopy))]; } { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; } { int arr[F(__has_nothrow_copy(VirtAr))]; } { int arr[F(__has_nothrow_copy(void))]; } { int arr[F(__has_nothrow_copy(cvoid))]; } } void has_nothrow_constructor() { { int arr[T(__has_nothrow_constructor(Int))]; } { int arr[T(__has_nothrow_constructor(IntAr))]; } { int arr[T(__has_nothrow_constructor(Union))]; } { int arr[T(__has_nothrow_constructor(UnionAr))]; } { int arr[T(__has_nothrow_constructor(POD))]; } { int arr[T(__has_nothrow_constructor(Derives))]; } { int arr[T(__has_nothrow_constructor(DerivesAr))]; } { int arr[T(__has_nothrow_constructor(ConstIntAr))]; } { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; } { int arr[T(__has_nothrow_constructor(HasDest))]; } { int arr[T(__has_nothrow_constructor(HasPriv))]; } { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; } { int arr[T(__has_nothrow_constructor(const Int))]; } { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; } { int arr[T(__has_nothrow_constructor(HasVirtDest))]; } // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented { int arr[T(__has_nothrow_constructor(AllPrivate))]; } { int arr[F(__has_nothrow_constructor(HasCons))]; } { int arr[F(__has_nothrow_constructor(HasRef))]; } { int arr[F(__has_nothrow_constructor(HasCopy))]; } { int arr[F(__has_nothrow_constructor(HasMove))]; } { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; } { int arr[F(__has_nothrow_constructor(IntRef))]; } { int arr[F(__has_nothrow_constructor(void))]; } { int arr[F(__has_nothrow_constructor(cvoid))]; } { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; } { int arr[F(__has_nothrow_constructor(HasMultipleDefaultConstructor1))]; } { int arr[F(__has_nothrow_constructor(HasMultipleDefaultConstructor2))]; } } void has_virtual_destructor() { { int arr[F(__has_virtual_destructor(Int))]; } { int arr[F(__has_virtual_destructor(IntAr))]; } { int arr[F(__has_virtual_destructor(Union))]; } { int arr[F(__has_virtual_destructor(UnionAr))]; } { int arr[F(__has_virtual_destructor(POD))]; } { int arr[F(__has_virtual_destructor(Derives))]; } { int arr[F(__has_virtual_destructor(DerivesAr))]; } { int arr[F(__has_virtual_destructor(const Int))]; } { int arr[F(__has_virtual_destructor(ConstIntAr))]; } { int arr[F(__has_virtual_destructor(ConstIntArAr))]; } { int arr[F(__has_virtual_destructor(HasDest))]; } { int arr[F(__has_virtual_destructor(HasPriv))]; } { int arr[F(__has_virtual_destructor(HasCons))]; } { int arr[F(__has_virtual_destructor(HasRef))]; } { int arr[F(__has_virtual_destructor(HasCopy))]; } { int arr[F(__has_virtual_destructor(HasMove))]; } { int arr[F(__has_virtual_destructor(HasCopyAssign))]; } { int arr[F(__has_virtual_destructor(HasMoveAssign))]; } { int arr[F(__has_virtual_destructor(IntRef))]; } { int arr[F(__has_virtual_destructor(VirtAr))]; } { int arr[T(__has_virtual_destructor(HasVirtDest))]; } { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; } { int arr[F(__has_virtual_destructor(VirtDestAr))]; } { int arr[F(__has_virtual_destructor(void))]; } { int arr[F(__has_virtual_destructor(cvoid))]; } { int arr[F(__has_virtual_destructor(AllPrivate))]; } } class Base {}; class Derived : Base {}; class Derived2a : Derived {}; class Derived2b : Derived {}; class Derived3 : virtual Derived2a, virtual Derived2b {}; template<typename T> struct BaseA { T a; }; template<typename T> struct DerivedB : BaseA<T> { }; template<typename T> struct CrazyDerived : T { }; class class_forward; // expected-note 2 {{forward declaration of 'class_forward'}} template <typename Base, typename Derived> void isBaseOfT() { int t[T(__is_base_of(Base, Derived))]; }; template <typename Base, typename Derived> void isBaseOfF() { int t[F(__is_base_of(Base, Derived))]; }; template <class T> class DerivedTemp : Base {}; template <class T> class NonderivedTemp {}; template <class T> class UndefinedTemp; // expected-note {{declared here}} void is_base_of() { { int arr[T(__is_base_of(Base, Derived))]; } { int arr[T(__is_base_of(const Base, Derived))]; } { int arr[F(__is_base_of(Derived, Base))]; } { int arr[F(__is_base_of(Derived, int))]; } { int arr[T(__is_base_of(Base, Base))]; } { int arr[T(__is_base_of(Base, Derived3))]; } { int arr[T(__is_base_of(Derived, Derived3))]; } { int arr[T(__is_base_of(Derived2b, Derived3))]; } { int arr[T(__is_base_of(Derived2a, Derived3))]; } { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; } { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; } { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; } { int arr[F(__is_base_of(Union, Union))]; } { int arr[T(__is_base_of(Empty, Empty))]; } { int arr[T(__is_base_of(class_forward, class_forward))]; } { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}} { int arr[F(__is_base_of(Base&, Derived&))]; } int t18[F(__is_base_of(Base[10], Derived[10]))]; { int arr[F(__is_base_of(int, int))]; } { int arr[F(__is_base_of(long, int))]; } { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; } { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; } { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}} isBaseOfT<Base, Derived>(); isBaseOfF<Derived, Base>(); isBaseOfT<Base, CrazyDerived<Base> >(); isBaseOfF<CrazyDerived<Base>, Base>(); isBaseOfT<BaseA<int>, DerivedB<int> >(); isBaseOfF<DerivedB<int>, BaseA<int> >(); } template<class T, class U> class TemplateClass {}; template<class T> using TemplateAlias = TemplateClass<T, int>; typedef class Base BaseTypedef; void is_same() { int t01[T(__is_same(Base, Base))]; int t02[T(__is_same(Base, BaseTypedef))]; int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))]; int t10[F(__is_same(Base, const Base))]; int t11[F(__is_same(Base, Base&))]; int t12[F(__is_same(Base, Derived))]; } struct IntWrapper { int value; IntWrapper(int _value) : value(_value) {} operator int() const { return value; } }; struct FloatWrapper { float value; FloatWrapper(float _value) : value(_value) {} FloatWrapper(const IntWrapper& obj) : value(static_cast<float>(obj.value)) {} operator float() const { return value; } operator IntWrapper() const { return IntWrapper(static_cast<int>(value)); } }; void is_convertible() { int t01[T(__is_convertible(IntWrapper, IntWrapper))]; int t02[T(__is_convertible(IntWrapper, const IntWrapper))]; int t03[T(__is_convertible(IntWrapper, int))]; int t04[T(__is_convertible(int, IntWrapper))]; int t05[T(__is_convertible(IntWrapper, FloatWrapper))]; int t06[T(__is_convertible(FloatWrapper, IntWrapper))]; int t07[T(__is_convertible(FloatWrapper, float))]; int t08[T(__is_convertible(float, FloatWrapper))]; } struct FromInt { FromInt(int); }; struct ToInt { operator int(); }; typedef void Function(); void is_convertible_to(); class PrivateCopy { PrivateCopy(const PrivateCopy&); friend void is_convertible_to(); }; template<typename T> struct X0 { template<typename U> X0(const X0<U>&); }; struct Abstract { virtual void f() = 0; }; void is_convertible_to() { { int arr[T(__is_convertible_to(Int, Int))]; } { int arr[F(__is_convertible_to(Int, IntAr))]; } { int arr[F(__is_convertible_to(IntAr, IntAr))]; } { int arr[T(__is_convertible_to(void, void))]; } { int arr[T(__is_convertible_to(cvoid, void))]; } { int arr[T(__is_convertible_to(void, cvoid))]; } { int arr[T(__is_convertible_to(cvoid, cvoid))]; } { int arr[T(__is_convertible_to(int, FromInt))]; } { int arr[T(__is_convertible_to(long, FromInt))]; } { int arr[T(__is_convertible_to(double, FromInt))]; } { int arr[T(__is_convertible_to(const int, FromInt))]; } { int arr[T(__is_convertible_to(const int&, FromInt))]; } { int arr[T(__is_convertible_to(ToInt, int))]; } { int arr[T(__is_convertible_to(ToInt, const int&))]; } { int arr[T(__is_convertible_to(ToInt, long))]; } { int arr[F(__is_convertible_to(ToInt, int&))]; } { int arr[F(__is_convertible_to(ToInt, FromInt))]; } { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; } { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; } { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; } { int arr[F(__is_convertible_to(Function, Function))]; } { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; } { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; } { int arr[F(__is_convertible_to(Abstract, Abstract))]; } } namespace is_convertible_to_instantiate { // Make sure we don't try to instantiate the constructor. template<int x> class A { A(int) { int a[x]; } }; int x = __is_convertible_to(int, A<-1>); } void is_trivial() { { int arr[T(__is_trivial(int))]; } { int arr[T(__is_trivial(Enum))]; } { int arr[T(__is_trivial(POD))]; } { int arr[T(__is_trivial(Int))]; } { int arr[T(__is_trivial(IntAr))]; } { int arr[T(__is_trivial(IntArNB))]; } { int arr[T(__is_trivial(Statics))]; } { int arr[T(__is_trivial(Empty))]; } { int arr[T(__is_trivial(EmptyUnion))]; } { int arr[T(__is_trivial(Union))]; } { int arr[T(__is_trivial(Derives))]; } { int arr[T(__is_trivial(DerivesAr))]; } { int arr[T(__is_trivial(DerivesArNB))]; } { int arr[T(__is_trivial(DerivesEmpty))]; } { int arr[T(__is_trivial(HasFunc))]; } { int arr[T(__is_trivial(HasOp))]; } { int arr[T(__is_trivial(HasConv))]; } { int arr[T(__is_trivial(HasAssign))]; } { int arr[T(__is_trivial(HasAnonymousUnion))]; } { int arr[T(__is_trivial(HasPriv))]; } { int arr[T(__is_trivial(HasProt))]; } { int arr[T(__is_trivial(DerivesHasPriv))]; } { int arr[T(__is_trivial(DerivesHasProt))]; } { int arr[T(__is_trivial(Vector))]; } { int arr[T(__is_trivial(VectorExt))]; } { int arr[F(__is_trivial(HasCons))]; } { int arr[F(__is_trivial(HasCopyAssign))]; } { int arr[F(__is_trivial(HasMoveAssign))]; } { int arr[F(__is_trivial(HasDest))]; } { int arr[F(__is_trivial(HasRef))]; } { int arr[F(__is_trivial(HasNonPOD))]; } { int arr[F(__is_trivial(HasVirt))]; } { int arr[F(__is_trivial(DerivesHasCons))]; } { int arr[F(__is_trivial(DerivesHasCopyAssign))]; } { int arr[F(__is_trivial(DerivesHasMoveAssign))]; } { int arr[F(__is_trivial(DerivesHasDest))]; } { int arr[F(__is_trivial(DerivesHasRef))]; } { int arr[F(__is_trivial(DerivesHasVirt))]; } { int arr[F(__is_trivial(void))]; } { int arr[F(__is_trivial(cvoid))]; } } template<typename T> struct TriviallyConstructibleTemplate {}; void trivial_checks() { { int arr[T(__is_trivially_copyable(int))]; } { int arr[T(__is_trivially_copyable(Enum))]; } { int arr[T(__is_trivially_copyable(POD))]; } { int arr[T(__is_trivially_copyable(Int))]; } { int arr[T(__is_trivially_copyable(IntAr))]; } { int arr[T(__is_trivially_copyable(IntArNB))]; } { int arr[T(__is_trivially_copyable(Statics))]; } { int arr[T(__is_trivially_copyable(Empty))]; } { int arr[T(__is_trivially_copyable(EmptyUnion))]; } { int arr[T(__is_trivially_copyable(Union))]; } { int arr[T(__is_trivially_copyable(Derives))]; } { int arr[T(__is_trivially_copyable(DerivesAr))]; } { int arr[T(__is_trivially_copyable(DerivesArNB))]; } { int arr[T(__is_trivially_copyable(DerivesEmpty))]; } { int arr[T(__is_trivially_copyable(HasFunc))]; } { int arr[T(__is_trivially_copyable(HasOp))]; } { int arr[T(__is_trivially_copyable(HasConv))]; } { int arr[T(__is_trivially_copyable(HasAssign))]; } { int arr[T(__is_trivially_copyable(HasAnonymousUnion))]; } { int arr[T(__is_trivially_copyable(HasPriv))]; } { int arr[T(__is_trivially_copyable(HasProt))]; } { int arr[T(__is_trivially_copyable(DerivesHasPriv))]; } { int arr[T(__is_trivially_copyable(DerivesHasProt))]; } { int arr[T(__is_trivially_copyable(Vector))]; } { int arr[T(__is_trivially_copyable(VectorExt))]; } { int arr[T(__is_trivially_copyable(HasCons))]; } { int arr[T(__is_trivially_copyable(HasRef))]; } { int arr[T(__is_trivially_copyable(HasNonPOD))]; } { int arr[T(__is_trivially_copyable(DerivesHasCons))]; } { int arr[T(__is_trivially_copyable(DerivesHasRef))]; } { int arr[T(__is_trivially_copyable(NonTrivialDefault))]; } { int arr[T(__is_trivially_copyable(NonTrivialDefault[]))]; } { int arr[T(__is_trivially_copyable(NonTrivialDefault[3]))]; } { int arr[F(__is_trivially_copyable(HasCopyAssign))]; } { int arr[F(__is_trivially_copyable(HasMoveAssign))]; } { int arr[F(__is_trivially_copyable(HasDest))]; } { int arr[F(__is_trivially_copyable(HasVirt))]; } { int arr[F(__is_trivially_copyable(DerivesHasCopyAssign))]; } { int arr[F(__is_trivially_copyable(DerivesHasMoveAssign))]; } { int arr[F(__is_trivially_copyable(DerivesHasDest))]; } { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; } { int arr[F(__is_trivially_copyable(void))]; } { int arr[F(__is_trivially_copyable(cvoid))]; } { int arr[T((__is_trivially_constructible(int)))]; } { int arr[T((__is_trivially_constructible(int, int)))]; } { int arr[T((__is_trivially_constructible(int, float)))]; } { int arr[T((__is_trivially_constructible(int, int&)))]; } { int arr[T((__is_trivially_constructible(int, const int&)))]; } { int arr[T((__is_trivially_constructible(int, int)))]; } { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; } { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; } { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; } { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; } { int arr[T((__is_trivially_constructible(NonTrivialDefault, const NonTrivialDefault&)))]; } { int arr[T((__is_trivially_constructible(NonTrivialDefault, NonTrivialDefault&&)))]; } { int arr[T((__is_trivially_constructible(AllDefaulted)))]; } { int arr[T((__is_trivially_constructible(AllDefaulted, const AllDefaulted &)))]; } { int arr[T((__is_trivially_constructible(AllDefaulted, AllDefaulted &&)))]; } { int arr[F((__is_trivially_constructible(int, int*)))]; } { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; } { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; } { int arr[F((__is_trivially_constructible(AllDeleted)))]; } { int arr[F((__is_trivially_constructible(AllDeleted, const AllDeleted &)))]; } { int arr[F((__is_trivially_constructible(AllDeleted, AllDeleted &&)))]; } { int arr[F((__is_trivially_constructible(ExtDefaulted)))]; } { int arr[F((__is_trivially_constructible(ExtDefaulted, const ExtDefaulted &)))]; } { int arr[F((__is_trivially_constructible(ExtDefaulted, ExtDefaulted &&)))]; } { int arr[T((__is_trivially_constructible(TriviallyConstructibleTemplate<int>)))]; } { int arr[F((__is_trivially_constructible(class_forward)))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}} { int arr[F((__is_trivially_constructible(class_forward[])))]; } { int arr[F((__is_trivially_constructible(void)))]; } { int arr[T((__is_trivially_assignable(int&, int)))]; } { int arr[T((__is_trivially_assignable(int&, int&)))]; } { int arr[T((__is_trivially_assignable(int&, int&&)))]; } { int arr[T((__is_trivially_assignable(int&, const int&)))]; } { int arr[T((__is_trivially_assignable(POD&, POD)))]; } { int arr[T((__is_trivially_assignable(POD&, POD&)))]; } { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; } { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; } { int arr[T((__is_trivially_assignable(int*&, int*)))]; } { int arr[T((__is_trivially_assignable(AllDefaulted, const AllDefaulted &)))]; } { int arr[T((__is_trivially_assignable(AllDefaulted, AllDefaulted &&)))]; } { int arr[F((__is_trivially_assignable(int*&, float*)))]; } { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign)))]; } { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&)))]; } { int arr[F((__is_trivially_assignable(HasCopyAssign&, const HasCopyAssign&)))]; } { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&&)))]; } { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&, TrivialMoveButNotCopy&)))]; } { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&, const TrivialMoveButNotCopy&)))]; } { int arr[F((__is_trivially_assignable(AllDeleted, const AllDeleted &)))]; } { int arr[F((__is_trivially_assignable(AllDeleted, AllDeleted &&)))]; } { int arr[F((__is_trivially_assignable(ExtDefaulted, const ExtDefaulted &)))]; } { int arr[F((__is_trivially_assignable(ExtDefaulted, ExtDefaulted &&)))]; } { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&, HasDefaultTrivialCopyAssign&)))]; } { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&, const HasDefaultTrivialCopyAssign&)))]; } { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&, TrivialMoveButNotCopy)))]; } { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&, TrivialMoveButNotCopy&&)))]; } } void constructible_checks() { { int arr[T(__is_constructible(HasNoThrowConstructorWithArgs))]; } { int arr[F(__is_nothrow_constructible(HasNoThrowConstructorWithArgs))]; } // MSVC doesn't look into default args and gets this wrong. { int arr[T(__is_constructible(HasNoThrowConstructorWithArgs, HasCons))]; } { int arr[T(__is_nothrow_constructible(HasNoThrowConstructorWithArgs, HasCons))]; } { int arr[T(__is_constructible(NonTrivialDefault))]; } { int arr[F(__is_nothrow_constructible(NonTrivialDefault))]; } { int arr[T(__is_constructible(int))]; } { int arr[T(__is_nothrow_constructible(int))]; } { int arr[F(__is_constructible(NonPOD))]; } { int arr[F(__is_nothrow_constructible(NonPOD))]; } { int arr[T(__is_constructible(NonPOD, int))]; } { int arr[F(__is_nothrow_constructible(NonPOD, int))]; } // PR19178 { int arr[F(__is_constructible(Abstract))]; } { int arr[F(__is_nothrow_constructible(Abstract))]; } // PR20228 { int arr[T(__is_constructible(VariadicCtor, int, int, int, int, int, int, int, int, int))]; } } // Instantiation of __is_trivially_constructible template<typename T, typename ...Args> struct is_trivially_constructible { static const bool value = __is_trivially_constructible(T, Args...); }; void is_trivially_constructible_test() { { int arr[T((is_trivially_constructible<int>::value))]; } { int arr[T((is_trivially_constructible<int, int>::value))]; } { int arr[T((is_trivially_constructible<int, float>::value))]; } { int arr[T((is_trivially_constructible<int, int&>::value))]; } { int arr[T((is_trivially_constructible<int, const int&>::value))]; } { int arr[T((is_trivially_constructible<int, int>::value))]; } { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; } { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; } { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; } { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; } { int arr[T((is_trivially_constructible<NonTrivialDefault, const NonTrivialDefault&>::value))]; } { int arr[T((is_trivially_constructible<NonTrivialDefault, NonTrivialDefault&&>::value))]; } { int arr[F((is_trivially_constructible<int, int*>::value))]; } { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; } { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; } { int arr[F((is_trivially_constructible<Abstract>::value))]; } // PR19178 } void array_rank() { int t01[T(__array_rank(IntAr) == 1)]; int t02[T(__array_rank(ConstIntArAr) == 2)]; } void array_extent() { int t01[T(__array_extent(IntAr, 0) == 10)]; int t02[T(__array_extent(ConstIntArAr, 0) == 4)]; int t03[T(__array_extent(ConstIntArAr, 1) == 10)]; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR5086-ambig-resolution-enum.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // expected-no-diagnostics class C { public: enum E { e1=0 }; const char * fun1(int , enum E) const; int fun1(unsigned, const char *) const; }; void foo(const C& rc) { enum {BUFLEN = 128 }; const char *p = rc.fun1(BUFLEN - 2, C::e1); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/discrim-union.cpp
// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -fcxx-exceptions template<typename T> struct remove_reference { typedef T type; }; template<typename T> struct remove_reference<T&> { typedef T type; }; template<typename T> struct remove_reference<T&&> { typedef T type; }; template<typename T> constexpr T &&forward(typename remove_reference<T>::type &t) noexcept { return static_cast<T&&>(t); } template<typename T> constexpr T &&forward(typename remove_reference<T>::type &&t) noexcept { return static_cast<T&&>(t); } template<typename T> constexpr typename remove_reference<T>::type &&move(T &&t) noexcept { return static_cast<typename remove_reference<T>::type&&>(t); } template<typename T> T declval() noexcept; namespace detail { template<unsigned N> struct select {}; // : integral_constant<unsigned, N> {}; template<typename T> struct type {}; template<typename...T> union either_impl; template<> union either_impl<> { void get(...); void destroy(...) { throw "logic_error"; } }; template<typename T, typename...Ts> union either_impl<T, Ts...> { private: T val; either_impl<Ts...> rest; typedef either_impl<Ts...> rest_t; public: constexpr either_impl(select<0>, T &&t) : val(move(t)) {} template<unsigned N, typename U> constexpr either_impl(select<N>, U &&u) : rest(select<N-1>(), move(u)) {} constexpr static unsigned index(type<T>) { return 0; } template<typename U> constexpr static unsigned index(type<U> t) { return decltype(rest)::index(t) + 1; } void destroy(unsigned elem) { if (elem) rest.destroy(elem - 1); else val.~T(); } constexpr const T &get(select<0>) { return val; } template<unsigned N> constexpr const decltype(static_cast<const rest_t&>(rest).get(select<N-1>{})) get(select<N>) { return rest.get(select<N-1>{}); } }; } template<typename T> struct a { T value; template<typename...U> constexpr a(U &&...u) : value{forward<U>(u)...} {} }; template<typename T> using an = a<T>; template<typename T, typename U> T throw_(const U &u) { throw u; } template<typename...T> class either { unsigned elem; detail::either_impl<T...> impl; typedef decltype(impl) impl_t; public: template<typename U> constexpr either(a<U> &&t) : elem(impl_t::index(detail::type<U>())), impl(detail::select<impl_t::index(detail::type<U>())>(), move(t.value)) {} // Destruction disabled to allow use in a constant expression. // FIXME: declare a destructor iff any element has a nontrivial destructor //~either() { impl.destroy(elem); } constexpr unsigned index() noexcept { return elem; } template<unsigned N> using const_get_result = decltype(static_cast<const impl_t&>(impl).get(detail::select<N>{})); template<unsigned N> constexpr const_get_result<N> get() { // Can't just use throw here, since that makes the conditional a prvalue, // which means we return a reference to a temporary. return (elem != N ? throw_<const_get_result<N>>("bad_either_get") : impl.get(detail::select<N>{})); } template<typename U> constexpr const U &get() { return get<impl_t::index(detail::type<U>())>(); } }; typedef either<int, char, double> icd; constexpr icd icd1 = an<int>(4); constexpr icd icd2 = a<char>('x'); constexpr icd icd3 = a<double>(6.5); static_assert(icd1.get<int>() == 4, ""); static_assert(icd2.get<char>() == 'x', ""); static_assert(icd3.get<double>() == 6.5, ""); struct non_triv { constexpr non_triv() : n(5) {} int n; }; constexpr either<const icd*, non_triv> icd4 = a<const icd*>(&icd2); constexpr either<const icd*, non_triv> icd5 = a<non_triv>(); static_assert(icd4.get<const icd*>()->get<char>() == 'x', ""); static_assert(icd5.get<non_triv>().n == 5, "");
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp
// RUN: %clang_cc1 -std=c++11 %s -verify // expected-no-diagnostics namespace PR15757 { struct S { }; template<typename X, typename Y> struct T { template<typename A> T(X x, A &&a) {} template<typename A> explicit T(A &&a) noexcept(noexcept(T(X(), static_cast<A &&>(a)))) : T(X(), static_cast<A &&>(a)) {} }; template<typename X, typename Y> struct U : T<X, Y> { using T<X, Y>::T; }; U<S, char> foo(char ch) { return U<S, char>(ch); } int main() { U<S, int> a(42); U<S, char> b('4'); return 0; } } namespace WrongIdent { struct A {}; struct B : A {}; struct C : B { using B::A; }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/2008-01-11-BadWarning.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s // expected-no-diagnostics // rdar://5683899 void** f(void **Buckets, unsigned NumBuckets) { return Buckets + NumBuckets; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s int fallthrough_compatibility_macro_from_command_line(int n) { switch (n) { case 0: n = n * 10; case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'COMMAND_LINE_FALLTHROUGH;' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} ; } return n; } #ifdef __clang__ #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") #define COMPATIBILITY_FALLTHROUGH [ [ /* test */ clang /* test */ \ :: fallthrough ] ] // testing whitespace and comments in macro definition #endif #endif #ifndef COMPATIBILITY_FALLTHROUGH #define COMPATIBILITY_FALLTHROUGH do { } while (0) #endif int fallthrough_compatibility_macro_from_source(int n) { switch (n) { case 0: n = n * 20; case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'COMPATIBILITY_FALLTHROUGH;' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} ; } return n; } // Deeper macro substitution #define M1 [[clang::fallthrough]] #ifdef __clang__ #define M2 M1 #else #define M2 #endif #define WRONG_MACRO1 clang::fallthrough #define WRONG_MACRO2 [[clang::fallthrough] #define WRONG_MACRO3 [[clang::fall through]] #define WRONG_MACRO4 [[clang::fallthrough]]] int fallthrough_compatibility_macro_in_macro(int n) { switch (n) { case 0: n = n * 20; case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'M1;' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} // there was an idea that this ^ should be M2 ; } return n; } #undef M1 #undef M2 #undef COMPATIBILITY_FALLTHROUGH #undef COMMAND_LINE_FALLTHROUGH int fallthrough_compatibility_macro_undefined(int n) { switch (n) { case 0: n = n * 20; case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} ; } #define TOO_LATE [[clang::fallthrough]] return n; } #undef TOO_LATE #define MACRO_WITH_HISTORY 11111111 #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY [[clang::fallthrough]] #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY 2222222 int fallthrough_compatibility_macro_history(int n) { switch (n) { case 0: n = n * 20; #undef MACRO_WITH_HISTORY case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} ; #define MACRO_WITH_HISTORY [[clang::fallthrough]] } return n; } #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY 11111111 #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY [[clang::fallthrough]] #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY 2222222 #undef MACRO_WITH_HISTORY int fallthrough_compatibility_macro_history2(int n) { switch (n) { case 0: n = n * 20; #define MACRO_WITH_HISTORY [[clang::fallthrough]] case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'MACRO_WITH_HISTORY;' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} ; #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY 3333333 #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY 4444444 #undef MACRO_WITH_HISTORY #define MACRO_WITH_HISTORY 5555555 } return n; } template<const int N> int fallthrough_compatibility_macro_history_template(int n) { switch (N * n) { case 0: n = n * 20; #define MACRO_WITH_HISTORY2 [[clang::fallthrough]] case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'MACRO_WITH_HISTORY2;' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} ; #undef MACRO_WITH_HISTORY2 #define MACRO_WITH_HISTORY2 3333333 } return n; } #undef MACRO_WITH_HISTORY2 #define MACRO_WITH_HISTORY2 4444444 #undef MACRO_WITH_HISTORY2 #define MACRO_WITH_HISTORY2 5555555 void f() { fallthrough_compatibility_macro_history_template<1>(0); // expected-note{{in instantiation of function template specialization 'fallthrough_compatibility_macro_history_template<1>' requested here}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-static-function-inheader.cpp
#include "warn-static-function-inheader.h" // RUN: %clang_cc1 -fsyntax-only -verify -Wall %s // rdar://11202617 static void another(void) { // expected-warning {{function 'another' is not needed and will not be emitted}} } template <typename T> void foo(void) { thing(); another(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only %s // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING template<class F, class ...Rest> struct first_impl { typedef F type; }; template<class ...Args> using first = typename first_impl<Args...>::type; namespace simple_explicit_capture { void test() { int i; auto L = [i](auto a) { return i + a; }; L(3.14); } } namespace explicit_call { int test() { auto L = [](auto a) { return a; }; L.operator()(3); L.operator()<char>(3.14); //expected-warning{{implicit conversion}} return 0; } } //end ns namespace test_conversion_to_fptr_2 { template<class T> struct X { T (*fp)(T) = [](auto a) { return a; }; }; X<int> xi; template<class T> void fooT(T t, T (*fp)(T) = [](auto a) { return a; }) { fp(t); } int test() { { auto L = [](auto a) { return a; }; int (*fp)(int) = L; fp(5); L(3); char (*fc)(char) = L; fc('b'); L('c'); double (*fd)(double) = L; fd(3.14); fd(6.26); L(4.25); } { auto L = [](auto a) ->int { return a; }; //expected-note 2{{candidate template ignored}} int (*fp)(int) = L; char (*fc)(char) = L; //expected-error{{no viable conversion}} double (*fd)(double) = L; //expected-error{{no viable conversion}} } { int x = 5; auto L = [=](auto b, char c = 'x') { int i = x; return [](auto a) ->decltype(a) { return a; }; }; int (*fp)(int) = L(8); fp(5); L(3); char (*fc)(char) = L('a'); fc('b'); L('c'); double (*fd)(double) = L(3.14); fd(3.14); fd(6.26); } { auto L = [=](auto b) { return [](auto a) ->decltype(b)* { return (decltype(b)*)0; }; }; int* (*fp)(int) = L(8); fp(5); L(3); char* (*fc)(char) = L('a'); fc('b'); L('c'); double* (*fd)(double) = L(3.14); fd(3.14); fd(6.26); } { auto L = [=](auto b) { return [](auto a) ->decltype(b)* { return (decltype(b)*)0; }; //expected-note{{candidate template ignored}} }; char* (*fp)(int) = L('8'); fp(5); char* (*fc)(char) = L('a'); fc('b'); double* (*fi)(int) = L(3.14); fi(5); int* (*fi2)(int) = L(3.14); //expected-error{{no viable conversion}} } { auto L = [=](auto b) { return [](auto a) { return [=](auto c) { return [](auto d) ->decltype(a + b + c + d) { return d; }; }; }; }; int (*fp)(int) = L('8')(3)(short{}); double (*fs)(char) = L(3.14)(short{})('4'); } fooT(3); fooT('a'); fooT(3.14); fooT("abcdefg"); return 0; } int run2 = test(); } namespace test_conversion_to_fptr { void f1(int (*)(int)) { } void f2(char (*)(int)) { } // expected-note{{candidate}} void g(int (*)(int)) { } // #1 expected-note{{candidate}} void g(char (*)(char)) { } // #2 expected-note{{candidate}} void h(int (*)(int)) { } // #3 void h(char (*)(int)) { } // #4 int test() { { auto glambda = [](auto a) { return a; }; glambda(1); f1(glambda); // OK f2(glambda); // expected-error{{no matching function}} g(glambda); // expected-error{{call to 'g' is ambiguous}} h(glambda); // OK: calls #3 since it is convertible from ID int& (*fpi)(int*) = [](auto* a) -> auto& { return *a; }; // OK } { auto L = [](auto a) { return a; }; int (*fp)(int) = L; fp(5); L(3); char (*fc)(char) = L; fc('b'); L('c'); double (*fd)(double) = L; fd(3.14); fd(6.26); L(4.25); } { auto L = [](auto a) ->int { return a; }; //expected-note 2{{candidate template ignored}} int (*fp)(int) = L; char (*fc)(char) = L; //expected-error{{no viable conversion}} double (*fd)(double) = L; //expected-error{{no viable conversion}} } { int* (*fp)(int*) = [](auto *a) -> auto* { return a; }; fp(0); } } namespace more_converion_to_ptr_to_function_tests { int test() { { int& (*fpi)(int*) = [](auto* a) -> auto& { return *a; }; // OK int (*fp2)(int) = [](auto b) -> int { return b; }; int (*fp3)(char) = [](auto c) -> int { return c; }; char (*fp4)(int) = [](auto d) { return d; }; //expected-error{{no viable conversion}}\ //expected-note{{candidate template ignored}} char (*fp5)(char) = [](auto e) -> int { return e; }; //expected-error{{no viable conversion}}\ //expected-note{{candidate template ignored}} fp2(3); fp3('\n'); fp3('a'); return 0; } } // end test() template<class ... Ts> void vfun(Ts ... ) { } int variadic_test() { int (*fp)(int, char, double) = [](auto ... a) -> int { vfun(a...); return 4; }; fp(3, '4', 3.14); int (*fp2)(int, char, double) = [](auto ... a) { vfun(a...); return 4; }; fp(3, '4', 3.14); return 2; } } // end ns namespace conversion_operator { void test() { auto L = [](auto a) -> int { return a; }; int (*fp)(int) = L; int (&fp2)(int) = [](auto a) { return a; }; // expected-error{{non-const lvalue}} int (&&fp3)(int) = [](auto a) { return a; }; // expected-error{{no viable conversion}}\ //expected-note{{candidate}} } } } namespace return_type_deduction_ok { auto l = [](auto a) ->auto { return a; }(2); auto l2 = [](auto a) ->decltype(auto) { return a; }(2); auto l3 = [](auto a) { return a; }(2); } namespace generic_lambda_as_default_argument_ok { void test(int i = [](auto a)->int { return a; }(3)) { } } namespace nested_non_capturing_lambda_tests { template<class ... Ts> void print(Ts ...) { } int test() { { auto L = [](auto a) { return [](auto b) { return b; }; }; auto M = L(3); M(4.15); } { int i = 10; //expected-note 3{{declared here}} auto L = [](auto a) { return [](auto b) { //expected-note 3{{begins here}} i = b; //expected-error 3{{cannot be implicitly captured}} return b; }; }; auto M = L(3); //expected-note{{instantiation}} M(4.15); //expected-note{{instantiation}} } { int i = 10; auto L = [](auto a) { return [](auto b) { b = sizeof(i); //ok return b; }; }; } { auto L = [](auto a) { print("a = ", a, "\n"); return [](auto b) ->decltype(a) { print("b = ", b, "\n"); return b; }; }; auto M = L(3); M(4.15); } { auto L = [](auto a) ->decltype(a) { print("a = ", a, "\n"); return [](auto b) ->decltype(a) { //expected-error{{no viable conversion}}\ //expected-note{{candidate template ignored}} print("b = ", b, "\n"); return b; }; }; auto M = L(3); //expected-note{{in instantiation of}} } { auto L = [](auto a) { print("a = ", a, "\n"); return [](auto ... b) ->decltype(a) { print("b = ", b ..., "\n"); return 4; }; }; auto M = L(3); M(4.15, 3, "fv"); } { auto L = [](auto a) { print("a = ", a, "\n"); return [](auto ... b) ->decltype(a) { print("b = ", b ..., "\n"); return 4; }; }; auto M = L(3); int (*fp)(double, int, const char*) = M; fp(4.15, 3, "fv"); } { auto L = [](auto a) { print("a = ", a, "\n"); return [](char b) { return [](auto ... c) ->decltype(b) { print("c = ", c ..., "\n"); return 42; }; }; }; L(4); auto M = L(3); M('a'); auto N = M('x'); N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = N; np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); } { auto L = [](auto a) { print("a = ", a, "\n"); return [](decltype(a) b) { return [](auto ... c) ->decltype(b) { print("c = ", c ..., "\n"); return 42; }; }; }; L('4'); auto M = L('3'); M('a'); auto N = M('x'); N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = N; np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); } { struct X { static void foo(double d) { } void test() { auto L = [](auto a) { print("a = ", a, "\n"); foo(a); return [](decltype(a) b) { foo(b); foo(sizeof(a) + sizeof(b)); return [](auto ... c) ->decltype(b) { print("c = ", c ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return 42; }; }; }; L('4'); auto M = L('3'); M('a'); auto N = M('x'); N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = N; np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); } }; X x; x.test(); } // Make sure we can escape the function { struct X { static void foo(double d) { } auto test() { auto L = [](auto a) { print("a = ", a, "\n"); foo(a); return [](decltype(a) b) { foo(b); foo(sizeof(a) + sizeof(b)); return [](auto ... c) ->decltype(b) { print("c = ", c ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return 42; }; }; }; return L; } }; X x; auto L = x.test(); L('4'); auto M = L('3'); M('a'); auto N = M('x'); N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = N; np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); } { struct X { static void foo(double d) { } auto test() { auto L = [](auto a) { print("a = ", a, "\n"); foo(a); return [](decltype(a) b) { foo(b); foo(sizeof(a) + sizeof(b)); return [](auto ... c) { print("c = ", c ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} print("d = ", d ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return decltype(a){}; }; }; }; }; return L; } }; X x; auto L = x.test(); L('4'); auto M = L('3'); M('a'); auto N = M('x'); auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = O; np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} } } // end test() namespace wrapped_within_templates { namespace explicit_return { template<class T> int fooT(T t) { auto L = [](auto a) -> void { auto M = [](char b) -> void { auto N = [](auto c) -> void { int x = 0; x = sizeof(a); x = sizeof(b); x = sizeof(c); }; N('a'); N(decltype(a){}); }; }; L(t); L(3.14); return 0; } int run = fooT('a') + fooT(3.14); } // end explicit_return namespace implicit_return_deduction { template<class T> auto fooT(T t) { auto L = [](auto a) { auto M = [](char b) { auto N = [](auto c) { int x = 0; x = sizeof(a); x = sizeof(b); x = sizeof(c); }; N('a'); N(decltype(a){}); }; }; L(t); L(3.14); return 0; } int run = fooT('a') + fooT(3.14); template<class ... Ts> void print(Ts ... ts) { } template<class ... Ts> auto fooV(Ts ... ts) { auto L = [](auto ... a) { auto M = [](decltype(a) ... b) { auto N = [](auto c) { int x = 0; x = sizeof...(a); x = sizeof...(b); x = sizeof(c); }; N('a'); N(N); N(first<Ts...>{}); }; M(a...); print("a = ", a..., "\n"); }; L(L, ts...); print("ts = ", ts..., "\n"); return 0; } int run2 = fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{}); } //implicit_return_deduction } //wrapped_within_templates namespace at_ns_scope { void foo(double d) { } auto test() { auto L = [](auto a) { print("a = ", a, "\n"); foo(a); return [](decltype(a) b) { foo(b); foo(sizeof(a) + sizeof(b)); return [](auto ... c) { print("c = ", c ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} print("d = ", d ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return decltype(a){}; }; }; }; }; return L; } auto L = test(); auto L_test = L('4'); auto M = L('3'); auto M_test = M('a'); auto N = M('x'); auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = O; auto NP_result = np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} } namespace variadic_tests_1 { template<class ... Ts> void print(Ts ... ts) { } template<class F, class ... Rest> F& FirstArg(F& f, Rest...) { return f; } template<class ... Ts> int fooV(Ts ... ts) { auto L = [](auto ... a) -> void { auto M = [](decltype(a) ... b) -> void { auto N = [](auto c) -> void { int x = 0; x = sizeof...(a); x = sizeof...(b); x = sizeof(c); }; N('a'); N(N); N(first<Ts...>{}); }; M(a...); print("a = ", a..., "\n"); }; L(L, ts...); print("ts = ", ts..., "\n"); return 0; } int run2 = fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{}); namespace more_variadic_1 { template<class ... Ts> int fooV(Ts ... ts) { auto L = [](auto ... a) { auto M = [](decltype(a) ... b) -> void { auto N = [](auto c) -> void { int x = 0; x = sizeof...(a); x = sizeof...(b); x = sizeof(c); }; N('a'); N(N); N(first<Ts...>{}); }; M(a...); return M; }; auto M = L(L, ts...); decltype(L(L, ts...)) (*fp)(decltype(L), decltype(ts) ...) = L; void (*fp2)(decltype(L), decltype(ts) ...) = L(L, ts...); { auto L = [](auto ... a) { auto M = [](decltype(a) ... b) { auto N = [](auto c) -> void { int x = 0; x = sizeof...(a); x = sizeof...(b); x = sizeof(c); }; N('a'); N(N); N(first<Ts...>{}); return N; }; M(a...); return M; }; auto M = L(L, ts...); decltype(L(L, ts...)) (*fp)(decltype(L), decltype(ts) ...) = L; fp(L, ts...); decltype(L(L, ts...)(L, ts...)) (*fp2)(decltype(L), decltype(ts) ...) = L(L, ts...); fp2 = fp(L, ts...); void (*fp3)(char) = fp2(L, ts...); fp3('a'); } return 0; } int run2 = fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{}); } //end ns more_variadic_1 } // end ns variadic_tests_1 namespace at_ns_scope_within_class_member { struct X { static void foo(double d) { } auto test() { auto L = [](auto a) { print("a = ", a, "\n"); foo(a); return [](decltype(a) b) { foo(b); foo(sizeof(a) + sizeof(b)); return [](auto ... c) { print("c = ", c ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} print("d = ", d ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return decltype(a){}; }; }; }; }; return L; } }; X x; auto L = x.test(); auto L_test = L('4'); auto M = L('3'); auto M_test = M('a'); auto N = M('x'); auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = O; auto NP_result = np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} } //end at_ns_scope_within_class_member namespace at_ns_scope_within_class_template_member { struct X { static void foo(double d) { } template<class T = int> auto test(T = T{}) { auto L = [](auto a) { print("a = ", a, "\n"); foo(a); return [](decltype(a) b) { foo(b); foo(sizeof(a) + sizeof(b)); return [](auto ... c) { print("c = ", c ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} print("d = ", d ..., "\n"); foo(decltype(b){}); foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); return decltype(a){}; }; }; }; }; return L; } }; X x; auto L = x.test(); auto L_test = L('4'); auto M = L('3'); auto M_test = M('a'); auto N = M('x'); auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); char (*np)(const char*, int, const char*, double, const char*, int) = O; auto NP_result = np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} } //end at_ns_scope_within_class_member namespace nested_generic_lambdas_123 { void test() { auto L = [](auto a) -> int { auto M = [](auto b, decltype(a) b2) -> int { return 1; }; M(a, a); }; L(3); } template<class T> void foo(T) { auto L = [](auto a) { return a; }; } template void foo(int); } // end ns nested_generic_lambdas_123 namespace nested_fptr_235 { int test() { auto L = [](auto b) { return [](auto a) ->decltype(a) { return a; }; }; int (*fp)(int) = L(8); fp(5); L(3); char (*fc)(char) = L('a'); fc('b'); L('c'); double (*fd)(double) = L(3.14); fd(3.14); fd(6.26); return 0; } int run = test(); } namespace fptr_with_decltype_return_type { template<class F, class ... Rest> F& FirstArg(F& f, Rest& ... r) { return f; }; template<class ... Ts> auto vfun(Ts&& ... ts) { print(ts...); return FirstArg(ts...); } int test() { { auto L = [](auto ... As) { return [](auto b) ->decltype(b) { vfun([](decltype(As) a) -> decltype(a) { return a; } ...)(first<decltype(As)...>{}); return decltype(b){}; }; }; auto LL = L(1, 'a', 3.14, "abc"); LL("dim"); } return 0; } int run = test(); } } // end ns nested_non_capturing_lambda_tests namespace PR17476 { struct string { string(const char *__s) { } string &operator+=(const string &__str) { return *this; } }; template <class T> void finalizeDefaultAtomValues() { auto startEnd = [](const char * sym) -> void { string start("__"); start += sym; }; startEnd("preinit_array"); } void f() { finalizeDefaultAtomValues<char>(); } } namespace PR17476_variant { struct string { string(const char *__s) { } string &operator+=(const string &__str) { return *this; } }; template <class T> void finalizeDefaultAtomValues() { auto startEnd = [](const T *sym) -> void { string start("__"); start += sym; }; startEnd("preinit_array"); } void f() { finalizeDefaultAtomValues<char>(); } } namespace PR17877_lambda_declcontext_and_get_cur_lambda_disconnect { template<class T> struct U { int t = 0; }; template<class T> struct V { U<T> size() const { return U<T>{}; } }; template<typename T> void Do() { V<int> v{}; [=] { v.size(); }; } } namespace inclass_lambdas_within_nested_classes { namespace ns1 { struct X1 { struct X2 { enum { E = [](auto i) { return i; }(3) }; //expected-error{{inside of a constant expression}}\ //expected-error{{not an integral constant}}\ //expected-note{{non-literal type}} int L = ([] (int i) { return i; })(2); void foo(int i = ([] (int i) { return i; })(2)) { } int B : ([](int i) { return i; })(3); //expected-error{{inside of a constant expression}}\ //expected-error{{not an integral constant}}\ //expected-note{{non-literal type}} int arr[([](int i) { return i; })(3)]; //expected-error{{inside of a constant expression}}\ //expected-error{{must have a constant size}} int (*fp)(int) = [](int i) { return i; }; void fooptr(int (*fp)(char) = [](char c) { return 0; }) { } int L2 = ([](auto i) { return i; })(2); void fooG(int i = ([] (auto i) { return i; })(2)) { } int BG : ([](auto i) { return i; })(3); //expected-error{{inside of a constant expression}} \ //expected-error{{not an integral constant}}\ //expected-note{{non-literal type}} int arrG[([](auto i) { return i; })(3)]; //expected-error{{inside of a constant expression}}\ //expected-error{{must have a constant size}} int (*fpG)(int) = [](auto i) { return i; }; void fooptrG(int (*fp)(char) = [](auto c) { return 0; }) { } }; }; } //end ns namespace ns2 { struct X1 { template<class T> struct X2 { int L = ([] (T i) { return i; })(2); void foo(int i = ([] (int i) { return i; })(2)) { } int B : ([](T i) { return i; })(3); //expected-error{{inside of a constant expression}}\ //expected-error{{not an integral constant}}\ //expected-note{{non-literal type}} int arr[([](T i) { return i; })(3)]; //expected-error{{inside of a constant expression}}\ //expected-error{{must have a constant size}} int (*fp)(T) = [](T i) { return i; }; void fooptr(T (*fp)(char) = [](char c) { return 0; }) { } int L2 = ([](auto i) { return i; })(2); void fooG(T i = ([] (auto i) { return i; })(2)) { } int BG : ([](auto i) { return i; })(3); //expected-error{{not an integral constant}}\ //expected-note{{non-literal type}}\ //expected-error{{inside of a constant expression}} int arrG[([](auto i) { return i; })(3)]; //expected-error{{must have a constant size}} \ //expected-error{{inside of a constant expression}} int (*fpG)(T) = [](auto i) { return i; }; void fooptrG(T (*fp)(char) = [](auto c) { return 0; }) { } template<class U = char> int fooG2(T (*fp)(U) = [](auto a) { return 0; }) { return 0; } template<class U = char> int fooG3(T (*fp)(U) = [](auto a) { return 0; }); }; }; template<class T> template<class U> int X1::X2<T>::fooG3(T (*fp)(U)) { return 0; } X1::X2<int> x2; //expected-note 3{{in instantiation of}} int run1 = x2.fooG2(); int run2 = x2.fooG3(); } // end ns } //end ns inclass_lambdas_within_nested_classes namespace pr21684_disambiguate_auto_followed_by_ellipsis_no_id { int a = [](auto ...) { return 0; }(); } namespace PR22117 { int x = [](auto) { return [](auto... run_args) { using T = int(decltype(run_args)...); return 0; }; }(0)(0); } namespace PR23716 { template<typename T> auto f(T x) { auto g = [](auto&&... args) { auto h = [args...]() -> int { return 0; }; return h; }; return g; } auto x = f(0)(); } namespace PR13987 { class Enclosing { void Method(char c = []()->char { int d = [](auto x)->int { struct LocalClass { int Method() { return 0; } }; return 0; }(0); return d; }() ); }; class Enclosing2 { void Method(char c = [](auto x)->char { int d = []()->int { struct LocalClass { int Method() { return 0; } }; return 0; }(); return d; }(0) ); }; class Enclosing3 { void Method(char c = [](auto x)->char { int d = [](auto y)->int { struct LocalClass { int Method() { return 0; } }; return 0; }(0); return d; }(0) ); }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-unused-variables-error.cpp
// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s namespace PR6948 { template<typename T> class X; // expected-note{{template is declared here}} void f() { X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}} \ expected-error{{implicit instantiation of undefined template 'PR6948::X<char>'}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/address-of.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR clang/3175 void bar(int*); class c { int var; static int svar; void foo() { bar(&var); bar(&svar); } static void wibble() { bar(&var); // expected-error{{invalid use of member 'var' in static member function}} bar(&svar); } }; enum E { Enumerator }; void test() { (void)&Enumerator; // expected-error{{cannot take the address of an rvalue of type 'E'}} } template<int N> void test2() { (void)&N; // expected-error{{cannot take the address of an rvalue of type 'int'}} } // PR clang/3222 void xpto(); void (*xyz)(void) = &xpto; struct PR11066 { static int foo(short); static int foo(float); void test(); }; void PR11066::test() { int (PR11066::*ptr)(int) = & &PR11066::foo; // expected-error{{extra '&' taking address of overloaded function}} } namespace test3 { // emit no error template<typename T> struct S { virtual void f() = 0; }; template<typename T> void S<T>::f() { T::error; } void (S<int>::*p)() = &S<int>::f; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/member-location.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR4103: Make sure we have a location for the error class A { float a(int *); // expected-note{{passing argument to parameter here}} int b(); }; int A::b() { return a(a((int*)0)); } // expected-error {{cannot initialize a parameter of type 'int *' with an rvalue of type 'float'}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-self-assign.cpp
// RUN: %clang_cc1 -fsyntax-only -Wself-assign -verify %s void f() { int a = 42, b = 42; a = a; // expected-warning{{explicitly assigning}} b = b; // expected-warning{{explicitly assigning}} a = b; b = a = b; a = a = a; // expected-warning{{explicitly assigning}} a = b = b = a; a &= a; // expected-warning{{explicitly assigning}} a |= a; // expected-warning{{explicitly assigning}} a ^= a; } // Dummy type. struct S {}; void false_positives() { #define OP = #define LHS a #define RHS a int a = 42; // These shouldn't warn due to the use of the preprocessor. a OP a; LHS = a; a = RHS; LHS OP RHS; #undef OP #undef LHS #undef RHS S s; s = s; // Not a builtin assignment operator, no warning. // Volatile stores aren't side-effect free. volatile int vol_a; vol_a = vol_a; volatile int &vol_a_ref = vol_a; vol_a_ref = vol_a_ref; } template <typename T> void g() { T a; a = a; // May or may not be a builtin assignment operator, no warning. } void instantiate() { g<int>(); g<S>(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s struct non_copiable { non_copiable(const non_copiable&) = delete; // expected-note {{marked deleted here}} non_copiable& operator = (const non_copiable&) = delete; // expected-note {{explicitly deleted}} non_copiable() = default; }; struct non_const_copy { non_const_copy(non_const_copy&); non_const_copy& operator = (non_const_copy&) &; non_const_copy& operator = (non_const_copy&) &&; non_const_copy() = default; // expected-note {{not viable}} }; non_const_copy::non_const_copy(non_const_copy&) = default; // expected-note {{not viable}} non_const_copy& non_const_copy::operator = (non_const_copy&) & = default; // expected-note {{not viable}} non_const_copy& non_const_copy::operator = (non_const_copy&) && = default; // expected-note {{not viable}} void fn1 () { non_copiable nc; non_copiable nc2 = nc; // expected-error {{deleted constructor}} nc = nc; // expected-error {{deleted operator}} non_const_copy ncc; non_const_copy ncc2 = ncc; ncc = ncc2; const non_const_copy cncc{}; const non_const_copy cncc1; // expected-error {{default initialization of an object of const type 'const non_const_copy' without a user-provided default constructor}} non_const_copy ncc3 = cncc; // expected-error {{no matching}} ncc = cncc; // expected-error {{no viable overloaded}} }; struct non_const_derived : non_const_copy { non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}} non_const_derived& operator =(non_const_derived&) = default; }; struct bad_decls { bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}} bad_decls&& operator = (bad_decls) = default; // expected-error {{lvalue reference}} expected-error {{must return 'bad_decls &'}} bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}} bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}} }; struct DefaultDelete { DefaultDelete() = default; // expected-note {{previous declaration is here}} DefaultDelete() = delete; // expected-error {{constructor cannot be redeclared}} ~DefaultDelete() = default; // expected-note {{previous declaration is here}} ~DefaultDelete() = delete; // expected-error {{destructor cannot be redeclared}} DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous declaration is here}} DefaultDelete &operator=(const DefaultDelete &) = delete; // expected-error {{class member cannot be redeclared}} }; struct DeleteDefault { DeleteDefault() = delete; // expected-note {{previous definition is here}} DeleteDefault() = default; // expected-error {{constructor cannot be redeclared}} ~DeleteDefault() = delete; // expected-note {{previous definition is here}} ~DeleteDefault() = default; // expected-error {{destructor cannot be redeclared}} DeleteDefault &operator=(const DeleteDefault &) = delete; // expected-note {{previous definition is here}} DeleteDefault &operator=(const DeleteDefault &) = default; // expected-error {{class member cannot be redeclared}} }; struct A {}; struct B {}; struct except_spec_a { virtual ~except_spec_a() throw(A); except_spec_a() throw(A); }; struct except_spec_b { virtual ~except_spec_b() throw(B); except_spec_b() throw(B); }; struct except_spec_d_good : except_spec_a, except_spec_b { ~except_spec_d_good(); }; except_spec_d_good::~except_spec_d_good() = default; struct except_spec_d_good2 : except_spec_a, except_spec_b { ~except_spec_d_good2() = default; }; struct except_spec_d_bad : except_spec_a, except_spec_b { ~except_spec_d_bad() noexcept; }; // FIXME: This should error because this exception spec is not // compatible with the implicit exception spec. except_spec_d_bad::~except_spec_d_bad() noexcept = default; // FIXME: This should error because this exception spec is not // compatible with the implicit exception spec. struct except_spec_d_mismatch : except_spec_a, except_spec_b { except_spec_d_mismatch() throw(A) = default; }; struct except_spec_d_match : except_spec_a, except_spec_b { except_spec_d_match() throw(A, B) = default; }; // gcc-compatibility: allow attributes on default definitions // (but not normal definitions) struct S { S(); }; S::S() __attribute((pure)) = default; using size_t = decltype(sizeof(0)); void *operator new(size_t) = delete; // expected-error {{deleted definition must be first declaration}} expected-note {{implicit}} void operator delete(void *) noexcept = delete; // expected-error {{deleted definition must be first declaration}} expected-note {{implicit}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/vararg-default-arg.cpp
// RUN: %clang_cc1 %s -verify -fsyntax-only // expected-no-diagnostics // PR5462 void f1(void); void f2(const char * = __null, ...); void f1(void) { f2(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/builtins-va_arg.cpp
// RUN: %clang_cc1 %s -ffreestanding // RUN: %clang_cc1 %s -ffreestanding -triple i686-unknown-linux // RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-linux // RUN: %clang_cc1 %s -ffreestanding -triple mips-unknown-linux // RUN: %clang_cc1 %s -ffreestanding -triple mipsel-unknown-linux // RUN: %clang_cc1 %s -ffreestanding -triple armv7-unknown-linux-gnueabi // RUN: %clang_cc1 %s -ffreestanding -triple thumbv7-unknown-linux-gnueabi #include "stdarg.h" int int_accumulator = 0; double double_accumulator = 0; int test_vprintf(const char *fmt, va_list ap) { char ch; int result = 0; while (*fmt != '\0') { ch = *fmt++; if (ch != '%') { continue; } ch = *fmt++; switch (ch) { case 'd': int_accumulator += va_arg(ap, int); result++; break; case 'f': double_accumulator += va_arg(ap, double); result++; break; default: break; } if (ch == '0') { break; } } return result; } int test_printf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); int result = test_vprintf(fmt, ap); va_end(ap); return result; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/array-bound-merge.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR5515 extern int a[]; int a[10]; extern int b[10]; int b[]; extern int c[1]; int c[] = {1,2}; // expected-error {{excess elements in array initializer}} int d[1][]; // expected-error {{array has incomplete element type 'int []'}} extern const int e[2]; // expected-note {{previous declaration is here}} int e[] = { 1 }; // expected-error {{redefinition of 'e' with a different type: 'int []' vs 'const int [2]'}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/arrow-operator.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct T { void f(); }; struct A { T* operator->(); // expected-note{{candidate function}} }; struct B { T* operator->(); // expected-note{{candidate function}} }; struct C : A, B { }; struct D : A { }; struct E; // expected-note {{forward declaration of 'E'}} void f(C &c, D& d, E& e) { c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}} d->f(); e->f(); // expected-error{{incomplete definition of type}} } // rdar://8875304 namespace rdar8875304 { class Point {}; class Line_Segment{ public: Line_Segment(const Point&){} }; class Node { public: Point Location(){ Point p; return p; } }; void f() { Node** node1; Line_Segment(node1->Location()); // expected-error {{not a structure or union}} } } namespace arrow_suggest { template <typename T> class wrapped_ptr { public: wrapped_ptr(T* ptr) : ptr_(ptr) {} T* operator->() { return ptr_; } void Check(); // expected-note {{'Check' declared here}} private: T *ptr_; }; class Worker { public: void DoSomething(); // expected-note {{'DoSomething' declared here}} void Chuck(); }; void test() { wrapped_ptr<Worker> worker(new Worker); worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} worker.DoSamething(); // expected-error {{no member named 'DoSamething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} \ // expected-error {{no member named 'DoSamething' in 'arrow_suggest::Worker'; did you mean 'DoSomething'?}} worker.Chuck(); // expected-error {{no member named 'Chuck' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean 'Check'?}} } } // namespace arrow_suggest
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/calling-conv-compat.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fms-extensions -verify -triple i686-pc-win32 %s // Pointers to free functions void free_func_default(); void __cdecl free_func_cdecl(); void __stdcall free_func_stdcall(); void __fastcall free_func_fastcall(); typedef void ( *fptr_default)(); typedef void (__cdecl *fptr_cdecl)(); typedef void (__stdcall *fptr_stdcall)(); typedef void (__fastcall *fptr_fastcall)(); // expected-note@+4 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}} // expected-note@+3 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((stdcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((fastcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}} void cb_fptr_default(fptr_default ptr); // expected-note@+4 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}} // expected-note@+3 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((stdcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((fastcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}} void cb_fptr_cdecl(fptr_cdecl ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fptr_stdcall' (aka 'void (*)() __attribute__((stdcall))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fptr_stdcall' (aka 'void (*)() __attribute__((stdcall))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fptr_stdcall' (aka 'void (*)() __attribute__((stdcall))') for 1st argument}} void cb_fptr_stdcall(fptr_stdcall ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fptr_fastcall' (aka 'void (*)() __attribute__((fastcall))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fptr_fastcall' (aka 'void (*)() __attribute__((fastcall))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fptr_fastcall' (aka 'void (*)() __attribute__((fastcall))') for 1st argument}} void cb_fptr_fastcall(fptr_fastcall ptr); // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'const fptr_default' (aka 'void (*const)()') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'const fptr_default' (aka 'void (*const)()') for 1st argument}} void cb_fptr_const_default(const fptr_default ptr); void call_free_func() { cb_fptr_default(free_func_default); cb_fptr_default(free_func_cdecl); cb_fptr_default(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fptr_default'}} cb_fptr_default(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fptr_default'}} cb_fptr_default(&free_func_default); cb_fptr_default(&free_func_cdecl); cb_fptr_default(&free_func_stdcall); // expected-error {{no matching function for call to 'cb_fptr_default'}} cb_fptr_default(&free_func_fastcall); // expected-error {{no matching function for call to 'cb_fptr_default'}} cb_fptr_cdecl(free_func_default); cb_fptr_cdecl(free_func_cdecl); cb_fptr_cdecl(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}} cb_fptr_cdecl(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}} cb_fptr_cdecl(&free_func_default); cb_fptr_cdecl(&free_func_cdecl); cb_fptr_cdecl(&free_func_stdcall); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}} cb_fptr_cdecl(&free_func_fastcall); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}} cb_fptr_stdcall(free_func_default); // expected-error {{no matching function for call to 'cb_fptr_stdcall'}} cb_fptr_stdcall(free_func_cdecl); // expected-error {{no matching function for call to 'cb_fptr_stdcall'}} cb_fptr_stdcall(free_func_stdcall); cb_fptr_stdcall(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fptr_stdcall'}} cb_fptr_fastcall(free_func_default); // expected-error {{no matching function for call to 'cb_fptr_fastcall'}} cb_fptr_fastcall(free_func_cdecl); // expected-error {{no matching function for call to 'cb_fptr_fastcall'}} cb_fptr_fastcall(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fptr_fastcall'}} cb_fptr_fastcall(free_func_fastcall); cb_fptr_const_default(free_func_default); cb_fptr_const_default(free_func_cdecl); cb_fptr_const_default(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fptr_const_default'}} cb_fptr_const_default(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fptr_const_default'}} } // Pointers to variadic functions // variadic function can't declared stdcall or fastcall void free_func_variadic_default(int, ...); void __cdecl free_func_variadic_cdecl(int, ...); typedef void ( *fptr_variadic_default)(int, ...); typedef void (__cdecl *fptr_variadic_cdecl)(int, ...); void cb_fptr_variadic_default(fptr_variadic_default ptr); void cb_fptr_variadic_cdecl(fptr_variadic_cdecl ptr); void call_free_variadic_func() { cb_fptr_variadic_default(free_func_variadic_default); cb_fptr_variadic_default(free_func_variadic_cdecl); cb_fptr_variadic_default(&free_func_variadic_default); cb_fptr_variadic_default(&free_func_variadic_cdecl); cb_fptr_variadic_cdecl(free_func_variadic_default); cb_fptr_variadic_cdecl(free_func_variadic_cdecl); cb_fptr_variadic_cdecl(&free_func_variadic_default); cb_fptr_variadic_cdecl(&free_func_variadic_cdecl); } // References to functions typedef void ( &fref_default)(); typedef void (__cdecl &fref_cdecl)(); typedef void (__stdcall &fref_stdcall)(); typedef void (__fastcall &fref_fastcall)(); // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fref_default' (aka 'void (&)()') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fref_default' (aka 'void (&)()') for 1st argument}} void cb_fref_default(fref_default ptr); // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fref_cdecl' (aka 'void (&)()') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fref_cdecl' (aka 'void (&)()') for 1st argument}} void cb_fref_cdecl(fref_cdecl ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fref_stdcall' (aka 'void (&)() __attribute__((stdcall))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fref_stdcall' (aka 'void (&)() __attribute__((stdcall))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fref_stdcall' (aka 'void (&)() __attribute__((stdcall))') for 1st argument}} void cb_fref_stdcall(fref_stdcall ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fref_fastcall' (aka 'void (&)() __attribute__((fastcall))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fref_fastcall' (aka 'void (&)() __attribute__((fastcall))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fref_fastcall' (aka 'void (&)() __attribute__((fastcall))') for 1st argument}} void cb_fref_fastcall(fref_fastcall ptr); void call_free_func_ref() { cb_fref_default(free_func_default); cb_fref_default(free_func_cdecl); cb_fref_default(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fref_default'}} cb_fref_default(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fref_default'}} cb_fref_cdecl(free_func_default); cb_fref_cdecl(free_func_cdecl); cb_fref_cdecl(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fref_cdecl'}} cb_fref_cdecl(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fref_cdecl'}} cb_fref_stdcall(free_func_default); // expected-error {{no matching function for call to 'cb_fref_stdcall'}} cb_fref_stdcall(free_func_cdecl); // expected-error {{no matching function for call to 'cb_fref_stdcall'}} cb_fref_stdcall(free_func_stdcall); cb_fref_stdcall(free_func_fastcall); // expected-error {{no matching function for call to 'cb_fref_stdcall'}} cb_fref_fastcall(free_func_default); // expected-error {{no matching function for call to 'cb_fref_fastcall'}} cb_fref_fastcall(free_func_cdecl); // expected-error {{no matching function for call to 'cb_fref_fastcall'}} cb_fref_fastcall(free_func_stdcall); // expected-error {{no matching function for call to 'cb_fref_fastcall'}} cb_fref_fastcall(free_func_fastcall); } // References to variadic functions // variadic function can't declared stdcall or fastcall typedef void ( &fref_variadic_default)(int, ...); typedef void (__cdecl &fref_variadic_cdecl)(int, ...); void cb_fref_variadic_default(fptr_variadic_default ptr); void cb_fref_variadic_cdecl(fptr_variadic_cdecl ptr); void call_free_variadic_func_ref() { cb_fref_variadic_default(free_func_variadic_default); cb_fref_variadic_default(free_func_variadic_cdecl); cb_fref_variadic_cdecl(free_func_variadic_default); cb_fref_variadic_cdecl(free_func_variadic_cdecl); } // Pointers to members namespace NonVariadic { struct A { void member_default(); void __cdecl member_cdecl(); void __thiscall member_thiscall(); }; struct B : public A { }; struct C { void member_default(); void __cdecl member_cdecl(); void __thiscall member_thiscall(); }; typedef void ( A::*memb_a_default)(); typedef void (__cdecl A::*memb_a_cdecl)(); typedef void (__thiscall A::*memb_a_thiscall)(); typedef void ( B::*memb_b_default)(); typedef void (__cdecl B::*memb_b_cdecl)(); typedef void (__thiscall B::*memb_b_thiscall)(); typedef void ( C::*memb_c_default)(); typedef void (__cdecl C::*memb_c_cdecl)(); typedef void (__thiscall C::*memb_c_thiscall)(); // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_a_default' (aka 'void (NonVariadic::A::*)() __attribute__((thiscall))') for 1st argument}} void cb_memb_a_default(memb_a_default ptr); // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_a_cdecl' (aka 'void (NonVariadic::A::*)() __attribute__((cdecl))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_a_cdecl' (aka 'void (NonVariadic::A::*)() __attribute__((cdecl))') for 1st argument}} void cb_memb_a_cdecl(memb_a_cdecl ptr); // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_a_thiscall' (aka 'void (NonVariadic::A::*)() __attribute__((thiscall))') for 1st argument}} void cb_memb_a_thiscall(memb_a_thiscall ptr); // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_b_default' (aka 'void (NonVariadic::B::*)() __attribute__((thiscall))') for 1st argument}} void cb_memb_b_default(memb_b_default ptr); // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_b_cdecl' (aka 'void (NonVariadic::B::*)() __attribute__((cdecl))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_b_cdecl' (aka 'void (NonVariadic::B::*)() __attribute__((cdecl))') for 1st argument}} void cb_memb_b_cdecl(memb_b_cdecl ptr); // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_b_thiscall' (aka 'void (NonVariadic::B::*)() __attribute__((thiscall))') for 1st argument}} void cb_memb_b_thiscall(memb_b_thiscall ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_c_default' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_c_default' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_c_default' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}} void cb_memb_c_default(memb_c_default ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_c_cdecl' (aka 'void (NonVariadic::C::*)() __attribute__((cdecl))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_c_cdecl' (aka 'void (NonVariadic::C::*)() __attribute__((cdecl))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_c_cdecl' (aka 'void (NonVariadic::C::*)() __attribute__((cdecl))') for 1st argument}} void cb_memb_c_cdecl(memb_c_cdecl ptr); // expected-note@+3 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_c_thiscall' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}} // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'memb_c_thiscall' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'memb_c_thiscall' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}} void cb_memb_c_thiscall(memb_c_thiscall ptr); void call_member() { cb_memb_a_default(&A::member_default); cb_memb_a_default(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_a_default'}} cb_memb_a_default(&A::member_thiscall); cb_memb_a_cdecl(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_a_cdecl'}} cb_memb_a_cdecl(&A::member_cdecl); cb_memb_a_cdecl(&A::member_thiscall); // expected-error {{no matching function for call to 'cb_memb_a_cdecl'}} cb_memb_a_thiscall(&A::member_default); cb_memb_a_thiscall(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_a_thiscall'}} cb_memb_a_thiscall(&A::member_thiscall); } void call_member_inheritance() { cb_memb_b_default(&A::member_default); cb_memb_b_default(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_b_default'}} cb_memb_b_default(&A::member_thiscall); cb_memb_c_default(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_c_default'}} cb_memb_c_default(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_c_default'}} cb_memb_c_default(&A::member_thiscall); // expected-error {{no matching function for call to 'cb_memb_c_default'}} cb_memb_b_cdecl(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_b_cdecl'}} cb_memb_b_cdecl(&A::member_cdecl); cb_memb_b_cdecl(&A::member_thiscall); // expected-error {{no matching function for call to 'cb_memb_b_cdecl'}} cb_memb_c_cdecl(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}} cb_memb_c_cdecl(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}} cb_memb_c_cdecl(&A::member_thiscall); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}} cb_memb_b_thiscall(&A::member_default); cb_memb_b_thiscall(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_b_thiscall'}} cb_memb_b_thiscall(&A::member_thiscall); cb_memb_c_thiscall(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_c_thiscall'}} cb_memb_c_thiscall(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_c_thiscall'}} cb_memb_c_thiscall(&A::member_thiscall); // expected-error {{no matching function for call to 'cb_memb_c_thiscall'}} } } // end namespace NonVariadic namespace Variadic { struct A { void member_default(int, ...); void __cdecl member_cdecl(int, ...); void __thiscall member_thiscall(int, ...); // expected-error {{variadic function cannot use thiscall calling convention}} }; struct B : public A { }; struct C { void member_default(int, ...); void __cdecl member_cdecl(int, ...); }; typedef void ( A::*memb_a_default)(int, ...); typedef void (__cdecl A::*memb_a_cdecl)(int, ...); typedef void ( B::*memb_b_default)(int, ...); typedef void (__cdecl B::*memb_b_cdecl)(int, ...); typedef void ( C::*memb_c_default)(int, ...); typedef void (__cdecl C::*memb_c_cdecl)(int, ...); void cb_memb_a_default(memb_a_default ptr); void cb_memb_a_cdecl(memb_a_cdecl ptr); void cb_memb_b_default(memb_b_default ptr); void cb_memb_b_cdecl(memb_b_cdecl ptr); // expected-note@+2 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...)' to 'memb_c_default' (aka 'void (Variadic::C::*)(int, ...)') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...) __attribute__((cdecl))' to 'memb_c_default' (aka 'void (Variadic::C::*)(int, ...)') for 1st argument}} void cb_memb_c_default(memb_c_default ptr); // expected-note@+2 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...)' to 'memb_c_cdecl' (aka 'void (Variadic::C::*)(int, ...) __attribute__((cdecl))') for 1st argument}} // expected-note@+1 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...) __attribute__((cdecl))' to 'memb_c_cdecl' (aka 'void (Variadic::C::*)(int, ...) __attribute__((cdecl))') for 1st argument}} void cb_memb_c_cdecl(memb_c_cdecl ptr); void call_member() { cb_memb_a_default(&A::member_default); cb_memb_a_default(&A::member_cdecl); cb_memb_a_cdecl(&A::member_default); cb_memb_a_cdecl(&A::member_cdecl); } void call_member_inheritance() { cb_memb_b_default(&A::member_default); cb_memb_b_default(&A::member_cdecl); cb_memb_c_default(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_c_default'}} cb_memb_c_default(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_c_default'}} cb_memb_b_cdecl(&A::member_default); cb_memb_b_cdecl(&A::member_cdecl); cb_memb_c_cdecl(&A::member_default); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}} cb_memb_c_cdecl(&A::member_cdecl); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}} } } // end namespace Variadic namespace MultiChunkDecls { // Try to test declarators that have multiple DeclaratorChunks. struct A { void __thiscall member_thiscall(int); }; void (A::*return_mptr(short))(int) { return &A::member_thiscall; } void (A::*(*return_fptr_mptr(char))(short))(int) { return return_mptr; } typedef void (A::*mptr_t)(int); mptr_t __stdcall return_mptr_std(short) { return &A::member_thiscall; } void (A::*(*return_fptr_std_mptr(char))(short))(int) { return return_mptr_std; // expected-error {{cannot initialize return object of type 'void (MultiChunkDecls::A::*(*)(short))(int) __attribute__((thiscall))' with an lvalue of type 'mptr_t (short) __attribute__((stdcall))'}} } void call_return() { A o; void (A::*(*fptr)(short))(int) = return_fptr_mptr('a'); void (A::*mptr)(int) = fptr(1); (o.*mptr)(2); } } // end namespace MultiChunkDecls namespace MemberPointers { struct A { void __thiscall method_thiscall(); void __cdecl method_cdecl(); void __stdcall method_stdcall(); void __fastcall method_fastcall(); }; void ( A::*mp1)() = &A::method_thiscall; void (__cdecl A::*mp2)() = &A::method_cdecl; void (__stdcall A::*mp3)() = &A::method_stdcall; void (__fastcall A::*mp4)() = &A::method_fastcall; // Use a typedef to form the member pointer and verify that cdecl is adjusted. typedef void ( fun_default)(); typedef void (__cdecl fun_cdecl)(); typedef void (__stdcall fun_stdcall)(); typedef void (__fastcall fun_fastcall)(); fun_default A::*td1 = &A::method_thiscall; fun_cdecl A::*td2 = &A::method_thiscall; fun_stdcall A::*td3 = &A::method_stdcall; fun_fastcall A::*td4 = &A::method_fastcall; // Round trip the function type through a template, and verify that only cdecl // gets adjusted. template<typename Fn> struct X { typedef Fn A::*p; }; X<void ()>::p tmpl1 = &A::method_thiscall; X<void __cdecl ()>::p tmpl2 = &A::method_thiscall; X<void __stdcall ()>::p tmpl3 = &A::method_stdcall; X<void __fastcall ()>::p tmpl4 = &A::method_fastcall; X<fun_default >::p tmpl5 = &A::method_thiscall; X<fun_cdecl >::p tmpl6 = &A::method_thiscall; X<fun_stdcall >::p tmpl7 = &A::method_stdcall; X<fun_fastcall>::p tmpl8 = &A::method_fastcall; } // end namespace MemberPointers // Test that lambdas that capture nothing convert to cdecl function pointers. namespace Lambdas { void pass_fptr_cdecl (void (__cdecl *fp)()); void pass_fptr_stdcall (void (__stdcall *fp)()); // expected-note {{candidate function not viable}} void pass_fptr_fastcall(void (__fastcall *fp)()); // expected-note {{candidate function not viable}} void conversion_to_fptr() { pass_fptr_cdecl ([]() { } ); pass_fptr_stdcall ([]() { } ); // expected-error {{no matching function for call}} pass_fptr_fastcall([]() { } ); // expected-error {{no matching function for call}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/deprecated.cpp
// RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS #include "Inputs/register.h" void f() throw(); void g() throw(int); void h() throw(...); #if __cplusplus >= 201103L // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept' instead}} // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}} // expected-warning@-4 {{dynamic exception specifications are deprecated}} expected-note@-4 {{use 'noexcept(false)' instead}} #endif void stuff() { register int n; #if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS) // expected-warning@-2 {{'register' storage class specifier is deprecated}} #endif register int m asm("rbx"); // no-warning int k = to_int(n); // no-warning bool b; ++b; // expected-warning {{incrementing expression of type bool is deprecated}} char *p = "foo"; #if __cplusplus < 201103L // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}} #else // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}} #endif } struct S { int n; void operator+(int); }; struct T : private S { S::n; #if __cplusplus < 201103L // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} #else // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} #endif S::operator+; #if __cplusplus < 201103L // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} #else // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} #endif }; #if __cplusplus >= 201103L namespace DeprecatedCopy { struct Assign { Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}} }; Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'Assign' first required here}} struct Ctor { Ctor(); Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}} }; Ctor b1, b2; void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'Ctor' first required here}} struct Dtor { ~Dtor(); // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}} // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}} }; Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'Dtor' first required here}} void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'Dtor' first required here}} } #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx98-compat-pedantic.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s -DCXX1Y2 // RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98 // RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-c++98-c++11-compat-pedantic -DCXX1Y2 // -Wc++98-compat-pedantic warns on C++11 features which we accept without a // warning in C++98 mode. #line 32767 // ok #line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}} #define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}} VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}} ; // expected-warning {{extra ';' outside of a function is incompatible with C++98}} enum Enum { Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}} }; template<typename T> struct InstantiationAfterSpecialization {}; template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}} template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}} void *dlsym(); void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}} void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}} struct ConvertToInt { operator int(); }; int *ArraySizeConversion = new int[ConvertToInt()]; #ifdef CXX1Y2 // expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}} #else // expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}} #endif template<typename T> class ExternTemplate {}; extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}} long long ll1 = // expected-warning {{'long long' is incompatible with C++98}} -42LL; // expected-warning {{'long long' is incompatible with C++98}} unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}} 42ULL; // expected-warning {{'long long' is incompatible with C++98}} int k = 0b1001; #ifdef CXX1Y // expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++14}} #endif namespace CopyCtorIssues { struct Private { Private(); private: Private(const Private&); // expected-note {{declared private here}} }; struct NoViable { NoViable(); NoViable(NoViable&); // expected-note {{not viable}} }; struct Ambiguous { Ambiguous(); Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}} Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}} }; struct Deleted { Private p; // expected-note {{implicitly deleted}} }; const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}} const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}} #if !CXX98 const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}} #endif const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-self-comparisons.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics void f(int (&array1)[2], int (&array2)[2]) { if (array1 == array2) { } // no warning }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/nullability.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wno-nullability-declspec %s -verify #if __has_feature(nullability) #else # error nullability feature should be defined #endif typedef decltype(nullptr) nullptr_t; class X { }; // Nullability applies to all pointer types. typedef int (X::* _Nonnull member_function_type_1)(int); typedef int X::* _Nonnull member_data_type_1; typedef nullptr_t _Nonnull nonnull_nullptr_t; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'nullptr_t'}} // Nullability can move into member pointers (this is suppressing a warning). typedef _Nonnull int (X::* member_function_type_2)(int); typedef int (X::* _Nonnull member_function_type_3)(int); typedef _Nonnull int X::* member_data_type_2; // Adding non-null via a template. template<typename T> struct AddNonNull { typedef _Nonnull T type; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int'}} // expected-error@-1{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'nullptr_t'}} }; typedef AddNonNull<int *>::type nonnull_int_ptr_1; typedef AddNonNull<int * _Nullable>::type nonnull_int_ptr_2; // FIXME: check that it was overridden typedef AddNonNull<nullptr_t>::type nonnull_int_ptr_3; // expected-note{{in instantiation of template class}} typedef AddNonNull<int>::type nonnull_non_pointer_1; // expected-note{{in instantiation of template class 'AddNonNull<int>' requested here}} // Non-null checking within a template. template<typename T> struct AddNonNull2 { typedef _Nonnull AddNonNull<T> invalid1; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'AddNonNull<T>'}} typedef _Nonnull AddNonNull2 invalid2; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'AddNonNull2<T>'}} typedef _Nonnull AddNonNull2<T> invalid3; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'AddNonNull2<T>'}} typedef _Nonnull typename AddNonNull<T>::type okay1; // Don't move past a dependent type even if we know that nullability // cannot apply to that specific dependent type. typedef _Nonnull AddNonNull<T> (*invalid4); // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'AddNonNull<T>'}} }; // Check passing null to a _Nonnull argument. void (*accepts_nonnull_1)(_Nonnull int *ptr); void (*& accepts_nonnull_2)(_Nonnull int *ptr) = accepts_nonnull_1; void (X::* accepts_nonnull_3)(_Nonnull int *ptr); void accepts_nonnull_4(_Nonnull int *ptr); void (&accepts_nonnull_5)(_Nonnull int *ptr) = accepts_nonnull_4; void test_accepts_nonnull_null_pointer_literal(X *x) { accepts_nonnull_1(0); // expected-warning{{null passed to a callee that requires a non-null argument}} accepts_nonnull_2(0); // expected-warning{{null passed to a callee that requires a non-null argument}} (x->*accepts_nonnull_3)(0); // expected-warning{{null passed to a callee that requires a non-null argument}} accepts_nonnull_4(0); // expected-warning{{null passed to a callee that requires a non-null argument}} accepts_nonnull_5(0); // expected-warning{{null passed to a callee that requires a non-null argument}} } template<void FP(_Nonnull int*)> void test_accepts_nonnull_null_pointer_literal_template() { FP(0); // expected-warning{{null passed to a callee that requires a non-null argument}} } template void test_accepts_nonnull_null_pointer_literal_template<&accepts_nonnull_4>(); // expected-note{{instantiation of function template specialization}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s void f(); // expected-note {{possible target for call}} void f(int); // expected-note {{possible target for call}} void g() { bool b = noexcept(f); // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} bool b2 = noexcept(f(0)); } struct S { void g(); // expected-note {{possible target for call}} void g(int); // expected-note {{possible target for call}} void h() { bool b = noexcept(this->g); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}} bool b2 = noexcept(this->g(0)); } };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-cleanup.cpp
// RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-gcc-compat namespace N { void c1(int *a) {} } class C { static void c2(int *a) {} // expected-note {{implicitly declared private here}} expected-note {{implicitly declared private here}} }; void t1() { int v1 __attribute__((cleanup(N::c1))); int v2 __attribute__((cleanup(N::c2))); // expected-error {{no member named 'c2' in namespace 'N'}} int v3 __attribute__((cleanup(C::c2))); // expected-error {{'c2' is a private member of 'C'}} } class D : public C { void t2() { int v1 __attribute__((cleanup(c2))); // expected-error {{'c2' is a private member of 'C'}} } }; namespace E { void c3(int *a) {} // expected-note {{candidate function}} void c3() {} // expected-note {{candidate function}} void t3() { int v1 __attribute__((cleanup(c3))); // expected-error {{'c3' is not a single function}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/constexpr-backtrace-limit.cpp
// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 0 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST1 // TEST1: constant expression // TEST1-NEXT: exceeded maximum depth of 4 // TEST1-NEXT: in call to 'recurse(2)' // TEST1-NEXT: in call to 'recurse(3)' // TEST1-NEXT: in call to 'recurse(4)' // TEST1-NEXT: in call to 'recurse(5)' // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 2 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST2 // TEST2: constant expression // TEST2-NEXT: exceeded maximum depth of 4 // TEST2-NEXT: in call to 'recurse(2)' // TEST2-NEXT: skipping 2 calls // TEST2-NEXT: in call to 'recurse(5)' // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 2 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST3 // TEST3: constant expression // TEST3-NEXT: reinterpret_cast // TEST3-NEXT: in call to 'recurse(0)' // TEST3-NEXT: skipping 4 calls // TEST3-NEXT: in call to 'recurse(5)' // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 8 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST4 // TEST4: constant expression // TEST4-NEXT: reinterpret_cast // TEST4-NEXT: in call to 'recurse(0)' // TEST4-NEXT: in call to 'recurse(1)' // TEST4-NEXT: in call to 'recurse(2)' // TEST4-NEXT: in call to 'recurse(3)' // TEST4-NEXT: in call to 'recurse(4)' // TEST4-NEXT: in call to 'recurse(5)' constexpr int recurse(int n) { return n ? recurse(n-1) : *(int*)n; } static_assert(recurse(5), "");
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-variable-not-needed.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s namespace test1 { static int abc = 42; // expected-warning {{variable 'abc' is not needed and will not be emitted}} template <typename T> int foo(void) { return abc; } } namespace test2 { struct bah { }; namespace { struct foo : bah { static char bar; virtual void zed(); }; void foo::zed() { bar++; } char foo::bar=0; } bah *getfoo() { return new foo(); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-shadow.cpp
// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow %s namespace { int i; // expected-note {{previous declaration is here}} } namespace one { namespace two { int j; // expected-note {{previous declaration is here}} } } namespace xx { int m; } namespace yy { int m; } using namespace one::two; using namespace xx; using namespace yy; void foo() { int i; // expected-warning {{declaration shadows a variable in namespace '(anonymous)'}} int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}} int m; } class A { static int data; // expected-note {{previous declaration}} int field; // expected-note {{previous declaration}} void test() { char *field; // expected-warning {{declaration shadows a field of 'A'}} char *data; // expected-warning {{declaration shadows a static data member of 'A'}} } }; // TODO: this should warn, <rdar://problem/5018057> class B : A { int data; static int field; }; // rdar://8900456 namespace rdar8900456 { struct Foo { static void Baz(); private: int Bar; }; void Foo::Baz() { double Bar = 12; // Don't warn. } } // http://llvm.org/PR9160 namespace PR9160 { struct V { V(int); }; struct S { V v; static void m() { if (1) { V v(0); } } }; } extern int bob; // expected-note {{previous declaration is here}} // rdar://8883302 void rdar8883302() { extern int bob; // don't warn for shadowing. } void test8() { int bob; // expected-warning {{declaration shadows a variable in the global namespace}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR7944.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR7944 #define MACRO(x) x struct B { int f() { return 0; } }; struct A { B* b() { return new B; } }; void g() { A a; MACRO(a.b->f()); // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/fntype-decl.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // PR2942 typedef void fn(int); fn f; // expected-note {{previous declaration is here}} int g(int x, int y); int g(int x, int y = 2); typedef int g_type(int, int); g_type g; int h(int x) { // expected-note {{previous definition is here}} return g(x); } float f(int) { } // expected-error{{functions that differ only in their return type cannot be overloaded}} int h(int) { } // expected-error{{redefinition of 'h'}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/decltype-this.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // expected-no-diagnostics 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; }; struct S { void f() { static_assert(is_same<decltype(this), S*>::value, ""); } void g() const { static_assert(is_same<decltype(this), const S*>::value, ""); } void h() volatile { static_assert(is_same<decltype(this), volatile S*>::value, ""); } void i() const volatile { static_assert(is_same<decltype(this), const volatile S*>::value, ""); } };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/constant-expression.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s // C++ [expr.const]p1: // In several places, C++ requires expressions that evaluate to an integral // or enumeration constant: as array bounds, as case expressions, as // bit-field lengths, as enumerator initializers, as static member // initializers, and as integral or enumeration non-type template arguments. // An integral constant-expression can involve only literals, enumerators, // const variables or static data members of integral or enumeration types // initialized with constant expressions, and sizeof expressions. Floating // literals can appear only if they are cast to integral or enumeration types. enum Enum { eval = 1 }; const int cval = 2; const Enum ceval = eval; struct Struct { static const int sval = 3; static const Enum seval = eval; }; template <int itval, Enum etval> struct C { enum E { v1 = 1, v2 = eval, v3 = cval, v4 = ceval, v5 = Struct::sval, v6 = Struct::seval, v7 = itval, v8 = etval, v9 = (int)1.5, v10 = sizeof(Struct), v11 = true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0 }; unsigned b1 : 1, b2 : eval, b3 : cval, b4 : ceval, b5 : Struct::sval, b6 : Struct::seval, b7 : itval, b8 : etval, b9 : (int)1.5, b10 : sizeof(Struct), b11 : true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0 ; static const int i1 = 1, i2 = eval, i3 = cval, i4 = ceval, i5 = Struct::sval, i6 = Struct::seval, i7 = itval, i8 = etval, i9 = (int)1.5, i10 = sizeof(Struct), i11 = true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0 ; void f(int cond) { switch(cond) { case 0 + 1: case 100 + eval: case 200 + cval: case 300 + ceval: case 400 + Struct::sval: case 500 + Struct::seval: case 600 + itval: case 700 + etval: case 800 + (int)1.5: case 900 + sizeof(Struct): case 1000 + (true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0): ; } } typedef C<itval, etval> T0; }; template struct C<1, eval>; template struct C<cval, ceval>; template struct C<Struct::sval, Struct::seval>; enum { a = sizeof(int) == 8, b = a? 8 : 4 }; void diags(int n) { switch (n) { case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} case __imag(1/0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} case (int)__imag((double)(1/0)): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} ; } } namespace IntOrEnum { const int k = 0; const int &p = k; template<int n> struct S {}; S<p> s; // expected-error {{not an integral constant expression}} } extern const int recurse1; // recurse2 cannot be used in a constant expression because it is not // initialized by a constant expression. The same expression appearing later in // the TU would be a constant expression, but here it is not. const int recurse2 = recurse1; const int recurse1 = 1; int array1[recurse1]; // ok int array2[recurse2]; // expected-warning {{variable length array}} expected-warning {{integer constant expression}} namespace FloatConvert { typedef int a[(int)42.3]; typedef int a[(int)42.997]; typedef int b[(long long)4e20]; // expected-warning {{variable length}} expected-error {{variable length}} expected-warning {{'long long' is a C++11 extension}} } // PR12626 namespace test3 { struct X; // expected-note {{forward declaration of 'test3::X'}} struct Y { bool b; X x; }; // expected-error {{field has incomplete type 'test3::X'}} int f() { return Y().b; } } // PR18283 namespace test4 { template <int> struct A {}; int const i = { 42 }; // i can be used as non-type template-parameter as "const int x = { 42 };" is // equivalent to "const int x = 42;" as per C++03 8.5/p13. typedef A<i> Ai; // ok } // rdar://16064952 namespace rdar16064952 { template < typename T > void fn1() { T b; unsigned w = ({int a = b.val[sizeof(0)]; 0; }); // expected-warning {{use of GNU statement expression extension}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/switch-implicit-fallthrough.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s int fallthrough(int n) { switch (n / 10) { if (n - 1) { n = 100; } else if (n - 2) { n = 101; } else if (n - 3) { n = 102; } case -1: // no warning here, ignore fall-through from unreachable code ; case 0: {// expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} } case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} n += 100 ; case 3: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} if (n > 0) n += 200; case 4: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} if (n < 0) ; case 5: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} switch (n) { case 111: break; case 112: break; case 113: break ; } case 6: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} n += 300; case 66: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} case 67: case 68: break; } switch (n / 15) { label_default: default: n += 333; if (n % 10) goto label_default; break; case 70: n += 335; break; } switch (n / 20) { case 7: n += 400; [[clang::fallthrough]]; case 9: // no warning here, intended fall-through marked with an attribute n += 800; [[clang::fallthrough]]; default: { // no warning here, intended fall-through marked with an attribute if (n % 2 == 0) { return 1; } else { [[clang::fallthrough]]; } } case 10: // no warning here, intended fall-through marked with an attribute if (n % 3 == 0) { n %= 3; } else { [[clang::fallthrough]]; } case 110: // expected-warning{{unannotated fall-through between switch labels}} but no fix-it hint as we have one fall-through annotation! n += 800; } switch (n / 30) { case 11: case 12: // no warning here, intended fall-through, no statement between labels n += 1600; } switch (n / 40) { case 13: if (n % 2 == 0) { return 1; } else { return 2; } case 15: // no warning here, there's no fall-through n += 3200; } switch (n / 50) { case 17: { if (n % 2 == 0) { return 1; } else { return 2; } } case 19: { // no warning here, there's no fall-through n += 6400; return 3; } case 21: { // no warning here, there's no fall-through break; } case 23: // no warning here, there's no fall-through n += 128000; break; case 25: // no warning here, there's no fall-through break; } return n; } class ClassWithDtor { public: ~ClassWithDtor() {} }; void fallthrough2(int n) { switch (n) { case 0: { ClassWithDtor temp; break; } default: // no warning here, there's no fall-through break; } } void fallthrough3(int n) { switch (n) { case 1: do { return; } while (0); case 2: do { ClassWithDtor temp; return; } while (0); case 3: break; } } #define MY_SWITCH(X, Y, Z, U, V) switch (X) { case Y: Z; case U: V; } #define MY_SWITCH2(X, Y, Z) switch (X) { Y; Z; } #define MY_CASE(X, Y) case X: Y #define MY_CASE2(X, Y, U, V) case X: Y; case U: V int fallthrough_macro1(int n) { MY_SWITCH(n, 13, n *= 2, 14, break) // expected-warning{{unannotated fall-through between switch labels}} switch (n + 1) { MY_CASE(33, n += 2); MY_CASE(44, break); // expected-warning{{unannotated fall-through between switch labels}} MY_CASE(55, n += 3); } switch (n + 3) { MY_CASE(333, return 333); MY_CASE2(444, n += 44, 4444, break); // expected-warning{{unannotated fall-through between switch labels}} MY_CASE(555, n += 33); } MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break)) // expected-warning{{unannotated fall-through between switch labels}} MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break)) // expected-warning{{unannotated fall-through between switch labels}} return n; } void fallthrough_cfgblock_with_null_successor(int x) { (x && "") ? (void)(0) : (void)(1); switch (x) {} } int fallthrough_position(int n) { switch (n) { [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} n += 300; [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} case 221: [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} return 1; [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} case 222: [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} n += 400; case 223: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} } long p = static_cast<long>(n) * n; switch (sizeof(p)) { case 9: n += static_cast<int>(p >> 32); [[clang::fallthrough]]; // no warning here case 5: n += static_cast<int>(p); [[clang::fallthrough]]; // no warning here default: n += 1; break; } return n; } enum Enum { Value1, Value2 }; int fallthrough_covered_enums(Enum e) { int n = 0; switch (e) { default: n += 17; [[clang::fallthrough]]; // no warning here, this shouldn't be treated as unreachable code case Value1: n += 19; break; case Value2: n += 21; break; } return n; } // Fallthrough annotations in local classes used to generate "fallthrough // annotation does not directly precede switch label" warning. void fallthrough_in_local_class() { class C { void f(int x) { switch (x) { case 0: x++; [[clang::fallthrough]]; // no diagnostics case 1: x++; default: // \ expected-warning{{unannotated fall-through between switch labels}} \ expected-note{{insert 'break;' to avoid fall-through}} break; } } }; } // Fallthrough annotations in lambdas used to generate "fallthrough // annotation does not directly precede switch label" warning. void fallthrough_in_lambda() { (void)[] { int x = 0; switch (x) { case 0: x++; [[clang::fallthrough]]; // no diagnostics case 1: x++; default: // \ expected-warning{{unannotated fall-through between switch labels}} \ expected-note{{insert 'break;' to avoid fall-through}} break; } }; } namespace PR18983 { void fatal() __attribute__((noreturn)); int num(); void test() { switch (num()) { case 1: fatal(); // Don't issue a warning. case 2: break; } } } int fallthrough_targets(int n) { [[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}} [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} switch (n) { case 121: n += 400; [[clang::fallthrough]]; // no warning here, correct target case 123: [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} n += 800; break; [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} expected-note{{did you forget ';'?}} case 125: n += 1600; } return n; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/constexpr-ackermann.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s constexpr unsigned long long A(unsigned long long m, unsigned long long n) { return m == 0 ? n + 1 : n == 0 ? A(m-1, 1) : A(m - 1, A(m, n - 1)); } using X = int[A(3,4)]; using X = int[125];
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/references.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s int g(int); void f() { int i; int &r = i; r = 1; int *p = &r; int &rr = r; int (&rg)(int) = g; rg(i); int a[3]; int (&ra)[3] = a; ra[1] = i; int *Q; int *& P = Q; P[1] = 1; } typedef int t[1]; void test2() { t a; t& b = a; int c[3]; int (&rc)[3] = c; } // C++ [dcl.init.ref]p5b1 struct A { }; struct B : A { } b; void test3() { double d = 2.0; double& rd = d; // rd refers to d const double& rcd = d; // rcd refers to d A& ra = b; // ra refers to A subobject in b const A& rca = b; // rca refers to A subobject in b } B fB(); // C++ [dcl.init.ref]p5b2 void test4() { double& rd2 = 2.0; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a temporary of type 'double'}} int i = 2; double& rd3 = i; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a value of unrelated type 'int'}} const A& rca = fB(); } void test5() { // const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0 const volatile int cvi = 1; const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}} } // C++ [dcl.init.ref]p3 int& test6(int& x) { int& yo; // expected-error{{declaration of reference variable 'yo' requires an initializer}} return x; } int& not_initialized_error; // expected-error{{declaration of reference variable 'not_initialized_error' requires an initializer}} extern int& not_initialized_okay; class Test6 { // expected-warning{{class 'Test6' does not declare any constructor to initialize its non-modifiable members}} int& okay; // expected-note{{reference member 'okay' will never be initialized}} }; struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due to ambiguity:\n struct C -> struct B -> struct A\nstruct C -> struct A}} void test7(C& c) { A& a1 = c; // expected-error {{ambiguous conversion from derived class 'C' to base class 'A':}} } // C++ [dcl.ref]p1, C++ [dcl.ref]p4 void test8(int& const,// expected-error{{'const' qualifier may not be applied to a reference}} void&, // expected-error{{cannot form a reference to 'void'}} int& &) // expected-error{{type name declared as a reference to a reference}} { typedef int& intref; typedef intref& intrefref; // C++ DR 106: reference collapsing typedef intref const intref_c; // expected-warning {{'const' qualifier on reference type 'intref' (aka 'int &') has no effect}} typedef intref_c intref; // ok, same type typedef intref volatile intref; // expected-warning {{'volatile' qualifier on reference type 'intref' (aka 'int &') has no effect}} typedef intref _Atomic intref; // expected-warning {{'_Atomic' qualifier on reference type 'intref' (aka 'int &') has no effect}} void restrict_ref(__restrict intref); // ok void restrict_ref(int &__restrict); // ok } template<typename T> int const_param(const T) {} int const_ref_param = const_param<int&>(const_ref_param); // no-warning class string { char *Data; unsigned Length; public: string(); ~string(); }; string getInput(); void test9() { string &s = getInput(); // expected-error{{lvalue reference}} } void test10() { __attribute((vector_size(16))) typedef int vec4; typedef __attribute__(( ext_vector_type(4) )) int ext_vec4; vec4 v; int &a = v[0]; // expected-error{{non-const reference cannot bind to vector element}} const int &b = v[0]; ext_vec4 ev; int &c = ev.x; // expected-error{{non-const reference cannot bind to vector element}} const int &d = ev.x; } namespace PR7149 { template<typename T> struct X0 { T& first; X0(T& p1) : first(p1) { } }; void f() { int p1[1]; X0< const int[1]> c(p1); } } namespace PR8608 { bool& f(unsigned char& c) { return (bool&)c; } } // The following crashed trying to recursively evaluate the LValue. const int &do_not_crash = do_not_crash; // expected-warning{{reference 'do_not_crash' is not yet bound to a value when used within its own initialization}} namespace ExplicitRefInit { // This is invalid: we can't copy-initialize an 'A' temporary using an // explicit constructor. struct A { explicit A(int); }; const A &a(0); // expected-error {{reference to type 'const ExplicitRefInit::A' could not bind to an rvalue of type 'int'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/auto-pragma.cpp
// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump -ast-dump-filter AutoVar | FileCheck %s namespace { class foo { }; } #pragma GCC visibility push(hidden) auto AutoVar = foo(); // CHECK: VarDecl {{.*}} AutoVar // CHECK-NOT: VisibilityAttr
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-address.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion -Wno-string-compare -Wno-tautological-compare -Waddress %s // RUN: %clang_cc1 -fsyntax-only -verify %s void foo(); int arr[5]; int global; const char* str = ""; void test() { if (foo) {} // expected-warning{{always evaluate to 'true'}} \ // expected-note{{silence}} if (arr) {} // expected-warning{{always evaluate to 'true'}} if (&global) {} // expected-warning{{always evaluate to 'true'}} if (foo == 0) {} // expected-warning{{always false}} \ // expected-note{{silence}} if (arr == 0) {} // expected-warning{{always false}} if (&global == 0) {} // expected-warning{{always false}} if (str == "foo") {} // expected-warning{{unspecified}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/default1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s void f(int i); void f(int i = 0); // expected-note {{previous definition is here}} void f(int i = 17); // expected-error {{redefinition of default argument}} void g(int i, int j, int k = 3); void g(int i, int j = 2, int k); void g(int i = 1, int j, int k); void h(int i, int j = 2, int k = 3, int l, // expected-error {{missing default argument on parameter 'l'}} int, // expected-error {{missing default argument on parameter}} int n);// expected-error {{missing default argument on parameter 'n'}} struct S { } s; void i(int = s) { } // expected-error {{no viable conversion}} \ // expected-note{{passing argument to parameter here}} struct X { X(int); }; void j(X x = 17); // expected-note{{'::j' declared here}} struct Y { // expected-note 2{{candidate}} explicit Y(int); }; void k(Y y = 17); // expected-error{{no viable conversion}} \ // expected-note{{passing argument to parameter 'y' here}} void kk(Y = 17); // expected-error{{no viable conversion}} \ // expected-note{{passing argument to parameter here}} int l () { int m(int i, int j, int k = 3); if (1) { int m(int i, int j = 2, int k = 4); m(8); } return 0; } int i () { void j (int f = 4); { void j (int f); j(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean '::j'?}} } void jj (int f = 4); { void jj (int f); // expected-note{{'jj' declared here}} jj(); // expected-error{{too few arguments to function call, single argument 'f' was not specified}} } } int i2() { void j(int f = 4); // expected-note{{'j' declared here}} { j(2, 3); // expected-error{{too many arguments to function call, expected at most single argument 'f', have 2}} } } int pr20055_f(int x = 0, int y = UNDEFINED); // expected-error{{use of undeclared identifier}} int pr20055_v = pr20055_f(0); void PR20769() { void PR20769(int = 1); } void PR20769(int = 2); void PR20769_b(int = 1); void PR20769_b() { void PR20769_b(int = 2); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx98-compat-flags.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s template<typename T> int TemplateFn(T) { return 0; } void LocalTemplateArg() { struct S {}; TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} } struct {} obj_of_unnamed_type; // expected-note {{here}} int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} namespace CopyCtorIssues { struct Private { Private(); private: Private(const Private&); // expected-note {{declared private here}} }; struct NoViable { NoViable(); NoViable(NoViable&); // expected-note {{not viable}} }; struct Ambiguous { Ambiguous(); Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}} Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}} }; struct Deleted { Private p; // expected-note {{copy constructor of 'Deleted' is implicitly deleted because field 'p' has an inaccessible copy constructor}} }; const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}} const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}} const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}} const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/scope-check.cpp
// RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify -fblocks -fcxx-exceptions -fms-extensions %s -Wno-unreachable-code // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify -fblocks -fcxx-exceptions -fms-extensions -std=gnu++11 %s -Wno-unreachable-code namespace testInvalid { Invalid inv; // expected-error {{unknown type name}} // Make sure this doesn't assert. void fn() { int c = 0; if (inv) Here: ; goto Here; } } namespace test0 { struct D { ~D(); }; int f(bool b) { if (b) { D d; goto end; } end: return 1; } } namespace test1 { struct C { C(); }; int f(bool b) { if (b) goto foo; // expected-error {{cannot jump}} C c; // expected-note {{jump bypasses variable initialization}} foo: return 1; } } namespace test2 { struct C { C(); }; int f(void **ip) { static void *ips[] = { &&lbl1, &&lbl2 }; C c; goto *ip; lbl1: return 0; lbl2: return 1; } } namespace test3 { struct C { C(); }; int f(void **ip) { static void *ips[] = { &&lbl1, &&lbl2 }; goto *ip; lbl1: { C c; return 0; } lbl2: return 1; } } namespace test4 { struct C { C(); }; struct D { ~D(); }; int f(void **ip) { static void *ips[] = { &&lbl1, &&lbl2 }; C c0; goto *ip; // expected-error {{cannot jump}} C c1; // expected-note {{jump bypasses variable initialization}} lbl1: // expected-note {{possible target of indirect goto}} return 0; lbl2: return 1; } } namespace test5 { struct C { C(); }; struct D { ~D(); }; int f(void **ip) { static void *ips[] = { &&lbl1, &&lbl2 }; C c0; goto *ip; lbl1: // expected-note {{possible target of indirect goto}} return 0; lbl2: if (ip[1]) { D d; // expected-note {{jump exits scope of variable with non-trivial destructor}} ip += 2; goto *ip; // expected-error {{cannot jump}} } return 1; } } namespace test6 { struct C { C(); }; unsigned f(unsigned s0, unsigned s1, void **ip) { static void *ips[] = { &&lbl1, &&lbl2, &&lbl3, &&lbl4 }; C c0; goto *ip; lbl1: s0++; goto *++ip; lbl2: s0 -= s1; goto *++ip; lbl3: { unsigned tmp = s0; s0 = s1; s1 = tmp; goto *++ip; } lbl4: return s0; } } // C++0x says it's okay to skip non-trivial initializers on static // locals, and we implement that in '03 as well. namespace test7 { struct C { C(); }; void test() { goto foo; static C c; foo: return; } } // PR7789 namespace test8 { void test1(int c) { switch (c) { case 0: int x = 56; // expected-note {{jump bypasses variable initialization}} case 1: // expected-error {{cannot jump}} x = 10; } } void test2() { goto l2; // expected-error {{cannot jump}} l1: int x = 5; // expected-note {{jump bypasses variable initialization}} l2: x++; } } namespace test9 { struct S { int i; }; void test1() { goto foo; S s; foo: return; } unsigned test2(unsigned x, unsigned y) { switch (x) { case 2: S s; if (y > 42) return x + y; default: return x - 2; } } } // http://llvm.org/PR10462 namespace PR10462 { enum MyEnum { something_valid, something_invalid }; bool recurse() { MyEnum K; switch (K) { // expected-warning {{enumeration value 'something_invalid' not handled in switch}} case something_valid: case what_am_i_thinking: // expected-error {{use of undeclared identifier}} int *X = 0; if (recurse()) { } break; } } } namespace test10 { int test() { static void *ps[] = { &&a0 }; goto *&&a0; // expected-error {{cannot jump}} int a = 3; // expected-note {{jump bypasses variable initialization}} a0: return 0; } } // pr13812 namespace test11 { struct C { C(int x); ~C(); }; void f(void **ip) { static void *ips[] = { &&l0 }; l0: // expected-note {{possible target of indirect goto}} C c0 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}} goto *ip; // expected-error {{cannot jump}} } } namespace test12 { struct C { C(int x); ~C(); }; void f(void **ip) { static void *ips[] = { &&l0 }; const C c0 = 17; l0: // expected-note {{possible target of indirect goto}} const C &c1 = 42; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}} const C &c2 = c0; goto *ip; // expected-error {{cannot jump}} } } namespace test13 { struct C { C(int x); ~C(); int i; }; void f(void **ip) { static void *ips[] = { &&l0 }; l0: // expected-note {{possible target of indirect goto}} const int &c1 = C(1).i; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}} goto *ip; // expected-error {{cannot jump}} } } namespace test14 { struct C { C(int x); ~C(); operator int&() const; }; void f(void **ip) { static void *ips[] = { &&l0 }; l0: // no warning since the C temporary is destructed before the goto. const int &c1 = C(1); goto *ip; } } // PR14225 namespace test15 { void f1() try { goto x; // expected-error {{cannot jump}} } catch(...) { // expected-note {{jump bypasses initialization of catch block}} x: ; } void f2() try { // expected-note {{jump bypasses initialization of try block}} x: ; } catch(...) { goto x; // expected-error {{cannot jump}} } } namespace test16 { struct S { int n; }; int f() { goto x; // expected-error {{cannot jump}} const S &s = S(); // expected-note {{jump bypasses variable initialization}} x: return s.n; } } #if __cplusplus >= 201103L namespace test17 { struct S { int get(); private: int n; }; int f() { goto x; // expected-error {{cannot jump}} S s = {}; // expected-note {{jump bypasses variable initialization}} x: return s.get(); } } #endif namespace test18 { struct A { ~A(); }; struct B { const int &r; const A &a; }; int f() { void *p = &&x; const A a = A(); x: B b = { 0, a }; // ok goto *p; } int g() { void *p = &&x; x: // expected-note {{possible target of indirect goto}} B b = { 0, A() }; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}} goto *p; // expected-error {{cannot jump}} } } #if __cplusplus >= 201103L namespace std { typedef decltype(sizeof(int)) size_t; template<typename T> struct initializer_list { const T *begin; size_t size; initializer_list(const T *, size_t); }; } namespace test19 { struct A { ~A(); }; int f() { void *p = &&x; A a; x: // expected-note {{possible target of indirect goto}} std::initializer_list<A> il = { a }; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}} goto *p; // expected-error {{cannot jump}} } } namespace test20 { struct A { ~A(); }; struct B { const A &a; }; int f() { void *p = &&x; A a; x: std::initializer_list<B> il = { a, a }; goto *p; } int g() { void *p = &&x; A a; x: // expected-note {{possible target of indirect goto}} std::initializer_list<B> il = { a, { A() } // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}} }; goto *p; // expected-error {{cannot jump}} } } #endif namespace test21 { template<typename T> void f() { goto x; // expected-error {{cannot jump}} T t; // expected-note {{bypasses}} x: return; } template void f<int>(); struct X { ~X(); }; template void f<X>(); // expected-note {{instantiation of}} } namespace PR18217 { typedef int *X; template <typename T> class MyCl { T mem; }; class Source { MyCl<X> m; public: int getKind() const; }; bool b; template<typename TT> static void foo(const Source &SF, MyCl<TT *> Source::*m) { switch (SF.getKind()) { case 1: return; case 2: break; case 3: case 4: return; }; if (b) { auto &y = const_cast<MyCl<TT *> &>(SF.*m); // expected-warning 0-1{{extension}} } } int Source::getKind() const { foo(*this, &Source::m); return 0; } } namespace test_recovery { // Test that jump scope checking recovers when there are unspecified errors // in the function declaration or body. void test(nexist, int c) { // expected-error {{}} nexist_fn(); // expected-error {{}} goto nexist_label; // expected-error {{use of undeclared label}} goto a0; // expected-error {{cannot jump}} int a = 0; // expected-note {{jump bypasses variable initialization}} a0:; switch (c) { case $: // expected-error {{}} case 0: int x = 56; // expected-note {{jump bypasses variable initialization}} case 1: // expected-error {{cannot jump}} x = 10; } } } namespace seh { // Jumping into SEH try blocks is not permitted. void jump_into_except() { goto into_try_except_try; // expected-error {{cannot jump from this goto statement to its label}} __try { // expected-note {{jump bypasses initialization of __try block}} into_try_except_try: ; } __except(0) { } goto into_try_except_except; // expected-error {{cannot jump from this goto statement to its label}} __try { } __except(0) { // expected-note {{jump bypasses initialization of __except block}} into_try_except_except: ; } } void jump_into_finally() { goto into_try_except_try; // expected-error {{cannot jump from this goto statement to its label}} __try { // expected-note {{jump bypasses initialization of __try block}} into_try_except_try: ; } __finally { } goto into_try_except_finally; // expected-error {{cannot jump from this goto statement to its label}} __try { } __finally { // expected-note {{jump bypasses initialization of __finally block}} into_try_except_finally: ; } } // Jumping out of SEH try blocks ok in general. (Jumping out of a __finally // has undefined behavior.) void jump_out_of_except() { __try { goto out_of_except_try; } __except(0) { } out_of_except_try: ; __try { } __except(0) { goto out_of_except_except; } out_of_except_except: ; } void jump_out_of_finally() { __try { goto out_of_finally_try; } __finally { } out_of_finally_try: ; __try { } __finally { goto out_of_finally_finally; // expected-warning {{jump out of __finally block has undefined behavior}} } __try { } __finally { goto *&&out_of_finally_finally; // expected-warning {{jump out of __finally block has undefined behavior}} } out_of_finally_finally: ; } // Jumping between protected scope and handler is not permitted. void jump_try_except() { __try { goto from_try_to_except; // expected-error {{cannot jump from this goto statement to its label}} } __except(0) { // expected-note {{jump bypasses initialization of __except block}} from_try_to_except: ; } __try { // expected-note {{jump bypasses initialization of __try block}} from_except_to_try: ; } __except(0) { goto from_except_to_try; // expected-error {{cannot jump from this goto statement to its label}} } } void jump_try_finally() { __try { goto from_try_to_finally; // expected-error {{cannot jump from this goto statement to its label}} } __finally { // expected-note {{jump bypasses initialization of __finally block}} from_try_to_finally: ; } __try { // expected-note {{jump bypasses initialization of __try block}} from_finally_to_try: ; } __finally { goto from_finally_to_try; // expected-error {{cannot jump from this goto statement to its label}} expected-warning {{jump out of __finally block has undefined behavior}} } } void nested() { // These are not permitted. __try { __try { } __finally { goto outer_except; // expected-error {{cannot jump from this goto statement to its label}} } } __except(0) { // expected-note {{jump bypasses initialization of __except bloc}} outer_except: ; } __try { __try{ } __except(0) { goto outer_finally; // expected-error {{cannot jump from this goto statement to its label}} } } __finally { // expected-note {{jump bypasses initialization of __finally bloc}} outer_finally: ; } // These are permitted. __try { __try { } __finally { goto after_outer_except; // expected-warning {{jump out of __finally block has undefined behavior}} } } __except(0) { } after_outer_except: ; __try { __try{ } __except(0) { goto after_outer_finally; } } __finally { } after_outer_finally: ; } // This section is academic, as MSVC doesn't support indirect gotos. void indirect_jumps(void **ip) { static void *ips[] = { &&l }; __try { // expected-note {{jump exits __try block}} // FIXME: Should this be allowed? Jumping out of the guarded section of a // __try/__except doesn't require unwinding. goto *ip; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}} } __except(0) { } __try { } __except(0) { // expected-note {{jump exits __except block}} // FIXME: What about here? goto *ip; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}} } __try { // expected-note {{jump exits __try block}} goto *ip; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}} } __finally { } __try { } __finally { // expected-note {{jump exits __finally block}} goto *ip; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}} } l: // expected-note 4 {{possible target of indirect goto statement}} ; } } // namespace seh
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/err_init_conversion_failed.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s void test0() { char variable = (void)0; // expected-error@-1{{cannot initialize a variable}} } void test1(int x = (void)0) {} // expected-error@-1{{cannot initialize a parameter}} // expected-note@-2{{here}} int test2() { return (void)0; // expected-error@-1{{cannot initialize return object}} } struct S4 { S4() : x((void)0) {}; // expected-error@-1{{cannot initialize a member subobject}} int x; }; void test5() { int foo[2] = {1, (void)0}; // expected-error@-1{{cannot initialize an array element}} } void test6() { new int((void)0); // expected-error@-1{{cannot initialize a new value}} } typedef short short2 __attribute__ ((__vector_size__ (2))); void test10() { short2 V = { (void)0 }; // expected-error@-1{{cannot initialize a vector element}} } typedef float float2 __attribute__((ext_vector_type(2))); typedef float float4 __attribute__((ext_vector_type(4))); void test14(const float2 in, const float2 out) { const float4 V = (float4){ in, out }; // expected-error@-1{{cannot initialize a compound literal initializer}} } namespace template_test { class S { public: void foo(int); }; template <class P> struct S2 { void (P::*a)(const int &); }; void test_15() { S2<S> X = {&S::foo}; // expected-error-re@-1{{cannot initialize a member subobject of type 'void (template_test::S::*)(const int &){{( __attribute__\(\(thiscall\)\))?}}' with an rvalue of type 'void (template_test::S::*)(int){{( __attribute__\(\(thiscall\)\))?}}': type mismatch at 1st parameter ('const int &' vs 'int')}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/for-range-unused.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wunused // PR9968: We used to warn that __range is unused in a dependent for-range. template <typename T> struct Vector { void doIt() { int a; // expected-warning {{unused variable 'a'}} for (auto& e : elements) // expected-warning {{unused variable 'e'}} ; } T elements[10]; }; int main(int, char**) { Vector<int> vector; vector.doIt(); // expected-note {{here}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/nested-name-spec.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify -fblocks %s namespace A { struct C { static int cx; static int cx2; static int Ag1(); static int Ag2(); }; int ax; // expected-note {{'ax' declared here}} void Af(); } A:: ; // expected-error {{expected unqualified-id}} ::A::ax::undef ex3; // expected-error {{'ax' is not a class, namespace, or enumeration}} A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} int A::C::Ag1() { return 0; } static int A::C::Ag2() { return 0; } // expected-error{{'static' can}} int A::C::cx = 17; static int A::C::cx2 = 17; // expected-error{{'static' can}} class C2 { void m(); // expected-note{{member declaration does not match because it is not const qualified}} void f(const int& parm); // expected-note{{type of 1st parameter of member declaration does not match definition ('const int &' vs 'int')}} void f(int) const; // expected-note{{member declaration does not match because it is const qualified}} void f(float); int x; }; void C2::m() const { } // expected-error{{out-of-line definition of 'm' does not match any declaration in 'C2'}} void C2::f(int) { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'C2'}} void C2::m() { x = 0; } namespace B { void ::A::Af() {} // expected-error {{cannot define or redeclare 'Af' here because namespace 'B' does not enclose namespace 'A'}} } void f1() { void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}} void (^x)() = ^{ void A::Af(); }; // expected-error {{definition or redeclaration of 'Af' not allowed inside a block}} } void f2() { A:: ; // expected-error {{expected unqualified-id}} A::C::undef = 0; // expected-error {{no member named 'undef'}} ::A::C::cx = 0; int x = ::A::ax = A::C::cx; x = sizeof(A::C); x = sizeof(::A::C::cx); } A::C c1; struct A::C c2; struct S : public A::C {}; struct A::undef; // expected-error {{no struct named 'undef' in namespace 'A'}} namespace A2 { typedef int INT; struct RC; struct CC { struct NC; }; } struct A2::RC { INT x; }; struct A2::CC::NC { void m() {} }; void f3() { N::x = 0; // expected-error {{use of undeclared identifier 'N'}} // FIXME: Consider including the kind of entity that 'N' is ("variable 'N' // declared here", "template 'X' declared here", etc) to help explain what it // is if it's 'not a class, namespace, or scoped enumeration'. int N; // expected-note {{'N' declared here}} N::x = 0; // expected-error {{'N' is not a class, namespace, or enumeration}} { int A; A::ax = 0; } { typedef int A; A::ax = 0; } // expected-error{{'A' (aka 'int') is not a class, namespace, or enumeration}} { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}} { typedef A::C A; A::cx = 0; } } // make sure the following doesn't hit any asserts void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} typedef void C2::f5(int); // expected-error{{typedef declarator cannot be qualified}} void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualified}} int A2::RC::x; // expected-error{{non-static data member defined out-of-line}} void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}} namespace E { int X = 5; namespace Nested { enum E { X = 0 }; int f() { return E::X; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} } } } class Operators { Operators operator+(const Operators&) const; // expected-note{{member declaration does not match because it is const qualified}} operator bool(); }; Operators Operators::operator+(const Operators&) { // expected-error{{out-of-line definition of 'operator+' does not match any declaration in 'Operators'}} Operators ops; return ops; } Operators Operators::operator+(const Operators&) const { Operators ops; return ops; } Operators::operator bool() { return true; } namespace A { void g(int&); // expected-note{{type of 1st parameter of member declaration does not match definition ('int &' vs 'const int &')}} } void A::f() {} // expected-error-re{{out-of-line definition of 'f' does not match any declaration in namespace 'A'{{$}}}} void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}} struct Struct { }; void Struct::f() { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'Struct'}} void global_func(int); void global_func2(int); namespace N { void ::global_func(int) { } // expected-error{{definition or redeclaration of 'global_func' cannot name the global scope}} void f(); // FIXME: if we move this to a separate definition of N, things break! } void ::global_func2(int) { } // expected-warning{{extra qualification on member 'global_func2'}} void N::f() { } // okay struct Y; // expected-note{{forward declaration of 'Y'}} Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}} X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} struct foo_S { static bool value; }; bool (foo_S::value); namespace somens { struct a { }; // expected-note{{candidate constructor (the implicit copy constructor)}} } template <typename T> class foo { }; // PR4452 / PR4451 foo<somens:a> a2; // expected-error {{unexpected ':' in nested name specifier}} somens::a a3 = a2; // expected-error {{no viable conversion}} // typedefs and using declarations. namespace test1 { namespace ns { class Counter { public: static int count; }; typedef Counter counter; } using ns::counter; class Test { void test1() { counter c; c.count++; counter::count++; } }; } // We still need to do lookup in the lexical scope, even if we push a // non-lexical scope. namespace test2 { namespace ns { extern int *count_ptr; } namespace { int count = 0; } int *ns::count_ptr = &count; } // PR6259, invalid case namespace test3 { class A; // expected-note {{forward declaration}} void foo(const char *path) { A::execute(path); // expected-error {{incomplete type 'test3::A' named in nested name specifier}} } } namespace PR7133 { namespace A { class Foo; } namespace A { namespace B { bool foo(Foo &); } } bool A::B::foo(Foo &) { return false; } } class CLASS { void CLASS::foo2(); // expected-error {{extra qualification on member 'foo2'}} }; namespace PR8159 { class B { }; class A { int A::a; // expected-error{{extra qualification on member 'a'}} static int A::b; // expected-error{{extra qualification on member 'b'}} int ::c; // expected-error{{non-friend class member 'c' cannot have a qualified name}} }; } namespace rdar7980179 { class A { void f0(); }; // expected-note {{previous}} int A::f0() {} // expected-error {{return type of out-of-line definition of 'rdar7980179::A::f0' differs}} } namespace alias = A; double *dp = (alias::C*)0; // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'alias::C *'}} // http://llvm.org/PR10109 namespace PR10109 { template<typename T> struct A { protected: struct B; struct B::C; // expected-error {{requires a template parameter list}} \ // expected-error {{no struct named 'C'}} \ // expected-error{{non-friend class member 'C' cannot have a qualified name}} }; template<typename T> struct A2 { protected: struct B; }; template <typename T> struct A2<T>::B::C; // expected-error {{no struct named 'C'}} } namespace PR13033 { namespace NS { int a; // expected-note {{'NS::a' declared here}} int longer_b; //expected-note {{'NS::longer_b' declared here}} } // Suggest adding a namespace qualifier to both variable names even though one // is only a single character long. int foobar = a + longer_b; // expected-error {{use of undeclared identifier 'a'; did you mean 'NS::a'?}} \ // expected-error {{use of undeclared identifier 'longer_b'; did you mean 'NS::longer_b'?}} } // <rdar://problem/13853540> namespace N { struct X { }; namespace N { struct Foo { struct N::X *foo(); // expected-error{{no struct named 'X' in namespace 'N::N'}} }; } } namespace TypedefNamespace { typedef int F; }; TypedefNamespace::F::NonexistentName BadNNSWithCXXScopeSpec; // expected-error {{'F' (aka 'int') is not a class, namespace, or enumeration}} namespace PR18587 { struct C1 { int a, b, c; typedef int C2; struct B1 { struct B2 { int a, b, c; }; }; }; struct C2 { static const unsigned N1 = 1; }; struct B1 { enum E1 { B2 = 2 }; static const int B3 = 3; }; const int N1 = 2; // Function declarators struct S1a { int f(C1::C2); }; struct S1b { int f(C1:C2); }; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} struct S2a { C1::C2 f(C1::C2); }; struct S2c { C1::C2 f(C1:C2); // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; struct S3a { int f(C1::C2), C2 : N1; int g : B1::B2; }; struct S3b { int g : B1:B2; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; // Inside square brackets struct S4a { int f[C2::N1]; }; struct S4b { int f[C2:N1]; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; struct S5a { int f(int xx[B1::B3 ? C2::N1 : B1::B2]); }; struct S5b { int f(int xx[B1::B3 ? C2::N1 : B1:B2]); // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; struct S5c { int f(int xx[B1:B3 ? C2::N1 : B1::B2]); // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; // Bit fields struct S6a { C1::C2 m1 : B1::B2; }; struct S6c { C1::C2 m1 : B1:B2; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; struct S6d { int C2:N1; }; struct S6e { static const int N = 3; B1::E1 : N; }; struct S6g { C1::C2 : B1:B2; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} B1::E1 : B1:B2; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; // Template parameters template <int N> struct T1 { int a,b,c; static const unsigned N1 = N; typedef unsigned C1; }; T1<C2::N1> var_1a; T1<C2:N1> var_1b; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} template<int N> int F() {} int (*X1)() = (B1::B2 ? F<1> : F<2>); int (*X2)() = (B1:B2 ? F<1> : F<2>); // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} // Bit fields + templates struct S7a { T1<B1::B2>::C1 m1 : T1<B1::B2>::N1; }; struct S7b { T1<B1:B2>::C1 m1 : T1<B1::B2>::N1; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; struct S7c { T1<B1::B2>::C1 m1 : T1<B1:B2>::N1; // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} }; } namespace PR16951 { namespace ns { enum an_enumeration { ENUMERATOR // expected-note{{'ENUMERATOR' declared here}} }; } int x1 = ns::an_enumeration::ENUMERATOR; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} int x2 = ns::an_enumeration::ENUMERATOR::vvv; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} \ // expected-error{{'ENUMERATOR' is not a class, namespace, or enumeration}} \ int x3 = ns::an_enumeration::X; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} \ // expected-error{{no member named 'X'}} enum enumerator_2 { ENUMERATOR_2 }; int x4 = enumerator_2::ENUMERATOR_2; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} int x5 = enumerator_2::X2; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} \ // expected-error{{no member named 'X2' in 'PR16951::enumerator_2'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/extern-c.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s namespace test1 { extern "C" { void test1_f() { void test1_g(int); } } } int test1_g(int); namespace test2 { extern "C" { void test2_f() { extern int test2_x; // expected-note {{declared with C language linkage here}} } } } float test2_x; // expected-error {{declaration of 'test2_x' in global scope conflicts with declaration with C language linkage}} namespace test3 { extern "C" { void test3_f() { extern int test3_b; // expected-note {{previous declaration is here}} } } extern "C" { float test3_b; // expected-error {{redefinition of 'test3_b' with a different type: 'float' vs 'int'}} } } namespace N { extern "C" { void test4_f() { extern int test4_b; // expected-note {{declared with C language linkage here}} } } } static float test4_b; // expected-error {{declaration of 'test4_b' in global scope conflicts with declaration with C language linkage}} extern "C" { void test4c_f() { extern int test4_c; // expected-note {{previous}} } } static float test4_c; // expected-error {{redefinition of 'test4_c' with a different type: 'float' vs 'int'}} namespace N { extern "C" { void test5_f() { extern int test5_b; // expected-note {{declared with C language linkage here}} } } } extern "C" { static float test5_b; // expected-error {{declaration of 'test5_b' in global scope conflicts with declaration with C language linkage}} } extern "C" { void test5c_f() { extern int test5_c; // expected-note {{previous}} } } extern "C" { static float test5_c; // expected-error {{redefinition of 'test5_c' with a different type: 'float' vs 'int'}} } extern "C" { void f() { extern int test6_b; } } namespace foo { extern "C" { static float test6_b; extern float test6_b; } } namespace linkage { namespace redecl { extern "C" { static void linkage_redecl(); static void linkage_redecl(int); void linkage_redecl(); // ok, still not extern "C" void linkage_redecl(int); // ok, still not extern "C" void linkage_redecl(float); // expected-note {{previous}} void linkage_redecl(double); // expected-error {{conflicting types}} } } namespace from_outer { void linkage_from_outer_1(); // expected-note {{previous}} void linkage_from_outer_2(); // expected-note {{previous}} extern "C" { void linkage_from_outer_1(int); void linkage_from_outer_1(); // expected-error {{different language linkage}} void linkage_from_outer_2(); // expected-error {{different language linkage}} } } namespace mixed { extern "C" { void linkage_mixed_1(); static void linkage_mixed_1(int); static void linkage_mixed_2(int); void linkage_mixed_2(); } } namespace across_scopes { namespace X { extern "C" void linkage_across_scopes_f() { void linkage_across_scopes_g(); // expected-note {{previous}} } } namespace Y { extern "C" void linkage_across_scopes_g(int); // expected-error {{conflicting}} } } } int lookup_in_global_f; // expected-note {{here}} namespace lookup_in_global { void lookup_in_global_f(); void lookup_in_global_g(); extern "C" { void lookup_in_global_f(int); // expected-error {{conflicts with declaration in global scope}} void lookup_in_global_g(int); // expected-note {{here}} } } int lookup_in_global_g; // expected-error {{conflicts with declaration with C language linkage}} namespace N1 { extern "C" int different_kind_1; // expected-note {{here}} extern "C" void different_kind_2(); // expected-note {{here}} } namespace N2 { extern "C" void different_kind_1(); // expected-error {{different kind of symbol}} extern "C" int different_kind_2; // expected-error {{different kind of symbol}} } // We allow all these even though the standard says they are ill-formed. extern "C" { struct stat {}; // expected-warning{{empty struct has size 0 in C, size 1 in C++}} void stat(struct stat); } namespace X { extern "C" { void stat(struct ::stat); } } int stat(int *p); void global_fn_vs_extern_c_var_1(); namespace X { extern "C" int global_fn_vs_extern_c_var_1; extern "C" int global_fn_vs_extern_c_var_2; } void global_fn_vs_extern_c_var_2(); void global_fn_vs_extern_c_fn_1(); namespace X { extern "C" int global_fn_vs_extern_c_fn_1(int); extern "C" int global_fn_vs_extern_c_fn_2(int); } void global_fn_vs_extern_c_fn_2(); extern "C" void name_with_using_decl_1(int); namespace using_decl { void name_with_using_decl_1(); void name_with_using_decl_2(); void name_with_using_decl_3(); } using using_decl::name_with_using_decl_1; using using_decl::name_with_using_decl_2; extern "C" void name_with_using_decl_2(int); extern "C" void name_with_using_decl_3(int); using using_decl::name_with_using_decl_3; // We do not allow a global variable and an extern "C" function to have the same // name, because such entities may have the same mangled name. int global_var_vs_extern_c_fn_1; // expected-note {{here}} namespace X { extern "C" void global_var_vs_extern_c_fn_1(); // expected-error {{conflicts with declaration in global scope}} extern "C" void global_var_vs_extern_c_fn_2(); // expected-note {{here}} } int global_var_vs_extern_c_fn_2; // expected-error {{conflicts with declaration with C language linkage}} int global_var_vs_extern_c_var_1; // expected-note {{here}} namespace X { extern "C" double global_var_vs_extern_c_var_1; // expected-error {{conflicts with declaration in global scope}} extern "C" double global_var_vs_extern_c_var_2; // expected-note {{here}} } int global_var_vs_extern_c_var_2; // expected-error {{conflicts with declaration with C language linkage}} template <class T> struct pr5065_n1 {}; extern "C" { union pr5065_1 {}; // expected-warning{{empty union has size 0 in C, size 1 in C++}} struct pr5065_2 { int: 0; }; // expected-warning{{struct has size 0 in C, size 1 in C++}} struct pr5065_3 {}; // expected-warning{{empty struct has size 0 in C, size 1 in C++}} struct pr5065_4 { // expected-warning{{empty struct has size 0 in C, size 1 in C++}} struct Inner {}; // expected-warning{{empty struct has size 0 in C, size 1 in C++}} }; // These should not warn class pr5065_n3 {}; pr5065_n1<int> pr5065_v; struct pr5065_n4 { void m() {} }; struct pr5065_n5 : public pr5065_3 {}; struct pr5065_n6 : public virtual pr5065_3 {}; } struct pr5065_n7 {};
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx0x-constexpr-const.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s constexpr int x = 1; // expected-note {{variable 'x' declared const here}} constexpr int id(int x) { return x; } void foo(void) { x = 2; // expected-error {{cannot assign to variable 'x' with const-qualified type 'const int'}} int (*idp)(int) = id; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/for-range-no-std.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions struct S { int *begin(); int *end(); }; struct T { }; struct Range {}; int begin(Range); // expected-note {{not viable}} int end(Range); namespace NS { struct ADL {}; struct iter { int operator*(); bool operator!=(iter); void operator++(); }; iter begin(ADL); // expected-note {{not viable}} iter end(ADL); struct NoADL {}; } NS::iter begin(NS::NoADL); // expected-note {{not viable}} NS::iter end(NS::NoADL); void f() { int a[] = {1, 2, 3}; for (auto b : S()) {} // ok for (auto b : T()) {} // expected-error {{invalid range expression of type 'T'}} for (auto b : a) {} // ok for (int b : NS::ADL()) {} // ok for (int b : NS::NoADL()) {} // expected-error {{invalid range expression of type 'NS::NoADL'}} } void PR11601() { void (*vv[])() = {PR11601, PR11601, PR11601}; for (void (*i)() : vv) i(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx0x-class.cpp
// RUN: %clang_cc1 -Wno-uninitialized -fsyntax-only -verify -std=c++11 -Wno-error=static-float-init %s int vs = 0; class C { public: struct NestedC { NestedC(int); }; int i = 0; static int si = 0; // expected-error {{non-const static data member must be initialized out of line}} static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}} static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}} static const int vi = 0; static const volatile int cvi = 0; // expected-error {{static const volatile data member must be initialized out of line}} }; namespace rdar8367341 { float foo(); // expected-note {{here}} struct A { static const float x = 5.0f; // expected-warning {{requires 'constexpr'}} expected-note {{add 'constexpr'}} static const float y = foo(); // expected-warning {{requires 'constexpr'}} expected-note {{add 'constexpr'}} static constexpr float x2 = 5.0f; static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}} }; } namespace Foo { // Regression test -- forward declaration of Foo should not cause error about // nonstatic data member. class Foo; class Foo { int x; int y = x; }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx98-compat.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify %s -DCXX14COMPAT namespace std { struct type_info; using size_t = decltype(sizeof(0)); // expected-warning {{decltype}} expected-warning {{alias}} template<typename T> struct initializer_list { initializer_list(T*, size_t); T *p; size_t n; T *begin(); T *end(); }; } template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}} class Variadic1 {}; template<template<typename> class ...T> // expected-warning {{variadic templates are incompatible with C++98}} class Variadic2 {}; template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}} class Variadic3 {}; alignas(8) int with_alignas; // expected-warning {{'alignas' is incompatible with C++98}} int with_attribute [[ ]]; // expected-warning {{C++11 attribute syntax is incompatible with C++98}} void Literals() { (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}} (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}} (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}} (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}} (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}} (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} } template<typename T> struct S {}; namespace TemplateParsing { S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}} S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}} } void Lambda() { []{}(); // expected-warning {{lambda expressions are incompatible with C++98}} } struct Ctor { Ctor(int, char); Ctor(double, long); }; struct InitListCtor { InitListCtor(std::initializer_list<bool>); }; int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} S<int> s = {}; // ok, aggregate s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} std::initializer_list<int> xs = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} auto ys = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} \ // expected-warning {{'auto' type specifier is incompatible with C++98}} Ctor c1 = { 1, 2 }; // expected-warning {{constructor call from initializer list is incompatible with C++98}} Ctor c2 = { 3.0, 4l }; // expected-warning {{constructor call from initializer list is incompatible with C++98}} InitListCtor ilc = { true, false }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} const int &r = { 0 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} struct { int a; const int &r; } rr = { 0, {0} }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} expected-warning {{scalar}} } struct DelayedDefaultArgumentParseInitList { void f(int i = {1}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} expected-warning {{scalar}} } }; int operator"" _hello(const char *); // expected-warning {{literal operators are incompatible with C++98}} enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}} }; enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}} }; void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}} struct Defaulted { Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}} }; int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}} struct RefQualifier { void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}} }; auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}} void RangeFor() { int xs[] = {1, 2, 3}; for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}} } for (auto &b : {1, 2, 3}) { // expected-warning@-1 {{range-based for loop is incompatible with C++98}} // expected-warning@-2 {{'auto' type specifier is incompatible with C++98}} // expected-warning@-3 {{initialization of initializer_list object is incompatible with C++98}} // expected-warning@-4 {{reference initialized from initializer list is incompatible with C++98}} } struct Agg { int a, b; } const &agg = { 1, 2 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} } struct InClassInit { int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}} }; struct OverrideControlBase { virtual void f(); virtual void g(); }; struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}} virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}} virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}} }; using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}} template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}} inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}} } auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}} int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}} const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}} char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}} char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}} constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}} decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}} __decltype(const_expr) decl_type2 = 0; // ok void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}} bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}} void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}} struct InhCtorBase { InhCtorBase(int); }; struct InhCtorDerived : InhCtorBase { using InhCtorBase::InhCtorBase; // expected-warning {{inheriting constructors are incompatible with C++98}} }; struct FriendMember { static void MemberFn(); friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}} }; struct DelegCtor { DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}} DelegCtor(); }; template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}} template<typename T> int TemplateFn(T) { return 0; } void LocalTemplateArg() { struct S {}; TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} } struct {} obj_of_unnamed_type; // expected-note {{here}} int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} namespace RedundantParensInAddressTemplateParam { int n; template<int*p> struct S {}; S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} } namespace TemplateSpecOutOfScopeNs { template<typename T> struct S {}; // expected-note {{here}} } template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}} struct Typename { template<typename T> struct Inner {}; }; typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}} Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}} struct TrivialButNonPOD { int f(int); private: int k; }; void Ellipsis(int n, ...); void TrivialButNonPODThroughEllipsis() { Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}} } struct HasExplicitConversion { explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}} }; struct Struct {}; enum Enum { enum_val = 0 }; struct BadFriends { friend enum ::Enum; // expected-warning {{befriending enumeration type 'enum ::Enum' is incompatible with C++98}} friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}} friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}} }; int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} class PrivateMember { struct ImPrivate {}; }; template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}} return typename T::ImPrivate(); } int SFINAEAccessControl(...) { return 0; } int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); // expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}} namespace UnionOrAnonStructMembers { struct NonTrivCtor { NonTrivCtor(); // expected-note 2{{user-provided default constructor}} }; struct NonTrivCopy { NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-provided copy constructor}} }; struct NonTrivDtor { ~NonTrivDtor(); // expected-note 2{{user-provided destructor}} }; union BadUnion { NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial constructor is incompatible with C++98}} NonTrivCopy ntcp; // expected-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}} NonTrivDtor ntd; // expected-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}} }; struct Wrap { struct { NonTrivCtor ntc; // expected-warning {{anonymous struct member 'ntc' with a non-trivial constructor is incompatible with C++98}} NonTrivCopy ntcp; // expected-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}} NonTrivDtor ntd; // expected-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}} }; }; union WithStaticDataMember { static constexpr double d = 0.0; // expected-warning {{static data member 'd' in union is incompatible with C++98}} expected-warning {{'constexpr' specifier is incompatible with C++98}} static const int n = 0; // expected-warning {{static data member 'n' in union is incompatible with C++98}} static int k; // expected-warning {{static data member 'k' in union is incompatible with C++98}} }; } int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}} template<typename T> void EnumNNSFn() { int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}} }; template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}} void JumpDiagnostics(int n) { goto DirectJump; // expected-warning {{jump from this goto statement to its label is incompatible with C++98}} TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}} DirectJump: void *Table[] = {&&DirectJump, &&Later}; goto *Table[n]; // expected-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++98}} TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}} Later: // expected-note {{possible target of indirect goto statement}} switch (n) { TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}} default: // expected-warning {{jump from switch statement to this case label is incompatible with C++98}} return; } } namespace UnevaluatedMemberAccess { struct S { int n; int f() { return sizeof(S::n); } // ok }; int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}} const std::type_info &ti = typeid(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}} } namespace LiteralUCNs { char c1 = '\u001e'; // expected-warning {{universal character name referring to a control character is incompatible with C++98}} wchar_t c2 = L'\u0041'; // expected-warning {{specifying character 'A' with a universal character name is incompatible with C++98}} const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}} const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}} } namespace NonTypeTemplateArgs { template<typename T, T v> struct S {}; const int k = 5; // expected-note {{here}} static void f() {} // expected-note {{here}} S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}} S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}} } namespace NullPointerTemplateArg { struct A {}; template<int*> struct X {}; template<int A::*> struct Y {}; X<(int*)0> x; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}} Y<(int A::*)0> y; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}} } namespace PR13480 { struct basic_iterator { basic_iterator(const basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-provided copy constructor}} basic_iterator(basic_iterator &it) {} }; union test { basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}} }; } namespace AssignOpUnion { struct a { void operator=(const a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-provided copy assignment operator}} void operator=(a &it) {} }; struct b { void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-provided copy assignment operator}} }; union test1 { a x; // expected-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}} b y; // expected-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}} }; } namespace rdar11736429 { struct X { // expected-note {{because type 'rdar11736429::X' has no default constructor}} X(const X&) = delete; // expected-warning{{deleted function definitions are incompatible with C++98}} \ // expected-note {{implicit default constructor suppressed by user-declared constructor}} }; union S { X x; // expected-warning{{union member 'x' with a non-trivial constructor is incompatible with C++98}} }; } template<typename T> T var = T(10); #ifdef CXX14COMPAT // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}} #else // expected-warning@-4 {{variable templates are a C++14 extension}} #endif // No diagnostic for specializations of variable templates; we will have // diagnosed the primary template. template<typename T> T* var<T*> = new T(); template<> int var<int> = 10; template int var<int>; float fvar = var<float>; class A { template<typename T> static T var = T(10); #ifdef CXX14COMPAT // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}} #else // expected-warning@-4 {{variable templates are a C++14 extension}} #endif template<typename T> static T* var<T*> = new T(); }; struct B { template<typename T> static T v; }; #ifdef CXX14COMPAT // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}} #else // expected-warning@-4 {{variable templates are a C++14 extension}} #endif template<typename T> T B::v = T(); #ifdef CXX14COMPAT // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}} #else // expected-warning@-4 {{variable templates are a C++14 extension}} #endif template<typename T> T* B::v<T*> = new T(); template<> int B::v<int> = 10; template int B::v<int>; float fsvar = B::v<float>; #ifdef CXX14COMPAT int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++14}} #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/unary-real-imag.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A {}; int i = __real__ A(); // expected-error {{invalid type 'A' to __real operator}} int j = __imag__ A(); // expected-error {{invalid type 'A' to __imag operator}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/const-cast.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A {}; // See if aliasing can confuse this baby. typedef char c; typedef c *cp; typedef cp *cpp; typedef cpp *cppp; typedef cppp &cpppr; typedef const cppp &cpppcr; typedef const char cc; typedef cc *ccp; typedef volatile ccp ccvp; typedef ccvp *ccvpp; typedef const volatile ccvpp ccvpcvp; typedef ccvpcvp *ccvpcvpp; typedef int iar[100]; typedef iar &iarr; typedef int (*f)(int); char ***good_const_cast_test(ccvpcvpp var) { // Cast away deep consts and volatiles. char ***var2 = const_cast<cppp>(var); char ***const &var3 = var2; // Const reference to reference. char ***&var4 = const_cast<cpppr>(var3); // Drop reference. Intentionally without qualifier change. char *** var5 = const_cast<cppp>(var4); // Const array to array reference. const int ar[100] = {0}; int (&rar)[100] = const_cast<iarr>(ar); // Array decay. Intentionally without qualifier change. int *pi = const_cast<int*>(ar); f fp = 0; // Don't misidentify fn** as a function pointer. f *fpp = const_cast<f*>(&fp); int const A::* const A::*icapcap = 0; int A::* A::* iapap = const_cast<int A::* A::*>(icapcap); (void)const_cast<A&&>(A()); // expected-warning {{C++11}} return var4; } short *bad_const_cast_test(char const *volatile *const volatile *var) { // Different pointer levels. char **var2 = const_cast<char**>(var); // expected-error {{const_cast from 'const char *volatile *const volatile *' to 'char **' is not allowed}} // Different final type. short ***var3 = const_cast<short***>(var); // expected-error {{const_cast from 'const char *volatile *const volatile *' to 'short ***' is not allowed}} // Rvalue to reference. char ***&var4 = const_cast<cpppr>(&var2); // expected-error {{const_cast from rvalue to reference type 'cpppr'}} // Non-pointer. char v = const_cast<char>(**var2); // expected-error {{const_cast to 'char', which is not a reference, pointer-to-object, or pointer-to-data-member}} const int *ar[100] = {0}; // Not even lenient g++ accepts this. int *(*rar)[100] = const_cast<int *(*)[100]>(&ar); // expected-error {{const_cast from 'const int *(*)[100]' to 'int *(*)[100]' is not allowed}} f fp1 = 0; // Function pointers. f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}} void (A::*mfn)() = 0; (void)const_cast<void (A::*)()>(mfn); // expected-error-re {{const_cast to 'void (A::*)(){{( __attribute__\(\(thiscall\)\))?}}', which is not a reference, pointer-to-object, or pointer-to-data-member}} (void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}} expected-warning {{C++11}} return **var3; } template <typename T> char *PR21845() { return const_cast<char *>((void)T::x); } // expected-error {{const_cast from 'void' to 'char *' is not allowed}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/compound-literal.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++03 -verify -ast-dump %s > %t-03 // RUN: FileCheck --input-file=%t-03 %s // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -ast-dump %s > %t-11 // RUN: FileCheck --input-file=%t-11 %s // RUN: FileCheck --input-file=%t-11 %s --check-prefix=CHECK-CXX11 // http://llvm.org/PR7905 namespace PR7905 { struct S; // expected-note {{forward declaration}} void foo1() { (void)(S[]) {{3}}; // expected-error {{array has incomplete element type}} } template <typename T> struct M { T m; }; void foo2() { (void)(M<short> []) {{3}}; } } // Check compound literals mixed with C++11 list-initialization. namespace brace_initializers { struct POD { int x, y; }; struct HasCtor { HasCtor(int x, int y); }; struct HasDtor { int x, y; ~HasDtor(); }; struct HasCtorDtor { HasCtorDtor(int x, int y); ~HasCtorDtor(); }; void test() { (void)(POD){1, 2}; // CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'struct brace_initializers::POD' // CHECK: CompoundLiteralExpr {{.*}} 'struct brace_initializers::POD' // CHECK-NEXT: InitListExpr {{.*}} 'struct brace_initializers::POD' // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} (void)(HasDtor){1, 2}; // CHECK: CXXBindTemporaryExpr {{.*}} 'struct brace_initializers::HasDtor' // CHECK-NEXT: CompoundLiteralExpr {{.*}} 'struct brace_initializers::HasDtor' // CHECK-NEXT: InitListExpr {{.*}} 'struct brace_initializers::HasDtor' // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} #if __cplusplus >= 201103L (void)(HasCtor){1, 2}; // CHECK-CXX11-NOT: CXXBindTemporaryExpr {{.*}} 'struct brace_initializers::HasCtor' // CHECK-CXX11: CompoundLiteralExpr {{.*}} 'struct brace_initializers::HasCtor' // CHECK-CXX11-NEXT: CXXTemporaryObjectExpr {{.*}} 'struct brace_initializers::HasCtor' // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 1{{$}} // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 2{{$}} (void)(HasCtorDtor){1, 2}; // CHECK-CXX11: CXXBindTemporaryExpr {{.*}} 'struct brace_initializers::HasCtorDtor' // CHECK-CXX11-NEXT: CompoundLiteralExpr {{.*}} 'struct brace_initializers::HasCtorDtor' // CHECK-CXX11-NEXT: CXXTemporaryObjectExpr {{.*}} 'struct brace_initializers::HasCtorDtor' // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 1{{$}} // CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 2{{$}} #endif } struct PrivateDtor { int x, y; private: ~PrivateDtor(); // expected-note {{declared private here}} }; void testPrivateDtor() { (void)(PrivateDtor){1, 2}; // expected-error {{temporary of type 'brace_initializers::PrivateDtor' has private destructor}} } } // This doesn't necessarily need to be an error, but CodeGen can't handle it // at the moment. int PR17415 = (int){PR17415}; // expected-error {{initializer element is not a compile-time constant}} // Make sure we accept this. (Not sure if we actually should... but we do // at the moment.) template<unsigned> struct Value { }; template<typename T> int &check_narrowed(Value<sizeof((T){1.1})>);
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s template<int z> int test9(int *a) { a = (int *) __builtin_assume_aligned(a, z + 1); // expected-error {{requested alignment is not a power of 2}} return a[0]; } void test9i(int *a) { test9<42>(a); // expected-note {{in instantiation of function template specialization 'test9<42>' requested here}} } template<typename T> int test10(int *a, T z) { a = (int *) __builtin_assume_aligned(a, z + 1); // expected-error {{must be a constant integer}} return a[0]; } int test10i(int *a) { return test10(a, 42); // expected-note {{in instantiation of function template specialization 'test10<int>' requested here}} } template <int q> void *atest() __attribute__((assume_aligned(q))); // expected-error {{requested alignment is not a power of 2}} template <int q, int o> void *atest2() __attribute__((assume_aligned(q, o))); // expected-error {{requested alignment is not a power of 2}} void test20() { atest<31>(); // expected-note {{in instantiation of function template specialization 'atest<31>' requested here}} atest<32>(); atest2<31, 5>(); // expected-note {{in instantiation of function template specialization 'atest2<31, 5>' requested here}} atest2<32, 4>(); } // expected-error@+1 {{invalid application of 'sizeof' to a function type}} template<typename T> __attribute__((assume_aligned(sizeof(int(T()))))) T *f(); void test21() { void *p = f<void>(); // expected-note {{in instantiation of function template specialization 'f<void>' requested here}} } // expected-error@+1 {{functional-style cast from 'void' to 'int' is not allowed}} template<typename T> __attribute__((assume_aligned(sizeof((int(T())))))) T *g(); void test23() { void *p = g<void>(); // expected-note {{in instantiation of function template specialization 'g<void>' requested here}} } template <typename T, int o> T *atest3() __attribute__((assume_aligned(31, o))); // expected-error {{requested alignment is not a power of 2}} template <typename T, int o> T *atest4() __attribute__((assume_aligned(32, o))); void test22() { atest3<int, 5>(); atest4<int, 5>(); } // expected-warning@+1 {{'assume_aligned' attribute only applies to functions and methods}} class __attribute__((assume_aligned(32))) x { int y; }; // expected-warning@+1 {{'assume_aligned' attribute only applies to return values that are pointers or references}} x foo() __attribute__((assume_aligned(32))); struct s1 { static const int x = 32; }; struct s2 { static const int x = 64; }; struct s3 { static const int x = 63; }; template <typename X> void *atest5() __attribute__((assume_aligned(X::x))); // expected-error {{requested alignment is not a power of 2}} void test24() { atest5<s1>(); atest5<s2>(); atest5<s3>(); // expected-note {{in instantiation of function template specialization 'atest5<s3>' requested here}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/member-class-11.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s struct rdar9677163 { struct Y { ~Y(); }; struct Z { ~Z(); }; Y::~Y() { } // expected-error{{non-friend class member '~Y' cannot have a qualified name}} ~Z(); // expected-error{{expected the class name after '~' to name the enclosing class}} };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR19955.cpp
// RUN: %clang_cc1 -triple i686-win32 -verify -std=c++11 %s // RUN: %clang_cc1 -triple i686-mingw32 -verify -std=c++11 %s extern int __attribute__((dllimport)) var; constexpr int *varp = &var; // expected-error {{must be initialized by a constant expression}} extern __attribute__((dllimport)) void fun(); constexpr void (*funp)(void) = &fun; // expected-error {{must be initialized by a constant expression}} template <void (*)()> struct S {}; S<&fun> x; template <int *> struct U {}; U<&var> y;
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/builtin-assume-aligned.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -triple x86_64-linux-gnu %s int n; constexpr int *p = 0; // expected-error@+1 {{must be initialized by a constant expression}} constexpr int *k = (int *) __builtin_assume_aligned(p, 16, n = 5); constexpr void *l = __builtin_assume_aligned(p, 16); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{cast from 'void *' is not allowed in a constant expression}} constexpr int *c = (int *) __builtin_assume_aligned(p, 16); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{alignment of the base pointee object (4 bytes) is less than the asserted 16 bytes}} constexpr void *m = __builtin_assume_aligned(&n, 16); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{offset of the aligned pointer from the base pointee object (-2 bytes) is not a multiple of the asserted 4 bytes}} constexpr void *q1 = __builtin_assume_aligned(&n, 4, 2); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{offset of the aligned pointer from the base pointee object (2 bytes) is not a multiple of the asserted 4 bytes}} constexpr void *q2 = __builtin_assume_aligned(&n, 4, -2); constexpr void *q3 = __builtin_assume_aligned(&n, 4, 4); constexpr void *q4 = __builtin_assume_aligned(&n, 4, -4); static char ar1[6]; // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{alignment of the base pointee object (1 byte) is less than the asserted 16 bytes}} constexpr void *r1 = __builtin_assume_aligned(&ar1[2], 16); static char ar2[6] __attribute__((aligned(32))); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{offset of the aligned pointer from the base pointee object (2 bytes) is not a multiple of the asserted 16 bytes}} constexpr void *r2 = __builtin_assume_aligned(&ar2[2], 16); constexpr void *r3 = __builtin_assume_aligned(&ar2[2], 16, 2); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{offset of the aligned pointer from the base pointee object (1 byte) is not a multiple of the asserted 16 bytes}} constexpr void *r4 = __builtin_assume_aligned(&ar2[2], 16, 1); constexpr int* x = __builtin_constant_p((int*)0xFF) ? (int*)0xFF : (int*)0xFF; // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{value of the aligned pointer (255) is not a multiple of the asserted 32 bytes}} constexpr void *s1 = __builtin_assume_aligned(x, 32); // expected-error@+2 {{must be initialized by a constant expression}} // expected-note@+1 {{value of the aligned pointer (250) is not a multiple of the asserted 32 bytes}} constexpr void *s2 = __builtin_assume_aligned(x, 32, 5); constexpr void *s3 = __builtin_assume_aligned(x, 32, -1);
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/member-operator-expr.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s class X { public: int operator++(); operator int(); }; void test() { X x; int i; i = x.operator++(); i = x.operator int(); x.operator--(); // expected-error{{no member named 'operator--'}} x.operator float(); // expected-error{{no member named 'operator float'}} x.operator; // expected-error{{expected a type}} } void test2() { X *x; int i; i = x->operator++(); i = x->operator int(); x->operator--(); // expected-error{{no member named 'operator--'}} x->operator float(); // expected-error{{no member named 'operator float'}} x->operator; // expected-error{{expected a type}} } namespace pr13157 { class A { public: void operator()(int x, int y = 2, ...) {} }; void f() { A()(1); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/ms_mutable_reference_member.cpp
// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility struct S { mutable int &a; // expected-warning {{'mutable' on a reference type is a Microsoft extension}} S(int &b) : a(b) {} }; int main() { int a = 0; const S s(a); s.a = 10; return s.a + a; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/ms-overload-entry-point.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s template <typename T> int wmain() { // expected-error{{'wmain' cannot be a template}} return 0; } namespace { int WinMain(void) { return 0; } int WinMain(int) { return 0; } } void wWinMain(void) {} // expected-note{{previous definition is here}} void wWinMain(int) {} // expected-error{{conflicting types for 'wWinMain'}} int foo() { wmain<void>(); // expected-error{{no matching function for call to 'wmain'}} wmain<int>(); // expected-error{{no matching function for call to 'wmain'}} WinMain(); return 0; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/pragma-weak.cpp
// RUN: %clang_cc1 %s #pragma weak foo static void foo(); extern "C" { void foo() { }; } extern "C" int Test; #pragma weak test = Test
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/address-space-conversion.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // This test checks for the various conversions and casting operations // with address-space-qualified pointers. struct A { virtual ~A() {} }; struct B : A { }; typedef void *void_ptr; typedef void __attribute__((address_space(1))) *void_ptr_1; typedef void __attribute__((address_space(2))) *void_ptr_2; typedef int *int_ptr; typedef int __attribute__((address_space(1))) *int_ptr_1; typedef int __attribute__((address_space(2))) *int_ptr_2; typedef A *A_ptr; typedef A __attribute__((address_space(1))) *A_ptr_1; typedef A __attribute__((address_space(2))) *A_ptr_2; typedef B *B_ptr; typedef B __attribute__((address_space(1))) *B_ptr_1; typedef B __attribute__((address_space(2))) *B_ptr_2; void test_const_cast(int_ptr ip, int_ptr_1 ip1, int_ptr_2 ip2, A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2, const int *cip, const int __attribute__((address_space(1))) *cip1) { // Cannot use const_cast to cast between address spaces, add an // address space, or remove an address space. (void)const_cast<int_ptr>(ip1); // expected-error{{is not allowed}} (void)const_cast<int_ptr>(ip2); // expected-error{{is not allowed}} (void)const_cast<int_ptr_1>(ip); // expected-error{{is not allowed}} (void)const_cast<int_ptr_1>(ip2); // expected-error{{is not allowed}} (void)const_cast<int_ptr_2>(ip); // expected-error{{is not allowed}} (void)const_cast<int_ptr_2>(ip1); // expected-error{{is not allowed}} (void)const_cast<A_ptr>(ap1); // expected-error{{is not allowed}} (void)const_cast<A_ptr>(ap2); // expected-error{{is not allowed}} (void)const_cast<A_ptr_1>(ap); // expected-error{{is not allowed}} (void)const_cast<A_ptr_1>(ap2); // expected-error{{is not allowed}} (void)const_cast<A_ptr_2>(ap); // expected-error{{is not allowed}} (void)const_cast<A_ptr_2>(ap1); // expected-error{{is not allowed}} // It's acceptable to cast away constness. (void)const_cast<int_ptr>(cip); (void)const_cast<int_ptr_1>(cip1); } void test_static_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2, A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2, B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) { // Well-formed upcast (void)static_cast<A_ptr>(bp); (void)static_cast<A_ptr_1>(bp1); (void)static_cast<A_ptr_2>(bp2); // Well-formed downcast (void)static_cast<B_ptr>(ap); (void)static_cast<B_ptr_1>(ap1); (void)static_cast<B_ptr_2>(ap2); // Well-formed cast to/from void (void)static_cast<void_ptr>(ap); (void)static_cast<void_ptr_1>(ap1); (void)static_cast<void_ptr_2>(ap2); (void)static_cast<A_ptr>(vp); (void)static_cast<A_ptr_1>(vp1); (void)static_cast<A_ptr_2>(vp2); // Ill-formed upcasts (void)static_cast<A_ptr>(bp1); // expected-error{{is not allowed}} (void)static_cast<A_ptr>(bp2); // expected-error{{is not allowed}} (void)static_cast<A_ptr_1>(bp); // expected-error{{is not allowed}} (void)static_cast<A_ptr_1>(bp2); // expected-error{{is not allowed}} (void)static_cast<A_ptr_2>(bp); // expected-error{{is not allowed}} (void)static_cast<A_ptr_2>(bp1); // expected-error{{is not allowed}} // Ill-formed downcasts (void)static_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}} (void)static_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}} (void)static_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}} (void)static_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}} (void)static_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}} (void)static_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}} // Ill-formed cast to/from void (void)static_cast<void_ptr>(ap1); // expected-error{{is not allowed}} (void)static_cast<void_ptr>(ap2); // expected-error{{is not allowed}} (void)static_cast<void_ptr_1>(ap); // expected-error{{is not allowed}} (void)static_cast<void_ptr_1>(ap2); // expected-error{{is not allowed}} (void)static_cast<void_ptr_2>(ap); // expected-error{{is not allowed}} (void)static_cast<void_ptr_2>(ap1); // expected-error{{is not allowed}} (void)static_cast<A_ptr>(vp1); // expected-error{{casts away qualifiers}} (void)static_cast<A_ptr>(vp2); // expected-error{{casts away qualifiers}} (void)static_cast<A_ptr_1>(vp); // expected-error{{casts away qualifiers}} (void)static_cast<A_ptr_1>(vp2); // expected-error{{casts away qualifiers}} (void)static_cast<A_ptr_2>(vp); // expected-error{{casts away qualifiers}} (void)static_cast<A_ptr_2>(vp1); // expected-error{{casts away qualifiers}} } void test_dynamic_cast(A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2, B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) { // Well-formed upcast (void)dynamic_cast<A_ptr>(bp); (void)dynamic_cast<A_ptr_1>(bp1); (void)dynamic_cast<A_ptr_2>(bp2); // Well-formed downcast (void)dynamic_cast<B_ptr>(ap); (void)dynamic_cast<B_ptr_1>(ap1); (void)dynamic_cast<B_ptr_2>(ap2); // Ill-formed upcasts (void)dynamic_cast<A_ptr>(bp1); // expected-error{{casts away qualifiers}} (void)dynamic_cast<A_ptr>(bp2); // expected-error{{casts away qualifiers}} (void)dynamic_cast<A_ptr_1>(bp); // expected-error{{casts away qualifiers}} (void)dynamic_cast<A_ptr_1>(bp2); // expected-error{{casts away qualifiers}} (void)dynamic_cast<A_ptr_2>(bp); // expected-error{{casts away qualifiers}} (void)dynamic_cast<A_ptr_2>(bp1); // expected-error{{casts away qualifiers}} // Ill-formed downcasts (void)dynamic_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}} (void)dynamic_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}} (void)dynamic_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}} (void)dynamic_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}} (void)dynamic_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}} (void)dynamic_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}} } void test_reinterpret_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2, A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2, B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2, const void __attribute__((address_space(1))) *cvp1) { // reinterpret_cast can be used to cast to a different address space. (void)reinterpret_cast<A_ptr>(ap1); (void)reinterpret_cast<A_ptr>(ap2); (void)reinterpret_cast<A_ptr>(bp); (void)reinterpret_cast<A_ptr>(bp1); (void)reinterpret_cast<A_ptr>(bp2); (void)reinterpret_cast<A_ptr>(vp); (void)reinterpret_cast<A_ptr>(vp1); (void)reinterpret_cast<A_ptr>(vp2); (void)reinterpret_cast<A_ptr_1>(ap); (void)reinterpret_cast<A_ptr_1>(ap2); (void)reinterpret_cast<A_ptr_1>(bp); (void)reinterpret_cast<A_ptr_1>(bp1); (void)reinterpret_cast<A_ptr_1>(bp2); (void)reinterpret_cast<A_ptr_1>(vp); (void)reinterpret_cast<A_ptr_1>(vp1); (void)reinterpret_cast<A_ptr_1>(vp2); // ... but don't try to cast away constness! (void)reinterpret_cast<A_ptr_2>(cvp1); // expected-error{{casts away qualifiers}} } void test_cstyle_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2, A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2, B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2, const void __attribute__((address_space(1))) *cvp1) { // C-style casts are the wild west of casts. (void)(A_ptr)(ap1); (void)(A_ptr)(ap2); (void)(A_ptr)(bp); (void)(A_ptr)(bp1); (void)(A_ptr)(bp2); (void)(A_ptr)(vp); (void)(A_ptr)(vp1); (void)(A_ptr)(vp2); (void)(A_ptr_1)(ap); (void)(A_ptr_1)(ap2); (void)(A_ptr_1)(bp); (void)(A_ptr_1)(bp1); (void)(A_ptr_1)(bp2); (void)(A_ptr_1)(vp); (void)(A_ptr_1)(vp1); (void)(A_ptr_1)(vp2); (void)(A_ptr_2)(cvp1); } void test_implicit_conversion(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2, A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2, B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) { // Well-formed conversions void_ptr vpA = ap; void_ptr_1 vp_1A = ap1; void_ptr_2 vp_2A = ap2; A_ptr ap_A = bp; A_ptr_1 ap_A1 = bp1; A_ptr_2 ap_A2 = bp2; // Ill-formed conversions void_ptr vpB = ap1; // expected-error{{cannot initialize a variable of type}} void_ptr_1 vp_1B = ap2; // expected-error{{cannot initialize a variable of type}} A_ptr ap_B = bp1; // expected-error{{cannot initialize a variable of type}} A_ptr_1 ap_B1 = bp2; // expected-error{{cannot initialize a variable of type}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-missing-noreturn.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn -Wreturn-type void f() __attribute__((noreturn)); template<typename T> void g(T) { f(); } template void g<int>(int); template<typename T> struct A { void g() { f(); } }; template struct A<int>; struct B { template<typename T> void g(T) { f(); } }; template void B::g<int>(int); // We don't want a warning here. struct X { virtual void g() { f(); } }; namespace test1 { bool condition(); // We don't want a warning here. void foo() { while (condition()) {} } } // <rdar://problem/7880658> - This test case previously had a false "missing return" // warning. struct R7880658 { R7880658 &operator++(); bool operator==(const R7880658 &) const; bool operator!=(const R7880658 &) const; }; void f_R7880658(R7880658 f, R7880658 l) { // no-warning for (; f != l; ++f) { } } namespace test2 { bool g(); void *h() __attribute__((noreturn)); void *j(); struct A { void *f; A() : f(0) { } A(int) : f(h()) { } // expected-warning {{function 'A' could be declared with attribute 'noreturn'}} A(char) : f(j()) { } A(bool b) : f(b ? h() : j()) { } }; } namespace test3 { struct A { ~A(); }; struct B { ~B() { } A a; }; struct C : A { ~C() { } }; } // <rdar://problem/8875247> - Properly handle CFGs with destructors. struct rdar8875247 { ~rdar8875247 (); }; void rdar8875247_aux(); int rdar8875247_test() { rdar8875247 f; } // expected-warning{{control reaches end of non-void function}} struct rdar8875247_B { rdar8875247_B(); ~rdar8875247_B(); }; rdar8875247_B test_rdar8875247_B() { rdar8875247_B f; return f; } // no-warning namespace PR10801 { struct Foo { void wibble() __attribute((__noreturn__)); }; struct Bar { void wibble(); }; template <typename T> void thingy(T thing) { thing.wibble(); } void test() { Foo f; Bar b; thingy(f); thingy(b); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/undefined-inline.cpp
// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -verify %s // PR14993 namespace test1 { inline void f(); // expected-warning{{inline function 'test1::f' is not defined}} void test() { f(); } // expected-note{{used here}} } namespace test2 { inline int f(); void test() { (void)sizeof(f()); } } namespace test3 { void f(); // expected-warning{{inline function 'test3::f' is not defined}} inline void f(); void test() { f(); } // expected-note{{used here}} } namespace test4 { inline void error_on_zero(int); // expected-warning{{inline function 'test4::error_on_zero' is not defined}} inline void error_on_zero(char*) {} void test() { error_on_zero(0); } // expected-note{{used here}} } namespace test5 { struct X { void f(); }; void test(X &x) { x.f(); } } namespace test6 { struct X { inline void f(); }; // expected-warning{{inline function 'test6::X::f' is not defined}} void test(X &x) { x.f(); } // expected-note{{used here}} } namespace test7 { void f(); // expected-warning{{inline function 'test7::f' is not defined}} void test() { f(); } // no used-here note. inline void f(); } namespace test8 { inline void foo() __attribute__((gnu_inline)); void test() { foo(); } } namespace test9 { void foo(); void test() { foo(); } inline void foo() __attribute__((gnu_inline)); } namespace test10 { inline void foo(); void test() { foo(); } inline void foo() __attribute__((gnu_inline)); } namespace test11 { inline void foo() __attribute__((dllexport)); inline void bar() __attribute__((dllimport)); void test() { foo(); bar(); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/dllimport.cpp
// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s // RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s // Helper structs to make templates more expressive. struct ImplicitInst_Imported {}; struct ExplicitDecl_Imported {}; struct ExplicitInst_Imported {}; struct ExplicitSpec_Imported {}; struct ExplicitSpec_Def_Imported {}; struct ExplicitSpec_InlineDef_Imported {}; struct ExplicitSpec_NotImported {}; namespace { struct Internal {}; } // Invalid usage. __declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) int typedef2; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef int __declspec(dllimport) typedef3; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} typedef __declspec(dllimport) void (*FunTy)(); // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} enum __declspec(dllimport) Enum {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} #if __has_feature(cxx_strong_enums) enum class __declspec(dllimport) EnumClass {}; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} #endif //===----------------------------------------------------------------------===// // Globals //===----------------------------------------------------------------------===// // Import declaration. __declspec(dllimport) extern int ExternGlobalDecl; // dllimport implies a declaration. __declspec(dllimport) int GlobalDecl; int **__attribute__((dllimport))* GlobalDeclChunkAttr; int GlobalDeclAttr __attribute__((dllimport)); // Not allowed on definitions. __declspec(dllimport) extern int ExternGlobalInit = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) int GlobalInit1 = 1; // expected-error{{definition of dllimport data}} int __declspec(dllimport) GlobalInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int ExternGlobalDeclInit = 1; // expected-warning{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclInit = 1; // expected-warning{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int *GlobalDeclChunkAttrInit = 0; // expected-warning{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} int GlobalDeclAttrInit = 1; // expected-warning{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations __declspec(dllimport) extern int GlobalRedecl1; __declspec(dllimport) extern int GlobalRedecl1; __declspec(dllimport) int GlobalRedecl2a; __declspec(dllimport) int GlobalRedecl2a; int *__attribute__((dllimport)) GlobalRedecl2b; int *__attribute__((dllimport)) GlobalRedecl2b; int GlobalRedecl2c __attribute__((dllimport)); int GlobalRedecl2c __attribute__((dllimport)); // NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} extern int GlobalRedecl4; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllimport' attribute}} extern "C" { extern int GlobalRedecl5; // expected-note{{previous declaration is here}} __declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclaration of 'GlobalRedecl5' should not add 'dllimport' attribute}} } // External linkage is required. __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) int ExternalGlobal; } __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}} // expected-error@-1{{definition of dllimport data}} // Thread local variables are invalid. __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}} // Import in local scope. __declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}} __declspec(dllimport) float LocalRedecl2; // expected-note{{previous declaration is here}} __declspec(dllimport) float LocalRedecl3; // expected-note{{previous declaration is here}} void functionScope() { __declspec(dllimport) int LocalRedecl1; // expected-error{{redeclaration of 'LocalRedecl1' with a different type: 'int' vs 'float'}} int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redeclaration of 'LocalRedecl2' with a different type: 'int *' vs 'float'}} int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redeclaration of 'LocalRedecl3' with a different type: 'int' vs 'float'}} __declspec(dllimport) int LocalVarDecl; __declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) extern int ExternLocalVarDecl; __declspec(dllimport) extern int ExternLocalVarDef = 1; // expected-error{{definition of dllimport data}} __declspec(dllimport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllimport'}} } //===----------------------------------------------------------------------===// // Variable templates //===----------------------------------------------------------------------===// #if __has_feature(cxx_variable_templates) // Import declaration. template<typename T> __declspec(dllimport) extern int ExternVarTmplDecl; // dllimport implies a declaration. template<typename T> __declspec(dllimport) int VarTmplDecl; // Not allowed on definitions. template<typename T> __declspec(dllimport) extern int ExternVarTmplInit = 1; // expected-error{{definition of dllimport data}} template<typename T> __declspec(dllimport) int VarTmplInit1 = 1; // expected-error{{definition of dllimport data}} template<typename T> int __declspec(dllimport) VarTmplInit2 = 1; // expected-error{{definition of dllimport data}} // Declare, then reject definition. template<typename T> __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> int ExternVarTmplDeclInit = 1; // expected-warning{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> __declspec(dllimport) int VarTmplDeclInit; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> int VarTmplDeclInit = 1; // expected-warning{{'VarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations template<typename T> __declspec(dllimport) extern int VarTmplRedecl1; template<typename T> __declspec(dllimport) extern int VarTmplRedecl1; template<typename T> __declspec(dllimport) int VarTmplRedecl2; template<typename T> __declspec(dllimport) int VarTmplRedecl2; template<typename T> __declspec(dllimport) extern int VarTmplRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> extern int VarTmplRedecl3; // expected-warning{{'VarTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> extern int VarTmplRedecl4; // expected-note{{previous declaration is here}} template<typename T> __declspec(dllimport) extern int VarTmplRedecl4; // expected-error{{redeclaration of 'VarTmplRedecl4' cannot add 'dllimport' attribute}} // External linkage is required. template<typename T> __declspec(dllimport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllimport'}} template<typename T> __declspec(dllimport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllimport'}} namespace { template<typename T> __declspec(dllimport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template<typename T> __declspec(dllimport) int ExternalVarTmpl; } template<typename T> __declspec(dllimport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{definition of dllimport data}} // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllimport'}} template<typename T> int VarTmpl; template<typename T> __declspec(dllimport) int ImportedVarTmpl; // Import implicit instantiation of an imported variable template. int useVarTmpl() { return ImportedVarTmpl<ImplicitInst_Imported>; } // Import explicit instantiation declaration of an imported variable template. extern template int ImportedVarTmpl<ExplicitDecl_Imported>; // An explicit instantiation definition of an imported variable template cannot // be imported because the template must be defined which is illegal. // Import specialization of an imported variable template. template<> __declspec(dllimport) int ImportedVarTmpl<ExplicitSpec_Imported>; template<> __declspec(dllimport) int ImportedVarTmpl<ExplicitSpec_Def_Imported> = 1; // expected-error{{definition of dllimport data}} // Not importing specialization of an imported variable template without // explicit dllimport. template<> int ImportedVarTmpl<ExplicitSpec_NotImported>; // Import explicit instantiation declaration of a non-imported variable template. extern template __declspec(dllimport) int VarTmpl<ExplicitDecl_Imported>; // Import explicit instantiation definition of a non-imported variable template. template __declspec(dllimport) int VarTmpl<ExplicitInst_Imported>; // Import specialization of a non-imported variable template. template<> __declspec(dllimport) int VarTmpl<ExplicitSpec_Imported>; template<> __declspec(dllimport) int VarTmpl<ExplicitSpec_Def_Imported> = 1; // expected-error{{definition of dllimport data}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Functions //===----------------------------------------------------------------------===// // Import function declaration. Check different placements. __attribute__((dllimport)) void decl1A(); // Sanity check with __attribute__ __declspec(dllimport) void decl1B(); void __attribute__((dllimport)) decl2A(); void __declspec(dllimport) decl2B(); // Not allowed on function definitions. __declspec(dllimport) void def() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // extern "C" extern "C" __declspec(dllimport) void externC(); // Import inline function. #ifdef GNU // expected-warning@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@+3{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) inline void inlineFunc1() {} inline void __attribute__((dllimport)) inlineFunc2() {} #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) inline void inlineDecl(); void inlineDecl() {} __declspec(dllimport) void inlineDef(); #ifdef GNU // expected-warning@+2{{'inlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif inline void inlineDef() {} // Redeclarations __declspec(dllimport) void redecl1(); __declspec(dllimport) void redecl1(); // NB: MSVC issues a warning and makes redecl2/redecl3 dllexport. We follow GCC // and drop the dllimport with a warning. __declspec(dllimport) void redecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void redecl2(); // expected-warning{{'redecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void redecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}} extern "C" { void redecl5(); // expected-note{{previous declaration is here}} __declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}} } #ifdef MS void redecl6(); // expected-note{{previous declaration is here}} __declspec(dllimport) inline void redecl6() {} // expected-warning{{redeclaration of 'redecl6' should not add 'dllimport' attribute}} #else void redecl6(); __declspec(dllimport) inline void redecl6() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif // Friend functions struct FuncFriend { friend __declspec(dllimport) void friend1(); friend __declspec(dllimport) void friend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} friend void friend4(); // expected-note{{previous declaration is here}} #ifdef MS // expected-note@+2{{previous declaration is here}} #endif friend void friend5(); }; __declspec(dllimport) void friend1(); void friend2(); // expected-warning{{'friend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void friend3() {} // expected-warning{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} __declspec(dllimport) void friend4(); // expected-warning{{redeclaration of 'friend4' should not add 'dllimport' attribute}} #ifdef MS __declspec(dllimport) inline void friend5() {} // expected-warning{{redeclaration of 'friend5' should not add 'dllimport' attribute}} #else __declspec(dllimport) inline void friend5() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif void __declspec(dllimport) friend6(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} void __declspec(dllimport) friend7(); struct FuncFriend2 { friend void friend6(); // expected-warning{{'friend6' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} friend void ::friend7(); }; // Implicit declarations can be redeclared with dllimport. __declspec(dllimport) void* operator new(__SIZE_TYPE__ n); // External linkage is required. __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}} __declspec(dllimport) Internal internalRetFunc(); // expected-error{{'internalRetFunc' must have external linkage when declared 'dllimport'}} namespace { __declspec(dllimport) void internalFunc(); } // expected-error{{'(anonymous namespace)::internalFunc' must have external linkage when declared 'dllimport'}} namespace ns { __declspec(dllimport) void externalFunc(); } // Import deleted functions. // FIXME: Deleted functions are definitions so a missing inline is diagnosed // here which is irrelevant. But because the delete keyword is parsed later // there is currently no straight-forward way to avoid this diagnostic. __declspec(dllimport) void deletedFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} expected-error{{dllimport cannot be applied to non-inline function definition}} #ifdef MS __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} #else __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} #endif //===----------------------------------------------------------------------===// // Function templates //===----------------------------------------------------------------------===// // Import function template declaration. Check different placements. template<typename T> __declspec(dllimport) void funcTmplDecl1(); template<typename T> void __declspec(dllimport) funcTmplDecl2(); // Import function template definition. template<typename T> __declspec(dllimport) void funcTmplDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} // Import inline function template. #ifdef GNU // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+6{{'dllimport' attribute ignored on inline function}} // expected-warning@+9{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}} #endif template<typename T> __declspec(dllimport) inline void inlineFuncTmpl1() {} template<typename T> inline void __attribute__((dllimport)) inlineFuncTmpl2() {} template<typename T> __declspec(dllimport) inline void inlineFuncTmplDecl(); template<typename T> void inlineFuncTmplDecl() {} template<typename T> __declspec(dllimport) void inlineFuncTmplDef(); template<typename T> inline void inlineFuncTmplDef() {} // Redeclarations template<typename T> __declspec(dllimport) void funcTmplRedecl1(); template<typename T> __declspec(dllimport) void funcTmplRedecl1(); template<typename T> __declspec(dllimport) void funcTmplRedecl2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> void funcTmplRedecl2(); // expected-warning{{'funcTmplRedecl2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> __declspec(dllimport) void funcTmplRedecl3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> void funcTmplRedecl3() {} // expected-warning{{'funcTmplRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> void funcTmplRedecl4(); // expected-note{{previous declaration is here}} template<typename T> __declspec(dllimport) void funcTmplRedecl4(); // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllimport' attribute}} #ifdef MS template<typename T> void funcTmplRedecl5(); // expected-note{{previous declaration is here}} template<typename T> __declspec(dllimport) inline void funcTmplRedecl5() {} // expected-error{{redeclaration of 'funcTmplRedecl5' cannot add 'dllimport' attribute}} #endif // Function template friends struct FuncTmplFriend { template<typename T> friend __declspec(dllimport) void funcTmplFriend1(); template<typename T> friend __declspec(dllimport) void funcTmplFriend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> friend __declspec(dllimport) void funcTmplFriend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> friend void funcTmplFriend4(); // expected-note{{previous declaration is here}} #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<typename T> friend __declspec(dllimport) inline void funcTmplFriend5(); }; template<typename T> __declspec(dllimport) void funcTmplFriend1(); template<typename T> void funcTmplFriend2(); // expected-warning{{'funcTmplFriend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> void funcTmplFriend3() {} // expected-warning{{'funcTmplFriend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> __declspec(dllimport) void funcTmplFriend4(); // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllimport' attribute}} template<typename T> inline void funcTmplFriend5() {} // External linkage is required. template<typename T> __declspec(dllimport) static int staticFuncTmpl(); // expected-error{{'staticFuncTmpl' must have external linkage when declared 'dllimport'}} template<typename T> __declspec(dllimport) Internal internalRetFuncTmpl(); // expected-error{{'internalRetFuncTmpl' must have external linkage when declared 'dllimport'}} namespace { template<typename T> __declspec(dllimport) void internalFuncTmpl(); } // expected-error{{'(anonymous namespace)::internalFuncTmpl' must have external linkage when declared 'dllimport'}} namespace ns { template<typename T> __declspec(dllimport) void externalFuncTmpl(); } template<typename T> void funcTmpl() {} template<typename T> inline void inlineFuncTmpl() {} template<typename T> __declspec(dllimport) void importedFuncTmplDecl(); #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) inline void importedFuncTmpl() {} // Import implicit instantiation of an imported function template. void useFunTmplDecl() { importedFuncTmplDecl<ImplicitInst_Imported>(); } void useFunTmplDef() { importedFuncTmpl<ImplicitInst_Imported>(); } // Import explicit instantiation declaration of an imported function template. extern template void importedFuncTmpl<ExplicitDecl_Imported>(); // Import explicit instantiation definition of an imported function template. // NB: MSVC fails this instantiation without explicit dllimport which is most // likely a bug because an implicit instantiation is accepted. template void importedFuncTmpl<ExplicitInst_Imported>(); // Import specialization of an imported function template. A definition must be // declared inline. template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Imported>(); template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Def_Imported>() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} #ifdef MS template<> __declspec(dllimport) inline void importedFuncTmpl<ExplicitSpec_InlineDef_Imported>() {} #endif // Not importing specialization of an imported function template without // explicit dllimport. template<> void importedFuncTmpl<ExplicitSpec_NotImported>() {} // Import explicit instantiation declaration of a non-imported function template. extern template __declspec(dllimport) void funcTmpl<ExplicitDecl_Imported>(); #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif extern template __declspec(dllimport) void inlineFuncTmpl<ExplicitDecl_Imported>(); // Import explicit instantiation definition of a non-imported function template. template __declspec(dllimport) void funcTmpl<ExplicitInst_Imported>(); #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template __declspec(dllimport) void inlineFuncTmpl<ExplicitInst_Imported>(); // Import specialization of a non-imported function template. A definition must // be declared inline. template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Imported>(); template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Def_Imported>() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<> __declspec(dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {} //===----------------------------------------------------------------------===// // Class members //===----------------------------------------------------------------------===// // Import individual members of a class. struct ImportMembers { struct Nested { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; #ifdef GNU // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+6{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInclass() {} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) inline void normalInlineDecl(); #ifdef GNU // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+6{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) virtual inline void virtualInlineDecl(); #ifdef GNU // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+6{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static void staticInlineDef(); __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; void ImportMembers::Nested::normalDef() {} // expected-warning{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} void ImportMembers::normalDef() {} // expected-warning{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #ifdef GNU // expected-warning@+2{{'ImportMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif inline void ImportMembers::normalInlineDef() {} void ImportMembers::normalInlineDecl() {} void ImportMembers::virtualDef() {} // expected-warning{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #ifdef GNU // expected-warning@+2{{'ImportMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif inline void ImportMembers::virtualInlineDef() {} void ImportMembers::virtualInlineDecl() {} void ImportMembers::staticDef() {} // expected-warning{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #ifdef GNU // expected-warning@+2{{'ImportMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif inline void ImportMembers::staticInlineDef() {} void ImportMembers::staticInlineDecl() {} int ImportMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} const int ImportMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} constexpr int ImportMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} // Import on member definitions. struct ImportMemberDefs { __declspec(dllimport) void normalDef(); __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) virtual void virtualDef(); __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) static void staticDef(); __declspec(dllimport) static void staticInlineDef(); #ifdef MS __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static inline void staticInlineDecl(); #endif __declspec(dllimport) static int StaticField; __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) constexpr static int ConstexprField = 1; }; __declspec(dllimport) void ImportMemberDefs::normalDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}} #ifdef MS __declspec(dllimport) inline void ImportMemberDefs::normalInlineDef() {} __declspec(dllimport) void ImportMemberDefs::normalInlineDecl() {} __declspec(dllimport) inline void ImportMemberDefs::virtualInlineDef() {} __declspec(dllimport) void ImportMemberDefs::virtualInlineDecl() {} __declspec(dllimport) inline void ImportMemberDefs::staticInlineDef() {} __declspec(dllimport) void ImportMemberDefs::staticInlineDecl() {} #endif __declspec(dllimport) int ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) const int ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} __declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}} // Import special member functions. struct ImportSpecials { __declspec(dllimport) ImportSpecials(); __declspec(dllimport) ~ImportSpecials(); __declspec(dllimport) ImportSpecials(const ImportSpecials&); __declspec(dllimport) ImportSpecials& operator=(const ImportSpecials&); __declspec(dllimport) ImportSpecials(ImportSpecials&&); __declspec(dllimport) ImportSpecials& operator=(ImportSpecials&&); }; // Import deleted member functions. struct ImportDeleted { #ifdef MS __declspec(dllimport) ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} __declspec(dllimport) void deleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} #else __declspec(dllimport) ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ~ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) void deleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}} #endif }; // Import allocation functions. struct ImportAlloc { __declspec(dllimport) void* operator new(__SIZE_TYPE__); __declspec(dllimport) void* operator new[](__SIZE_TYPE__); __declspec(dllimport) void operator delete(void*); __declspec(dllimport) void operator delete[](void*); }; // Import defaulted member functions. struct ImportDefaulted { #ifdef GNU // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) ImportDefaulted() = default; __declspec(dllimport) ~ImportDefaulted() = default; __declspec(dllimport) ImportDefaulted(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted& operator=(const ImportDefaulted&) = default; __declspec(dllimport) ImportDefaulted(ImportDefaulted&&) = default; __declspec(dllimport) ImportDefaulted& operator=(ImportDefaulted&&) = default; }; // Import defaulted member function definitions. struct ImportDefaultedDefs { __declspec(dllimport) ImportDefaultedDefs(); __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} #ifdef GNU // expected-warning@+3{{'dllimport' attribute ignored on inline function}} // expected-note@+2{{previous declaration is here}} #endif __declspec(dllimport) inline ImportDefaultedDefs(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs& operator=(const ImportDefaultedDefs&); __declspec(dllimport) ImportDefaultedDefs(ImportDefaultedDefs&&); __declspec(dllimport) ImportDefaultedDefs& operator=(ImportDefaultedDefs&&); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} }; // Not allowed on definitions. __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs() = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} // dllimport cannot be dropped. ImportDefaultedDefs::~ImportDefaultedDefs() = default; // expected-warning{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Import inline declaration and definition. #ifdef GNU // expected-error@+3{{redeclaration of 'ImportDefaultedDefs::ImportDefaultedDefs' cannot add 'dllimport' attribute}} // expected-warning@+3{{'ImportDefaultedDefs::operator=' redeclared inline; 'dllimport' attribute ignored}} #endif __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(const ImportDefaultedDefs&) = default; inline ImportDefaultedDefs& ImportDefaultedDefs::operator=(const ImportDefaultedDefs&) = default; __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(ImportDefaultedDefs&&) = default; // expected-error{{dllimport cannot be applied to non-inline function definition}} ImportDefaultedDefs& ImportDefaultedDefs::operator=(ImportDefaultedDefs&&) = default; // expected-warning{{'ImportDefaultedDefs::operator=' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} // Redeclarations cannot add dllimport. struct MemberRedecl { void normalDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #ifdef MS // expected-note@+4{{previous declaration is here}} // expected-note@+4{{previous declaration is here}} // expected-note@+4{{previous declaration is here}} #endif void normalInlineDef(); virtual void virtualInlineDef(); static void staticInlineDef(); static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; __declspec(dllimport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void MemberRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::virtualDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void MemberRedecl::virtualInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllimport' attribute}} __declspec(dllimport) void MemberRedecl::staticDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} __declspec(dllimport) void MemberRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} #ifdef MS __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}} #else __declspec(dllimport) inline void MemberRedecl::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} __declspec(dllimport) inline void MemberRedecl::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) int MemberRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} __declspec(dllimport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} __declspec(dllimport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class member templates //===----------------------------------------------------------------------===// struct ImportMemberTmpl { template<typename T> __declspec(dllimport) void normalDecl(); template<typename T> __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> __declspec(dllimport) void normalInlineDef(); template<typename T> __declspec(dllimport) static void staticDecl(); template<typename T> __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename T> __declspec(dllimport) static void staticInlineDef(); #ifdef GNU // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) void normalInclass() {} template<typename T> __declspec(dllimport) inline void normalInlineDecl(); template<typename T> __declspec(dllimport) static void staticInclass() {} template<typename T> __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template<typename T> __declspec(dllimport) static int StaticField; template<typename T> __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template<typename T> __declspec(dllimport) static const int StaticConstField; template<typename T> __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template<typename T> __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template<typename T> __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template<typename T> __declspec(dllimport) constexpr static int ConstexprField = 1; template<typename T> __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template<typename T> void ImportMemberTmpl::normalDef() {} // expected-warning{{'ImportMemberTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> void ImportMemberTmpl::normalInlineDecl() {} template<typename T> void ImportMemberTmpl::staticDef() {} // expected-warning{{'ImportMemberTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> void ImportMemberTmpl::staticInlineDecl() {} #ifdef GNU // expected-warning@+3{{ImportMemberTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} // expected-warning@+3{{ImportMemberTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template<typename T> inline void ImportMemberTmpl::normalInlineDef() {} template<typename T> inline void ImportMemberTmpl::staticInlineDef() {} #if __has_feature(cxx_variable_templates) template<typename T> int ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}} template<typename T> const int ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}} template<typename T> constexpr int ImportMemberTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. struct MemTmplRedecl { template<typename T> void normalDef(); // expected-note{{previous declaration is here}} template<typename T> inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template<typename T> static void staticDef(); // expected-note{{previous declaration is here}} template<typename T> static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #ifdef MS // expected-note@+3{{previous declaration is here}} // expected-note@+3{{previous declaration is here}} #endif template<typename T> void normalInlineDef(); template<typename T> static void staticInlineDef(); #if __has_feature(cxx_variable_templates) template<typename T> static int StaticField; // expected-note{{previous declaration is here}} template<typename T> static const int StaticConstField; // expected-note{{previous declaration is here}} template<typename T> constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template<typename T> __declspec(dllimport) void MemTmplRedecl::normalDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} #ifdef MS template<typename T> __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllimport' attribute}} #else template<typename T> __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) void MemTmplRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllimport' attribute}} template<typename T> __declspec(dllimport) void MemTmplRedecl::staticDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} #ifdef MS template<typename T> __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllimport' attribute}} #else template<typename T> __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) void MemTmplRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllimport' attribute}} #if __has_feature(cxx_variable_templates) template<typename T> __declspec(dllimport) int MemTmplRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticField' cannot add 'dllimport' attribute}} // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} template<typename T> __declspec(dllimport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllimport' attribute}} // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} template<typename T> __declspec(dllimport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllimport' attribute}} // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) struct MemFunTmpl { template<typename T> void normalDef() {} #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) void importedNormal() {} template<typename T> static void staticDef() {} #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) static void importedStatic() {} }; // Import implicit instantiation of an imported member function template. void useMemFunTmpl() { MemFunTmpl().importedNormal<ImplicitInst_Imported>(); MemFunTmpl().importedStatic<ImplicitInst_Imported>(); } // Import explicit instantiation declaration of an imported member function // template. extern template void MemFunTmpl::importedNormal<ExplicitDecl_Imported>(); extern template void MemFunTmpl::importedStatic<ExplicitDecl_Imported>(); // Import explicit instantiation definition of an imported member function // template. // NB: MSVC fails this instantiation without explicit dllimport. template void MemFunTmpl::importedNormal<ExplicitInst_Imported>(); template void MemFunTmpl::importedStatic<ExplicitInst_Imported>(); // Import specialization of an imported member function template. template<> __declspec(dllimport) void MemFunTmpl::importedNormal<ExplicitSpec_Imported>(); template<> __declspec(dllimport) void MemFunTmpl::importedNormal<ExplicitSpec_Def_Imported>() {} // error on mingw #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<> __declspec(dllimport) inline void MemFunTmpl::importedNormal<ExplicitSpec_InlineDef_Imported>() {} #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@-7{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::importedStatic<ExplicitSpec_Imported>(); template<> __declspec(dllimport) void MemFunTmpl::importedStatic<ExplicitSpec_Def_Imported>() {} // error on mingw #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<> __declspec(dllimport) inline void MemFunTmpl::importedStatic<ExplicitSpec_InlineDef_Imported>() {} #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@-7{{dllimport cannot be applied to non-inline function definition}} #endif // Not importing specialization of an imported member function template without // explicit dllimport. template<> void MemFunTmpl::importedNormal<ExplicitSpec_NotImported>() {} template<> void MemFunTmpl::importedStatic<ExplicitSpec_NotImported>() {} // Import explicit instantiation declaration of a non-imported member function // template. #ifdef GNU // expected-warning@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@+3{{'dllimport' attribute ignored on inline function}} #endif extern template __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitDecl_Imported>(); extern template __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitDecl_Imported>(); // Import explicit instantiation definition of a non-imported member function // template. #ifdef GNU // expected-warning@+3{{'dllimport' attribute ignored on inline function}} // expected-warning@+3{{'dllimport' attribute ignored on inline function}} #endif template __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitInst_Imported>(); template __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitInst_Imported>(); // Import specialization of a non-imported member function template. template<> __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitSpec_Imported>(); template<> __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitSpec_Def_Imported>() {} // error on mingw #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<> __declspec(dllimport) inline void MemFunTmpl::normalDef<ExplicitSpec_InlineDef_Imported>() {} #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@-7{{dllimport cannot be applied to non-inline function definition}} #endif template<> __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitSpec_Imported>(); template<> __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitSpec_Def_Imported>() {} // error on mingw #ifdef GNU // expected-warning@+2{{'dllimport' attribute ignored on inline function}} #endif template<> __declspec(dllimport) inline void MemFunTmpl::staticDef<ExplicitSpec_InlineDef_Imported>() {} #if 1 // FIXME: This should not be an error when targeting MSVC. (PR21406) // expected-error@-7{{dllimport cannot be applied to non-inline function definition}} #endif #if __has_feature(cxx_variable_templates) struct MemVarTmpl { template<typename T> static const int StaticVar = 1; template<typename T> __declspec(dllimport) static const int ImportedStaticVar = 1; }; // Import implicit instantiation of an imported member variable template. int useMemVarTmpl() { return MemVarTmpl::ImportedStaticVar<ImplicitInst_Imported>; } // Import explicit instantiation declaration of an imported member variable // template. extern template const int MemVarTmpl::ImportedStaticVar<ExplicitDecl_Imported>; // An explicit instantiation definition of an imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of an imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar<ExplicitSpec_Imported>; template<> __declspec(dllimport) const int MemVarTmpl::ImportedStaticVar<ExplicitSpec_Def_Imported> = 1; // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} // Not importing specialization of a member variable template without explicit // dllimport. template<> const int MemVarTmpl::ImportedStaticVar<ExplicitSpec_NotImported>; // Import explicit instantiation declaration of a non-imported member variable // template. extern template __declspec(dllimport) const int MemVarTmpl::StaticVar<ExplicitDecl_Imported>; // An explicit instantiation definition of a non-imported member variable template // cannot be imported because the template must be defined which is illegal. The // in-class initializer does not count. // Import specialization of a non-imported member variable template. template<> __declspec(dllimport) const int MemVarTmpl::StaticVar<ExplicitSpec_Imported>; template<> __declspec(dllimport) const int MemVarTmpl::StaticVar<ExplicitSpec_Def_Imported> = 1; // expected-error@-1{{definition of dllimport static field not allowed}} // expected-note@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Class template members //===----------------------------------------------------------------------===// // Import individual members of a class template. template<typename T> struct ImportClassTmplMembers { __declspec(dllimport) void normalDecl(); __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) void normalInlineDef(); __declspec(dllimport) virtual void virtualDecl(); __declspec(dllimport) virtual void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) virtual void virtualInlineDef(); __declspec(dllimport) static void staticDecl(); __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} __declspec(dllimport) static void staticInlineDef(); #ifdef GNU // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} // expected-warning@+7{{'dllimport' attribute ignored on inline function}} #endif __declspec(dllimport) void normalInclass() {} __declspec(dllimport) inline void normalInlineDecl(); __declspec(dllimport) virtual void virtualInclass() {} __declspec(dllimport) virtual inline void virtualInlineDecl(); __declspec(dllimport) static void staticInclass() {} __declspec(dllimport) static inline void staticInlineDecl(); protected: __declspec(dllimport) void protectedDecl(); private: __declspec(dllimport) void privateDecl(); public: __declspec(dllimport) int Field; // expected-warning{{'dllimport' attribute only applies to variables, functions and classes}} __declspec(dllimport) static int StaticField; __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstField; __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; __declspec(dllimport) constexpr static int ConstexprField = 1; __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} }; // NB: MSVC is inconsistent here and disallows *InlineDef on class templates, // but allows it on classes. We allow both. template<typename T> void ImportClassTmplMembers<T>::normalDef() {} // expected-warning{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #ifdef GNU // expected-warning@+2{{'ImportClassTmplMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template<typename T> inline void ImportClassTmplMembers<T>::normalInlineDef() {} template<typename T> void ImportClassTmplMembers<T>::normalInlineDecl() {} template<typename T> void ImportClassTmplMembers<T>::virtualDef() {} // expected-warning{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #ifdef GNU // expected-warning@+2{{'ImportClassTmplMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template<typename T> inline void ImportClassTmplMembers<T>::virtualInlineDef() {} template<typename T> void ImportClassTmplMembers<T>::virtualInlineDecl() {} template<typename T> void ImportClassTmplMembers<T>::staticDef() {} // expected-warning{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} #ifdef GNU // expected-warning@+2{{'ImportClassTmplMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template<typename T> inline void ImportClassTmplMembers<T>::staticInlineDef() {} template<typename T> void ImportClassTmplMembers<T>::staticInlineDecl() {} template<typename T> int ImportClassTmplMembers<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}} template<typename T> const int ImportClassTmplMembers<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}} template<typename T> constexpr int ImportClassTmplMembers<T>::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}} // Redeclarations cannot add dllimport. template<typename T> struct CTMR /*ClassTmplMemberRedecl*/ { void normalDef(); // expected-note{{previous declaration is here}} inline void normalInlineDecl(); // expected-note{{previous declaration is here}} virtual void virtualDef(); // expected-note{{previous declaration is here}} virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}} static void staticDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #ifdef MS // expected-note@+4{{previous declaration is here}} // expected-note@+4{{previous declaration is here}} // expected-note@+4{{previous declaration is here}} #endif void normalInlineDef(); virtual void virtualInlineDef(); static void staticInlineDef(); static int StaticField; // expected-note{{previous declaration is here}} static const int StaticConstField; // expected-note{{previous declaration is here}} constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} }; template<typename T> __declspec(dllimport) void CTMR<T>::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} template<typename T> __declspec(dllimport) void CTMR<T>::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllimport' attribute}} template<typename T> __declspec(dllimport) void CTMR<T>::virtualDef() {} // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} template<typename T> __declspec(dllimport) void CTMR<T>::virtualInlineDecl() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllimport' attribute}} template<typename T> __declspec(dllimport) void CTMR<T>::staticDef() {} // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} template<typename T> __declspec(dllimport) void CTMR<T>::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllimport' attribute}} #ifdef MS template<typename T> __declspec(dllimport) inline void CTMR<T>::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}} template<typename T> __declspec(dllimport) inline void CTMR<T>::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}} template<typename T> __declspec(dllimport) inline void CTMR<T>::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}} #else template<typename T> __declspec(dllimport) inline void CTMR<T>::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template<typename T> __declspec(dllimport) inline void CTMR<T>::virtualInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template<typename T> __declspec(dllimport) inline void CTMR<T>::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif template<typename T> __declspec(dllimport) int CTMR<T>::StaticField = 1; // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllimport' attribute}} // expected-warning@-1{{definition of dllimport static field}} // expected-note@-2{{attribute is here}} template<typename T> __declspec(dllimport) const int CTMR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllimport' attribute}} // expected-warning@-1{{definition of dllimport static field}} // expected-note@-2{{attribute is here}} template<typename T> __declspec(dllimport) constexpr int CTMR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}} // expected-warning@-1{{definition of dllimport static field}} // expected-note@-2{{attribute is here}} //===----------------------------------------------------------------------===// // Class template member templates //===----------------------------------------------------------------------===// template<typename T> struct ImportClsTmplMemTmpl { template<typename U> __declspec(dllimport) void normalDecl(); template<typename U> __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename U> __declspec(dllimport) void normalInlineDef(); template<typename U> __declspec(dllimport) static void staticDecl(); template<typename U> __declspec(dllimport) static void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}} template<typename U> __declspec(dllimport) static void staticInlineDef(); #ifdef GNU // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} // expected-warning@+5{{'dllimport' attribute ignored on inline function}} #endif template<typename U> __declspec(dllimport) void normalInclass() {} template<typename U> __declspec(dllimport) inline void normalInlineDecl(); template<typename U> __declspec(dllimport) static void staticInclass() {} template<typename U> __declspec(dllimport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template<typename U> __declspec(dllimport) static int StaticField; template<typename U> __declspec(dllimport) static int StaticFieldDef; // expected-note{{attribute is here}} template<typename U> __declspec(dllimport) static const int StaticConstField; template<typename U> __declspec(dllimport) static const int StaticConstFieldDef; // expected-note{{attribute is here}} template<typename U> __declspec(dllimport) static const int StaticConstFieldEqualInit = 1; template<typename U> __declspec(dllimport) static const int StaticConstFieldBraceInit{1}; template<typename U> __declspec(dllimport) constexpr static int ConstexprField = 1; template<typename U> __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}} #endif // __has_feature(cxx_variable_templates) }; template<typename T> template<typename U> void ImportClsTmplMemTmpl<T>::normalDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> template<typename U> void ImportClsTmplMemTmpl<T>::normalInlineDecl() {} template<typename T> template<typename U> void ImportClsTmplMemTmpl<T>::staticDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} template<typename T> template<typename U> void ImportClsTmplMemTmpl<T>::staticInlineDecl() {} #ifdef GNU // expected-warning@+3{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}} // expected-warning@+3{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}} #endif template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::normalInlineDef() {} template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::staticInlineDef() {} #if __has_feature(cxx_variable_templates) template<typename T> template<typename U> int ImportClsTmplMemTmpl<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}} template<typename T> template<typename U> const int ImportClsTmplMemTmpl<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}} template<typename T> template<typename U> constexpr int ImportClsTmplMemTmpl<T>::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}} #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllimport. template<typename T> struct CTMTR /*ClassTmplMemberTmplRedecl*/ { template<typename U> void normalDef(); // expected-note{{previous declaration is here}} template<typename U> inline void normalInlineDecl(); // expected-note{{previous declaration is here}} template<typename U> static void staticDef(); // expected-note{{previous declaration is here}} template<typename U> static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #ifdef MS // expected-note@+3{{previous declaration is here}} // expected-note@+3{{previous declaration is here}} #endif template<typename U> void normalInlineDef(); template<typename U> static void staticInlineDef(); #if __has_feature(cxx_variable_templates) template<typename U> static int StaticField; // expected-note{{previous declaration is here}} template<typename U> static const int StaticConstField; // expected-note{{previous declaration is here}} template<typename U> constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}} #endif // __has_feature(cxx_variable_templates) }; template<typename T> template<typename U> __declspec(dllimport) void CTMTR<T>::normalDef() {} // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} template<typename T> template<typename U> __declspec(dllimport) void CTMTR<T>::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllimport' attribute}} template<typename T> template<typename U> __declspec(dllimport) void CTMTR<T>::staticDef() {} // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllimport' attribute}} // expected-error@-1{{dllimport cannot be applied to non-inline function definition}} template<typename T> template<typename U> __declspec(dllimport) void CTMTR<T>::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllimport' attribute}} #ifdef MS template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}} template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}} #else template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::normalInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::staticInlineDef() {} // expected-warning{{'dllimport' attribute ignored on inline function}} #endif #if __has_feature(cxx_variable_templates) template<typename T> template<typename U> __declspec(dllimport) int CTMTR<T>::StaticField = 1; // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllimport' attribute}} // expected-warning@-1{{definition of dllimport static field}} // expected-note@-2{{attribute is here}} template<typename T> template<typename U> __declspec(dllimport) const int CTMTR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllimport' attribute}} // expected-warning@-1{{definition of dllimport static field}} // expected-note@-2{{attribute is here}} template<typename T> template<typename U> __declspec(dllimport) constexpr int CTMTR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllimport' attribute}} // expected-warning@-1{{definition of dllimport static field}} // expected-note@-2{{attribute is here}} #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Classes //===----------------------------------------------------------------------===// namespace { struct __declspec(dllimport) AnonymousClass {}; // expected-error{{(anonymous namespace)::AnonymousClass' must have external linkage when declared 'dllimport'}} } class __declspec(dllimport) ClassDecl; class __declspec(dllimport) ClassDef { }; template <typename T> class ClassTemplate {}; #ifdef MS // expected-note@+5{{previous attribute is here}} // expected-note@+4{{previous attribute is here}} // expected-error@+4{{attribute 'dllexport' cannot be applied to member of 'dllimport' class}} // expected-error@+4{{attribute 'dllimport' cannot be applied to member of 'dllimport' class}} #endif class __declspec(dllimport) ImportClassWithDllMember { void __declspec(dllexport) foo(); void __declspec(dllimport) bar(); }; #ifdef MS // expected-note@+5{{previous attribute is here}} // expected-note@+4{{previous attribute is here}} // expected-error@+4{{attribute 'dllimport' cannot be applied to member of 'dllexport' class}} // expected-error@+4{{attribute 'dllexport' cannot be applied to member of 'dllexport' class}} #endif template <typename T> class __declspec(dllexport) ExportClassWithDllMember { void __declspec(dllimport) foo(); void __declspec(dllexport) bar(); }; namespace ImportedExplicitSpecialization { template <typename T> struct S { static int x; }; template <typename T> int S<T>::x = sizeof(T); template <> struct __declspec(dllimport) S<int> { static int x; }; // expected-note{{attribute is here}} int S<int>::x = -1; // expected-error{{definition of dllimport static field not allowed}} } namespace PR19988 { // Don't error about applying delete to dllimport member function when instantiating. template <typename> struct __declspec(dllimport) S { void foo() = delete; }; S<int> s; } #ifdef MS // expected-warning@+3{{'dllimport' attribute ignored}} #endif template <typename T> struct PartiallySpecializedClassTemplate {}; template <typename T> struct __declspec(dllimport) PartiallySpecializedClassTemplate<T*> { void f() {} }; template <typename T> struct ExpliciallySpecializedClassTemplate {}; template <> struct __declspec(dllimport) ExpliciallySpecializedClassTemplate<int> { void f() {} }; //===----------------------------------------------------------------------===// // Classes with template base classes //===----------------------------------------------------------------------===// template <typename T> class __declspec(dllexport) ExportedClassTemplate {}; template <typename T> class __declspec(dllimport) ImportedClassTemplate {}; // ClassTemplate<int> gets imported. class __declspec(dllimport) DerivedFromTemplate : public ClassTemplate<int> {}; // ClassTemplate<int> is already imported. class __declspec(dllimport) DerivedFromTemplate2 : public ClassTemplate<int> {}; // ImportedClassTemplate is expliitly imported. class __declspec(dllimport) DerivedFromImportedTemplate : public ImportedClassTemplate<int> {}; // ExportedClassTemplate is explicitly exported. class __declspec(dllimport) DerivedFromExportedTemplate : public ExportedClassTemplate<int> {}; class DerivedFromTemplateD : public ClassTemplate<double> {}; // Base class previously implicitly instantiated without attribute; it will get propagated. class __declspec(dllimport) DerivedFromTemplateD2 : public ClassTemplate<double> {}; // Base class has explicit instantiation declaration; the attribute will get propagated. extern template class ClassTemplate<float>; class __declspec(dllimport) DerivedFromTemplateF : public ClassTemplate<float> {}; class __declspec(dllimport) DerivedFromTemplateB : public ClassTemplate<bool> {}; // The second derived class doesn't change anything, the attribute that was propagated first wins. class __declspec(dllexport) DerivedFromTemplateB2 : public ClassTemplate<bool> {}; template <typename T> struct ExplicitlySpecializedTemplate { void func() {} }; #ifdef MS // expected-note@+2{{class template 'ExplicitlySpecializedTemplate<int>' was explicitly specialized here}} #endif template <> struct ExplicitlySpecializedTemplate<int> { void func() {} }; template <typename T> struct ExplicitlyExportSpecializedTemplate { void func() {} }; template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate<int> { void func() {} }; template <typename T> struct ExplicitlyImportSpecializedTemplate { void func() {} }; template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func() {} }; template <typename T> struct ExplicitlyInstantiatedTemplate { void func() {} }; #ifdef MS // expected-note@+2{{class template 'ExplicitlyInstantiatedTemplate<int>' was instantiated here}} #endif template struct ExplicitlyInstantiatedTemplate<int>; template <typename T> struct ExplicitlyExportInstantiatedTemplate { void func() {} }; template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate<int>; template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func() {} }; template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate<int>; #ifdef MS // expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}} // expected-note@+2{{attribute is here}} #endif struct __declspec(dllimport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {}; // Base class already specialized with export attribute. struct __declspec(dllimport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate<int> {}; // Base class already specialized with import attribute. struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {}; #ifdef MS // expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}} // expected-note@+2{{attribute is here}} #endif struct __declspec(dllimport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {}; // Base class already instantiated with export attribute. struct __declspec(dllimport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate<int> {}; // Base class already instantiated with import attribute. struct __declspec(dllimport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate<int> {}; template <typename T> struct ExplicitInstantiationDeclTemplateBase { void func() {} }; extern template struct ExplicitInstantiationDeclTemplateBase<int>; struct __declspec(dllimport) DerivedFromExplicitInstantiationDeclTemplateBase : public ExplicitInstantiationDeclTemplateBase<int> {};
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overloaded-operator-decl.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct X { X(); X(int); }; X operator+(X, X); X operator-(X, X) { X x; return x; } struct Y { Y operator-() const; void operator()(int x = 17) const; int operator[](int); static int operator+(Y, Y); // expected-error{{overloaded 'operator+' cannot be a static member function}} }; void f(X x) { x = operator+(x, x); } X operator+(int, float); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}} X operator*(X, X = 5); // expected-error{{parameter of overloaded 'operator*' cannot have a default argument}} X operator/(X, X, ...); // expected-error{{overloaded 'operator/' cannot be variadic}} X operator%(Y); // expected-error{{overloaded 'operator%' must be a binary operator (has 1 parameter)}} void operator()(Y&, int, int); // expected-error{{overloaded 'operator()' must be a non-static member function}} typedef int INT; typedef float FLOAT; Y& operator++(Y&); Y operator++(Y&, INT); X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}} int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}} namespace PR6238 { static struct { void operator()(); } plus; } struct PR10839 { operator int; // expected-error{{'operator int' cannot be the name of a variable or data member}} int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}} }; namespace PR14120 { struct A { static void operator()(int& i) { ++i; } // expected-error{{overloaded 'operator()' cannot be a static member function}} }; void f() { int i = 0; A()(i); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/implicit-int.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s x; // expected-error{{C++ requires a type specifier for all declarations}} f(int y) { return y; } // expected-error{{C++ requires a type specifier for all declarations}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/defaulted-private-dtor.cpp
// RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions class BadDtor { // A private, but nonetheless trivial, destructor. ~BadDtor() = default; // expected-note 9{{here}} friend class K; }; void f() { BadDtor *p = new BadDtor[3]; // expected-error {{private destructor}} delete [] p; // expected-error {{private destructor}} const BadDtor &dd2 = BadDtor(); // expected-error {{private destructor}} BadDtor dd; // expected-error {{private destructor}} throw dd; // expected-error {{private destructor}} } struct V { V(); BadDtor bd; // expected-note {{inaccessible destructor}} }; V v; // expected-error {{deleted function}} struct W : BadDtor { // expected-note {{inaccessible destructor}} W(); }; W w; // expected-error {{deleted function}} struct X : BadDtor { // expected-error {{private destructor}} ~X() {} }; struct Y { BadDtor dd; // expected-error {{private destructor}} ~Y() {} }; struct Z : virtual BadDtor { // expected-error {{private destructor}} ~Z() {} }; BadDtor dd; // expected-error {{private destructor}} class K : BadDtor { void f() { BadDtor *p = new BadDtor[3]; delete [] p; const BadDtor &dd2 = BadDtor(); BadDtor dd; throw dd; { BadDtor x; goto dont_call_dtor; } dont_call_dtor: ; } struct Z : virtual BadDtor { ~Z() {} }; BadDtor dd; ~K(); };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-new-overaligned.cpp
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s namespace test1 { struct Test { template <typename T> struct SeparateCacheLines { T data; } __attribute__((aligned(256))); SeparateCacheLines<int> high_contention_data[10]; }; void helper() { Test t; new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}} new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } namespace test2 { class Test { typedef int __attribute__((aligned(256))) aligned_int; aligned_int high_contention_data[10]; }; void helper() { Test t; new Test; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}} new Test[10]; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } namespace test3 { struct Test { template <typename T> struct SeparateCacheLines { T data; } __attribute__((aligned(256))); void* operator new(unsigned long) { return 0; // expected-warning {{'operator new' should not return a null pointer unless it is declared 'throw()'}} } SeparateCacheLines<int> high_contention_data[10]; }; void helper() { Test t; new Test; new Test[10]; // expected-warning {{type 'test3::Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } namespace test4 { struct Test { template <typename T> struct SeparateCacheLines { T data; } __attribute__((aligned(256))); void* operator new[](unsigned long) { return 0; // expected-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()'}} } SeparateCacheLines<int> high_contention_data[10]; }; void helper() { Test t; new Test; // expected-warning {{type 'test4::Test' requires 256 bytes of alignment and the default allocator only guarantees}} new Test[10]; } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/new-null.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 typedef __SIZE_TYPE__ size_t; #if __cplusplus >= 201103L struct S1 { void *operator new(size_t n) { return nullptr; // expected-warning {{'operator new' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}} } void *operator new[](size_t n) noexcept { return __null; } }; #endif struct S2 { static size_t x; void *operator new(size_t n) throw() { return 0; } void *operator new[](size_t n) { return (void*)0; #if __cplusplus >= 201103L // expected-warning@-2 {{'operator new[]' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}} #else // expected-warning-re@-4 {{'operator new[]' should not return a null pointer unless it is declared 'throw()'{{$}}}} #endif } }; struct S3 { void *operator new(size_t n) { return 1-1; #if __cplusplus >= 201103L // expected-error@-2 {{cannot initialize return object of type 'void *' with an rvalue of type 'int'}} #else // expected-warning@-4 {{expression which evaluates to zero treated as a null pointer constant of type 'void *'}} // expected-warning@-5 {{'operator new' should not return a null pointer unless it is declared 'throw()'}} #endif } void *operator new[](size_t n) { return (void*)(1-1); // expected-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()'}} } }; #if __cplusplus >= 201103L template<bool B> struct S4 { void *operator new(size_t n) noexcept(B) { return 0; // expected-warning {{'operator new' should not return a null pointer}} } }; template struct S4<true>; template struct S4<false>; // expected-note {{in instantiation of}} #endif template<typename ...T> struct S5 { // expected-warning 0-1{{extension}} void *operator new(size_t n) throw(T...) { return 0; // expected-warning {{'operator new' should not return a null pointer}} } }; template struct S5<>; template struct S5<int>; // expected-note {{in instantiation of}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/default-constructor-initializers.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct X1 { // has no implicit default constructor X1(int); }; struct X2 : X1 { // expected-note 2 {{'X2' declared here}} X2(int); }; struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} }; X3 x3; // expected-note {{first required here}} struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \ // expected-error {{must explicitly initialize the reference member 'rx2'}} X2 x2; // expected-note {{member is declared here}} X2 & rx2; // expected-note {{declared here}} }; X4 x4; // expected-note {{first required here}} struct Y1 { // has no implicit default constructor Y1(int); }; struct Y2 : Y1 { Y2(int); Y2(); }; struct Y3 : public Y2 { }; Y3 y3; struct Y4 { Y2 y2; }; Y4 y4; // More tests struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \ // expected-error {{must explicitly initialize the const member 'c1'}} int& z; // expected-note {{declared here}} const int c1; // expected-note {{declared here}} volatile int v1; }; // Test default initialization which *requires* a constructor call for non-POD. Z1 z1; // expected-note {{first required here}} // Ensure that value initialization doesn't use trivial implicit constructors. namespace PR7948 { // Note that this is also non-POD to ensure we don't just special case PODs. struct S { const int x; ~S(); }; const S arr[2] = { { 42 } }; } // This is valid union U { const int i; float f; }; U u;
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/declspec-thread.cpp
// RUN: %clang_cc1 -triple i686-pc-win32 -std=c++11 -fms-extensions -fms-compatibility-version=18.00 -verify %s // RUN: %clang_cc1 -triple i686-pc-win32 -std=c++11 -fms-extensions -fms-compatibility-version=19.00 -verify %s __thread __declspec(thread) int a; // expected-error {{already has a thread-local storage specifier}} __declspec(thread) __thread int b; // expected-error {{already has a thread-local storage specifier}} __declspec(thread) int c(); // expected-warning {{only applies to variables}} __declspec(thread) int d; int foo(); #if _MSC_VER >= 1900 __declspec(thread) int e = foo(); #else __declspec(thread) int e = foo(); // expected-error {{must be a constant expression}} expected-note {{thread_local}} #endif struct HasCtor { HasCtor(); int x; }; #if _MSC_VER >= 1900 __declspec(thread) HasCtor f; #else __declspec(thread) HasCtor f; // expected-error {{must be a constant expression}} expected-note {{thread_local}} #endif struct HasDtor { ~HasDtor(); int x; }; #if _MSC_VER >= 1900 __declspec(thread) HasDtor g; #else __declspec(thread) HasCtor g; // expected-error {{must be a constant expression}} expected-note {{thread_local}} #endif struct HasDefaultedDefaultCtor { HasDefaultedDefaultCtor() = default; int x; }; __declspec(thread) HasDefaultedDefaultCtor h; struct HasConstexprCtor { constexpr HasConstexprCtor(int x) : x(x) {} int x; }; __declspec(thread) HasConstexprCtor i(42); int foo() { __declspec(thread) int a; // expected-error {{must have global storage}} static __declspec(thread) int b; } extern __declspec(thread) int fwd_thread_var; __declspec(thread) int fwd_thread_var = 5; extern int fwd_thread_var_mismatch; // expected-note {{previous declaration}} __declspec(thread) int fwd_thread_var_mismatch = 5; // expected-error-re {{thread-local {{.*}} follows non-thread-local}} extern __declspec(thread) int thread_mismatch_2; // expected-note {{previous declaration}} int thread_mismatch_2 = 5; // expected-error-re {{non-thread-local {{.*}} follows thread-local}} typedef __declspec(thread) int tls_int_t; // expected-warning {{only applies to variables}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx-altivec.cpp
// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s struct Vector { __vector float xyzw; } __attribute__((vecreturn)) __attribute__((vecreturn)); // expected-error {{'vecreturn' attribute cannot be repeated}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/ambig-user-defined-conversions.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s namespace test0 { struct BASE { operator int &(); // expected-note {{candidate function}} }; struct BASE1 { operator int &(); // expected-note {{candidate function}} }; struct B : public BASE, BASE1 {}; extern B f(); B b1; void func(const int ci, const char cc); // expected-note {{candidate function}} void func(const char ci, const B b); // expected-note {{candidate function}} void func(const B b, const int ci); // expected-note {{candidate function}} const int Test1() { func(b1, f()); // expected-error {{call to 'func' is ambiguous}} return f(); // expected-error {{conversion from 'test0::B' to 'const int' is ambiguous}} } // This used to crash when comparing the two operands. void func2(const char cc); // expected-note {{candidate function}} void func2(const int ci); // expected-note {{candidate function}} void Test2() { func2(b1); // expected-error {{call to 'func2' is ambiguous}} } } namespace test1 { struct E; struct A { A (E&); }; struct E { operator A (); }; struct C { C (E&); }; void f1(A); // expected-note {{candidate function}} void f1(C); // expected-note {{candidate function}} void Test2() { E b; f1(b); // expected-error {{call to 'f1' is ambiguous}} // ambiguous because b -> C via constructor and // b -> A via constructor or conversion function. } } namespace rdar8876150 { struct A { operator bool(); }; struct B : A { }; struct C : A { }; struct D : B, C { }; bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'rdar8876150::D' to base class 'rdar8876150::A':}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overloaded-builtin-operators.cpp
// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu %s struct yes; struct no; struct Short { operator short(); }; struct Long { operator long(); }; enum E1 { }; struct Enum1 { operator E1(); }; enum E2 { }; struct Enum2 { operator E2(); }; struct X { void f(); }; typedef void (X::*pmf)(); struct Xpmf { operator pmf(); }; yes& islong(long); yes& islong(unsigned long); // FIXME: shouldn't be needed no& islong(int); void f(Short s, Long l, Enum1 e1, Enum2 e2, Xpmf pmf) { // C++ [over.built]p8 int i1 = +e1; int i2 = -e2; // C++ [over.built]p10: int i3 = ~s; bool b1 = !s; // C++ [over.built]p12 (void)static_cast<yes&>(islong(s + l)); (void)static_cast<no&>(islong(s + s)); // C++ [over.built]p16 (void)(pmf == &X::f); (void)(pmf == 0); // C++ [over.built]p17 (void)static_cast<yes&>(islong(s % l)); (void)static_cast<yes&>(islong(l << s)); (void)static_cast<no&>(islong(s << l)); (void)static_cast<yes&>(islong(e1 % l)); // FIXME: should pass (void)static_cast<no&>(islong(e1 % e2)); } struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator)}} operator short&(); }; struct LongRef { operator volatile long&(); }; struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator)}} operator pmf&(); }; struct E2Ref { operator E2&(); }; void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) { // C++ [over.built]p3 short s1 = sr++; // C++ [over.built]p3 long l1 = lr--; // C++ [over.built]p18 short& sr1 = (sr *= lr); volatile long& lr1 = (lr *= sr); // C++ [over.built]p20: E2 e2r2; e2r2 = e2_ref; pmf &pmr = (pmf_ref = &X::f); // expected-error{{no viable overloaded '='}} pmf pmr2; pmr2 = pmf_ref; // C++ [over.built]p22 short& sr2 = (sr %= lr); volatile long& lr2 = (lr <<= sr); bool b1 = (sr && lr) || (sr || lr); } struct VolatileIntPtr { operator int volatile *(); }; struct ConstIntPtr { operator int const *(); }; struct VolatileIntPtrRef { operator int volatile *&(); }; struct ConstIntPtrRef { operator int const *&(); }; void test_with_ptrs(VolatileIntPtr vip, ConstIntPtr cip, ShortRef sr, VolatileIntPtrRef vipr, ConstIntPtrRef cipr) { const int& cir1 = cip[sr]; const int& cir2 = sr[cip]; volatile int& vir1 = vip[sr]; volatile int& vir2 = sr[vip]; bool b1 = (vip == cip); long p1 = vip - cip; // C++ [over.built]p5: int volatile *vip1 = vipr++; int const *cip1 = cipr++; int volatile *&vipr1 = ++vipr; int const *&cipr1 = --cipr; // C++ [over.built]p6: int volatile &ivr = *vip; // C++ [over.built]p8: int volatile *vip2 = +vip; int i1 = +sr; int i2 = -sr; // C++ [over.built]p13: int volatile &ivr2 = vip[17]; int const &icr2 = 17[cip]; } // C++ [over.match.open]p4 void test_assign_restrictions(ShortRef& sr) { sr = (short)0; // expected-error{{no viable overloaded '='}} } struct Base { }; struct Derived1 : Base { }; struct Derived2 : Base { }; template<typename T> struct ConvertibleToPtrOf { operator T*(); }; bool test_with_base_ptrs(ConvertibleToPtrOf<Derived1> d1, ConvertibleToPtrOf<Derived2> d2) { return d1 == d2; // expected-error{{invalid operands}} } // DR425 struct A { template< typename T > operator T() const; }; void test_dr425(A a) { // FIXME: lots of candidates here! (void)(1.0f * a); // expected-error{{ambiguous}} \ // expected-note 4{{candidate}} \ // expected-note {{remaining 117 candidates omitted; pass -fshow-overloads=all to show them}} } // pr5432 enum e {X}; const int a[][2] = {{1}}; int test_pr5432() { return a[X][X]; } void f() { (void)__extension__(A()); } namespace PR7319 { typedef enum { Enum1, Enum2, Enum3 } MyEnum; template<typename X> bool operator>(const X &inX1, const X &inX2); void f() { MyEnum e1, e2; if (e1 > e2) {} } } namespace PR8477 { struct Foo { operator bool(); operator const char *(); }; bool doit() { Foo foo; long long zero = 0; (void)(foo + zero); (void)(foo - zero); (void)(zero + foo); (void)(zero[foo]); (void)(foo - foo); // expected-error{{use of overloaded operator '-' is ambiguous}} \ // expected-note 4{{built-in candidate operator-}} \ // expected-note{{candidates omitted}} return foo[zero] == zero; } } namespace PR7851 { struct X { operator const void *() const; operator void *(); operator const unsigned *() const; operator unsigned *(); }; void f() { X x; x[0] = 1; *x = 0; (void)(x - x); } } namespace PR12854 { enum { size = 1 }; void plus_equals() { int* __restrict py; py += size; } struct RestrictInt { operator int* __restrict &(); }; void user_conversions(RestrictInt ri) { ++ri; --ri; ri++; ri--; } } namespace PR12964 { struct X { operator __int128() const; } x; bool a = x == __int128(0); bool b = x == 0; struct Y { operator unsigned __int128() const; } y; bool c = y == __int128(0); bool d = y == 0; bool e = x == y; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/unused-functions.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused -verify %s // expected-no-diagnostics static int foo(int x) { return x; } template<typename T> T get_from_foo(T y) { return foo(y); } int g(int z) { return get_from_foo(z); } namespace { void f() = delete; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/static-cast.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A {}; struct B : public A {}; // Single public base. struct C1 : public virtual B {}; // Single virtual base. struct C2 : public virtual B {}; struct D : public C1, public C2 {}; // Diamond struct E : private A {}; // Single private base. expected-note 3 {{declared private here}} struct F : public C1 {}; // Single path to B with virtual. struct G1 : public B {}; struct G2 : public B {}; struct H : public G1, public G2 {}; // Ambiguous path to B. struct I; // Incomplete. expected-note {{'I' is incomplete}} struct J; // Incomplete. expected-note {{'J' is incomplete}} enum Enum { En1, En2 }; enum Onom { On1, On2 }; struct Co1 { operator int(); }; struct Co2 { Co2(int); }; struct Co3 { }; struct Co4 { Co4(Co3); operator Co3(); }; // Explicit implicits void t_529_2() { int i = 1; (void)static_cast<float>(i); double d = 1.0; (void)static_cast<float>(d); (void)static_cast<int>(d); (void)static_cast<char>(i); (void)static_cast<unsigned long>(i); (void)static_cast<int>(En1); (void)static_cast<double>(En1); (void)static_cast<int&>(i); (void)static_cast<const int&>(i); int ar[1]; (void)static_cast<const int*>(ar); (void)static_cast<void (*)()>(t_529_2); (void)static_cast<void*>(0); (void)static_cast<void*>((int*)0); (void)static_cast<volatile const void*>((const int*)0); (void)static_cast<A*>((B*)0); (void)static_cast<A&>(*((B*)0)); (void)static_cast<const B*>((C1*)0); (void)static_cast<B&>(*((C1*)0)); (void)static_cast<A*>((D*)0); (void)static_cast<const A&>(*((D*)0)); (void)static_cast<int B::*>((int A::*)0); (void)static_cast<void (B::*)()>((void (A::*)())0); (void)static_cast<int>(Co1()); (void)static_cast<Co2>(1); (void)static_cast<Co3>(static_cast<Co4>(Co3())); // Bad code below (void)static_cast<void*>((const int*)0); // expected-error {{static_cast from 'const int *' to 'void *' is not allowed}} (void)static_cast<A*>((E*)0); // expected-error {{cannot cast 'E' to its private base class 'A'}} (void)static_cast<A*>((H*)0); // expected-error {{ambiguous conversion}} (void)static_cast<int>((int*)0); // expected-error {{static_cast from 'int *' to 'int' is not allowed}} (void)static_cast<A**>((B**)0); // expected-error {{static_cast from 'B **' to 'A **' is not allowed}} (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}} } // Anything to void void t_529_4() { static_cast<void>(1); static_cast<void>(t_529_4); } // Static downcasts void t_529_5_8() { (void)static_cast<B*>((A*)0); (void)static_cast<B&>(*((A*)0)); (void)static_cast<const G1*>((A*)0); (void)static_cast<const G1&>(*((A*)0)); // Bad code below (void)static_cast<C1*>((A*)0); // expected-error {{cannot cast 'A *' to 'C1 *' via virtual base 'B'}} (void)static_cast<C1&>(*((A*)0)); // expected-error {{cannot cast 'A' to 'C1 &' via virtual base 'B'}} (void)static_cast<D*>((A*)0); // expected-error {{cannot cast 'A *' to 'D *' via virtual base 'B'}} (void)static_cast<D&>(*((A*)0)); // expected-error {{cannot cast 'A' to 'D &' via virtual base 'B'}} (void)static_cast<B*>((const A*)0); // expected-error {{static_cast from 'const A *' to 'B *' casts away qualifiers}} (void)static_cast<B&>(*((const A*)0)); // expected-error {{static_cast from 'const A' to 'B &' casts away qualifiers}} (void)static_cast<E*>((A*)0); // expected-error {{cannot cast private base class 'A' to 'E'}} (void)static_cast<E&>(*((A*)0)); // expected-error {{cannot cast private base class 'A' to 'E'}} (void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}} (void)static_cast<H&>(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}} (void)static_cast<E*>((B*)0); // expected-error {{static_cast from 'B *' to 'E *', which are not related by inheritance, is not allowed}} (void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot bind to a value of unrelated type 'B'}} (void)static_cast<E*>((J*)0); // expected-error {{static_cast from 'J *' to 'E *', which are not related by inheritance, is not allowed}} (void)static_cast<I*>((B*)0); // expected-error {{static_cast from 'B *' to 'I *', which are not related by inheritance, is not allowed}} // TODO: Test inaccessible base in context where it's accessible, i.e. // member function and friend. // TODO: Test DR427. This requires user-defined conversions, though. } // Enum conversions void t_529_7() { (void)static_cast<Enum>(1); (void)static_cast<Enum>(1.0); (void)static_cast<Onom>(En1); // Bad code below (void)static_cast<Enum>((int*)0); // expected-error {{static_cast from 'int *' to 'Enum' is not allowed}} } // Void pointer to object pointer void t_529_10() { (void)static_cast<int*>((void*)0); (void)static_cast<const A*>((void*)0); // Bad code below (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'const void *' to 'int *' casts away qualifiers}} (void)static_cast<void (*)()>((void*)0); // expected-error {{static_cast from 'void *' to 'void (*)()' is not allowed}} } // Member pointer upcast. void t_529_9() { (void)static_cast<int A::*>((int B::*)0); // Bad code below (void)static_cast<int A::*>((int H::*)0); // expected-error {{ambiguous conversion from pointer to member of derived class 'H' to pointer to member of base class 'A':}} (void)static_cast<int A::*>((int F::*)0); // expected-error {{conversion from pointer to member of class 'F' to pointer to member of class 'A' via virtual base 'B' is not allowed}} (void)static_cast<int I::*>((int J::*)0); // expected-error {{static_cast from 'int J::*' to 'int I::*' is not allowed}} } // PR 5261 - static_cast should instantiate template if possible namespace pr5261 { struct base {}; template<typename E> struct derived : public base {}; template<typename E> struct outer { base *pb; ~outer() { (void)static_cast<derived<E>*>(pb); } }; outer<int> EntryList; } // Initialization by constructor struct X0; struct X1 { X1(); X1(X1&); X1(const X0&); operator X0() const; }; struct X0 { }; void test_ctor_init() { (void)static_cast<X1>(X1()); } // Casting away constness struct X2 { }; struct X3 : X2 { }; struct X4 { typedef const X3 X3_typedef; void f() const { (void)static_cast<X3_typedef*>(x2); } const X2 *x2; }; // PR5897 - accept static_cast from const void* to const int (*)[1]. void PR5897() { (void)static_cast<const int(*)[1]>((const void*)0); } namespace PR6072 { struct A { }; struct B : A { void f(int); void f(); }; // expected-note 2{{candidate function}} struct C : B { }; struct D { }; void f() { (void)static_cast<void (A::*)()>(&B::f); (void)static_cast<void (B::*)()>(&B::f); (void)static_cast<void (C::*)()>(&B::f); (void)static_cast<void (D::*)()>(&B::f); // expected-error-re{{address of overloaded function 'f' cannot be static_cast to type 'void (PR6072::D::*)(){{( __attribute__\(\(thiscall\)\))?}}'}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/return-stack-addr.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s int* ret_local() { int x = 1; return &x; // expected-warning {{address of stack memory}} } int* ret_local_array() { int x[10]; return x; // expected-warning {{address of stack memory}} } int* ret_local_array_element(int i) { int x[10]; return &x[i]; // expected-warning {{address of stack memory}} } int *ret_local_array_element_reversed(int i) { int x[10]; return &i[x]; // expected-warning {{address of stack memory}} } int* ret_local_array_element_const_index() { int x[10]; return &x[2]; // expected-warning {{address of stack memory}} } int& ret_local_ref() { int x = 1; return x; // expected-warning {{reference to stack memory}} } int* ret_local_addrOf() { int x = 1; return &*&x; // expected-warning {{address of stack memory}} } int* ret_local_addrOf_paren() { int x = 1; return (&(*(&x))); // expected-warning {{address of stack memory}} } int* ret_local_addrOf_ptr_arith() { int x = 1; return &*(&x+1); // expected-warning {{address of stack memory}} } int* ret_local_addrOf_ptr_arith2() { int x = 1; return &*(&x+1); // expected-warning {{address of stack memory}} } int* ret_local_field() { struct { int x; } a; return &a.x; // expected-warning {{address of stack memory}} } int& ret_local_field_ref() { struct { int x; } a; return a.x; // expected-warning {{reference to stack memory}} } int* ret_conditional(bool cond) { int x = 1; int y = 2; return cond ? &x : &y; // expected-warning {{address of stack memory}} } int* ret_conditional_rhs(int *x, bool cond) { int y = 1; return cond ? x : &y; // expected-warning {{address of stack memory}} } void* ret_c_cast() { int x = 1; return (void*) &x; // expected-warning {{address of stack memory}} } int* ret_static_var() { static int x = 1; return &x; // no warning. } int z = 1; int* ret_global() { return &z; // no warning. } int* ret_parameter(int x) { return &x; // expected-warning {{address of stack memory}} } void* ret_cpp_static_cast(short x) { return static_cast<void*>(&x); // expected-warning {{address of stack memory}} } int* ret_cpp_reinterpret_cast(double x) { return reinterpret_cast<int*>(&x); // expected-warning {{address of stack me}} } int* ret_cpp_reinterpret_cast_no_warning(long x) { return reinterpret_cast<int*>(x); // no-warning } int* ret_cpp_const_cast(const int x) { return const_cast<int*>(&x); // expected-warning {{address of stack memory}} } struct A { virtual ~A(); }; struct B : A {}; A* ret_cpp_dynamic_cast(B b) { return dynamic_cast<A*>(&b); // expected-warning {{address of stack memory}} } // PR 7999 - handle the case where a field is itself a reference. template <typename T> struct PR7999 { PR7999(T& t) : value(t) {} T& value; }; struct PR7999_X {}; PR7999_X& PR7999_f(PR7999<PR7999_X> s) { return s.value; } // no-warning void test_PR7999(PR7999_X& x) { (void)PR7999_f(x); } // no-warning // PR 8774: Don't try to evaluate parameters with default arguments like // variables with an initializer, especially in templates where the default // argument may not be an expression (yet). namespace PR8774 { template <typename U> struct B { }; template <typename V> V f(typename B<V>::type const &v = B<V>::value()) { return v; } template <> struct B<const char *> { typedef const char *type; static const char *value(); }; void g() { const char *t; f<const char*>(t); } } // Don't warn about returning a local variable from a surrounding function if // we're within a lambda-expression. void ret_from_lambda() { int a; int &b = a; (void) [&]() -> int& { return a; }; (void) [&]() -> int& { return b; }; (void) [=]() mutable -> int& { return a; }; (void) [=]() mutable -> int& { return b; }; (void) [&]() -> int& { int a; return a; }; // expected-warning {{reference to stack}} (void) [=]() -> int& { int a; return a; }; // expected-warning {{reference to stack}} (void) [&]() -> int& { int &a = b; return a; }; (void) [=]() mutable -> int& { int &a = b; return a; }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/pseudo-destructors.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct A {}; enum Foo { F }; typedef Foo Bar; // expected-note{{type 'Bar' (aka 'Foo') is declared here}} typedef int Integer; typedef double Double; void g(); namespace N { typedef Foo Wibble; typedef int OtherInteger; } template <typename T> void cv_test(const volatile T* cvt) { cvt->T::~T(); // no-warning } void f(A* a, Foo *f, int *i, double *d, int ii) { a->~A(); a->A::~A(); a->~foo(); // expected-error{{identifier 'foo' in object destruction expression does not name a type}} a->~Bar(); // expected-error{{destructor type 'Bar' (aka 'Foo') in object destruction expression does not match the type 'A' of the object being destroyed}} f->~Bar(); f->~Foo(); i->~Bar(); // expected-error{{does not match}} g().~Bar(); // expected-error{{non-scalar}} f->::~Bar(); f->N::~Wibble(); // FIXME: technically, Wibble isn't a class-name f->::~Bar(17, 42); // expected-error{{cannot have any arguments}} i->~Integer(); i->Integer::~Integer(); i->N::~OtherInteger(); i->N::OtherInteger::~OtherInteger(); i->N::OtherInteger::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}} i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}} i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('Double' (aka 'double')) in pseudo-destructor expression}} ii->~Integer(); // expected-error{{member reference type 'int' is not a pointer; did you mean to use '.'?}} ii.~Integer(); cv_test(a); cv_test(f); cv_test(i); cv_test(d); } typedef int Integer; void destroy_without_call(int *ip) { ip->~Integer; // expected-error{{reference to pseudo-destructor must be called}} } void paren_destroy_with_call(int *ip) { (ip->~Integer)(); } // PR5530 namespace N1 { class X0 { }; } void test_X0(N1::X0 &x0) { x0.~X0(); } namespace PR11339 { template<class T> void destroy(T* p) { p->~T(); // ok p->~oops(); // expected-error{{expected the class name after '~' to name a destructor}} } template void destroy(int*); // expected-note{{in instantiation of function template specialization}} } template<typename T> using Id = T; void AliasTemplate(int *p) { p->~Id<int>(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-nonnull.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct S { S(const char *) __attribute__((nonnull(2))); static void f(const char*, const char*) __attribute__((nonnull(1))); // GCC has a hidden 'this' argument in member functions, so the middle // argument is the one that must not be null. void g(const char*, const char*, const char*) __attribute__((nonnull(3))); void h(const char*) __attribute__((nonnull(1))); // \ expected-error{{invalid for the implicit this argument}} }; void test() { S s(0); // expected-warning{{null passed}} s.f(0, ""); // expected-warning{{null passed}} s.f("", 0); s.g("", 0, ""); // expected-warning{{null passed}} s.g(0, "", 0); } namespace rdar8769025 { __attribute__((nonnull)) void f0(int *&p); __attribute__((nonnull)) void f1(int * const &p); __attribute__((nonnull(2))) void f2(int i, int * const &p); void test_f1() { f1(0); // expected-warning{{null passed to a callee that requires a non-null argument}} f2(0, 0); // expected-warning{{null passed to a callee that requires a non-null argument}} } } namespace test3 { __attribute__((nonnull(1))) void f(void *ptr); void g() { f(static_cast<char*>((void*)0)); // expected-warning{{null passed}} f(static_cast<char*>(0)); // expected-warning{{null passed}} } } namespace test4 { struct X { bool operator!=(const void *) const __attribute__((nonnull(2))); }; bool operator==(const X&, const void *) __attribute__((nonnull(2))); void test(const X& x) { (void)(x == 0); // expected-warning{{null passed}} (void)(x != 0); // expected-warning{{null passed}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/function-type-qual.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s void f() const; // expected-error {{non-member function cannot have 'const' qualifier}} void (*pf)() const; // expected-error {{pointer to function type cannot have 'const' qualifier}} extern void (&rf)() const; // expected-error {{reference to function type cannot have 'const' qualifier}} typedef void cfn() const; cfn f2; // expected-error {{non-member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}} class C { void f() const; cfn f2; static void f3() const; // expected-error {{static member function cannot have 'const' qualifier}} static cfn f4; // expected-error {{static member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}} void m1() { x = 0; } void m2() const { // expected-note {{member function 'C::m2' is declared const here}} x = 0; // expected-error {{cannot assign to non-static data member within const member function 'm2'}} } int x; }; void (C::*mpf)() const; cfn C::*mpg; // Don't crash! void (PR14171)() const; // expected-error {{non-member function cannot have 'const' qualifier}} // Test template instantiation of decayed array types. Not really related to // type quals. template <typename T> void arrayDecay(const T a[]) { } void instantiateArrayDecay() { int a[1]; arrayDecay(a); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-vla.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wvla %s void test1(int n) { int v[n]; // expected-warning {{variable length array used}} } void test2(int n, int v[n]) { // expected-warning {{variable length array used}} } void test3(int n, int v[n]); // expected-warning {{variable length array used}} template<typename T> void test4(int n) { int v[n]; // expected-warning {{variable length array used}} } template<typename T> void test5(int n, int v[n]) { // expected-warning {{variable length array used}} } template<typename T> void test6(int n, int v[n]); // expected-warning {{variable length array used}} template<typename T> void test7(int n, T v[n]) { // expected-warning {{variable length array used}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/constexpr-duffs-device.cpp
// RUN: %clang_cc1 -std=c++1y -verify %s // expected-no-diagnostics constexpr void copy(const char *from, unsigned long count, char *to) { unsigned long n = (count + 7) / 8; switch(count % 8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } while(--n > 0); } } struct S { char stuff[14]; constexpr S() : stuff{} { copy("Hello, world!", 14, stuff); } }; constexpr bool streq(const char *a, const char *b) { while (*a && *a == *b) ++a, ++b; return *a == *b; } static_assert(streq(S().stuff, "Hello, world!"), "should be same"); static_assert(!streq(S().stuff, "Something else"), "should be different");
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/unknown-anytype-blocks.cpp
// RUN: %clang_cc1 -funknown-anytype -fblocks -fsyntax-only -verify -std=c++11 %s namespace test1 { __unknown_anytype (^foo)(); __unknown_anytype (^bar)(); int test() { auto ret1 = (int)foo(); auto ret2 = bar(); // expected-error {{'bar' has unknown return type; cast the call to its declared return type}} return ret1; } }