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/bool.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s // RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion \ // RUN: -Wno-deprecated -Wdeprecated-increment-bool %s // Bool literals can be enum values. enum { ReadWrite = false, ReadOnly = true }; // bool cannot be decremented, and gives a warning on increment void test(bool b) { ++b; // expected-warning {{incrementing expression of type bool is deprecated}} b++; // expected-warning {{incrementing expression of type bool is deprecated}} --b; // expected-error {{cannot decrement expression of type bool}} b--; // expected-error {{cannot decrement expression of type bool}} bool *b1 = (int *)0; // expected-error{{cannot initialize}} } // static_assert_arg_is_bool(x) compiles only if x is a bool. template <typename T> void static_assert_arg_is_bool(T x) { bool* p = &x; } void test2() { int n = 2; static_assert_arg_is_bool(n && 4); // expected-warning {{use of logical '&&' with constant operand}} \ // expected-note {{use '&' for a bitwise operation}} \ // expected-note {{remove constant to silence this warning}} static_assert_arg_is_bool(n || 5); // expected-warning {{use of logical '||' with constant operand}} \ // expected-note {{use '|' for a bitwise operation}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/lambda-expressions.cpp
// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks %s // RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks %s namespace std { class type_info; }; namespace ExplicitCapture { class C { int Member; static void Overload(int); void Overload(); virtual C& Overload(float); void ImplicitThisCapture() { [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}} [&](){(void)Member;}; [this](){(void)Member;}; [this]{[this]{};}; []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} []{Overload(3);}; []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} []{(void)typeid(Overload());}; []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} } }; void f() { [this] () {}; // expected-error {{'this' cannot be captured in this context}} } } namespace ReturnDeduction { void test() { [](){ return 1; }; [](){ return 1; }; [](){ return ({return 1; 1;}); }; [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} []()->int{ return 'c'; return 1; }; [](){ return 'c'; return 1; }; // expected-error {{must match previous return type}} []() { return; return (void)0; }; [](){ return 1; return 1; }; } } namespace ImplicitCapture { void test() { int a = 0; // expected-note 5 {{declared}} []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} [&]() { return a; }; [=]() { return a; }; [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}} [=]() { return [&]() { return a; }; }; []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}} [=]() { return [&a] { return a; }; }; // const int b = 2; []() { return b; }; union { // expected-note {{declared}} int c; float d; }; d = 3; [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}} __block int e; // expected-note 3 {{declared}} [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}} int f[10]; // expected-note {{declared}} [&]() { return f[2]; }; (void) ^{ return []() { return f[2]; }; }; // expected-error {{variable 'f' cannot be implicitly captured in a lambda with no capture-default specified}} \ // expected-note{{lambda expression begins here}} struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}} G g; [=]() { const G* gg = &g; return gg->a; }; [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'G'}} (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const G'}} const int h = a; // expected-note {{declared}} []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} // References can appear in constant expressions if they are initialized by // reference constant expressions. int i; int &ref_i = i; // expected-note {{declared}} [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} static int j; int &ref_j = j; [] { return ref_j; }; // ok } } namespace PR12031 { struct X { template<typename T> X(const T&); ~X(); }; void f(int i, X x); void g() { const int v = 10; f(v, [](){}); } } namespace Array { int &f(int *p); char &f(...); void g() { int n = -1; [=] { int arr[n]; // VLA } (); const int m = -1; [] { int arr[m]; // expected-error{{negative size}} } (); [&] { int arr[m]; // expected-error{{negative size}} } (); [=] { int arr[m]; // expected-error{{negative size}} } (); [m] { int arr[m]; // expected-error{{negative size}} } (); } } void PR12248() { unsigned int result = 0; auto l = [&]() { ++result; }; } namespace ModifyingCapture { void test() { int n = 0; [=] { n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}} }; } } namespace VariadicPackExpansion { template<typename T, typename U> using Fst = T; template<typename...Ts> bool g(Fst<bool, Ts> ...bools); template<typename...Ts> bool f(Ts &&...ts) { return g<Ts...>([&ts] { if (!ts) return false; --ts; return true; } () ...); } void h() { int a = 5, b = 2, c = 3; while (f(a, b, c)) { } } struct sink { template<typename...Ts> sink(Ts &&...) {} }; template<typename...Ts> void local_class() { sink { [] (Ts t) { struct S : Ts { void f(Ts t) { Ts &that = *this; that = t; } Ts g() { return *this; }; }; S s; s.f(t); return s; } (Ts()).g() ... }; }; struct X {}; struct Y {}; template void local_class<X, Y>(); template<typename...Ts> void nested(Ts ...ts) { f( // Each expansion of this lambda implicitly captures all of 'ts', because // the inner lambda also expands 'ts'. [&] { return ts + [&] { return f(ts...); } (); } () ... ); } template void nested(int, int, int); template<typename...Ts> void nested2(Ts ...ts) { // expected-note 2{{here}} // Capture all 'ts', use only one. f([&ts...] { return ts; } ()...); // Capture each 'ts', use it. f([&ts] { return ts; } ()...); // Capture all 'ts', use all of them. f([&ts...] { return (int)f(ts...); } ()); // Capture each 'ts', use all of them. Ill-formed. In more detail: // // We instantiate two lambdas here; the first captures ts$0, the second // captures ts$1. Both of them reference both ts parameters, so both are // ill-formed because ts can't be implicitly captured. // // FIXME: This diagnostic does not explain what's happening. We should // specify which 'ts' we're referring to in its diagnostic name. We should // also say which slice of the pack expansion is being performed in the // instantiation backtrace. f([&ts] { return (int)f(ts...); } ()...); // \ // expected-error 2{{'ts' cannot be implicitly captured}} \ // expected-note 2{{lambda expression begins here}} } template void nested2(int); // ok template void nested2(int, int); // expected-note {{in instantiation of}} } namespace PR13860 { void foo() { auto x = PR13860UndeclaredIdentifier(); // expected-error {{use of undeclared identifier 'PR13860UndeclaredIdentifier'}} auto y = [x]() { }; static_assert(sizeof(y), ""); } } namespace PR13854 { auto l = [](void){}; } namespace PR14518 { auto f = [](void) { return __func__; }; // no-warning } namespace PR16708 { auto L = []() { auto ret = 0; return ret; return 0; }; } namespace TypeDeduction { struct S {}; void f() { const S s {}; S &&t = [&] { return s; } (); #if __cplusplus > 201103L S &&u = [&] () -> auto { return s; } (); #endif } } namespace lambdas_in_NSDMIs { template<class T> struct L { T t{}; T t2 = ([](int a) { return [](int b) { return b; };})(t)(t); }; L<int> l; namespace non_template { struct L { int t = 0; int t2 = ([](int a) { return [](int b) { return b; };})(t)(t); }; L l; } } // PR18477: don't try to capture 'this' from an NSDMI encountered while parsing // a lambda. namespace NSDMIs_in_lambdas { template<typename T> struct S { int a = 0; int b = a; }; void f() { []() { S<int> s; }; } auto x = []{ struct S { int n, m = n; }; }; auto y = [&]{ struct S { int n, m = n; }; }; // expected-error {{non-local lambda expression cannot have a capture-default}} void g() { auto z = [&]{ struct S { int n, m = n; }; }; } } namespace CaptureIncomplete { struct Incomplete; // expected-note 2{{forward decl}} void g(const Incomplete &a); void f(Incomplete &a) { (void) [a] {}; // expected-error {{incomplete}} (void) [&a] {}; (void) [=] { g(a); }; // expected-error {{incomplete}} (void) [&] { f(a); }; } } namespace CaptureAbstract { struct S { virtual void f() = 0; // expected-note {{unimplemented}} int n = 0; }; struct T : S { constexpr T() {} void f(); }; void f() { constexpr T t = T(); S &s = const_cast<T&>(t); // FIXME: Once we properly compute odr-use per DR712, this should be // accepted (and should not capture 's'). [=] { return s.n; }; // expected-error {{abstract}} } } namespace PR18128 { auto l = [=]{}; // expected-error {{non-local lambda expression cannot have a capture-default}} struct S { int n; int (*f())[true ? 1 : ([=]{ return n; }(), 0)]; // expected-error@-1 {{non-local lambda expression cannot have a capture-default}} // expected-error@-2 {{invalid use of non-static data member 'n'}} // expected-error@-3 {{a lambda expression may not appear inside of a constant expression}} int g(int k = ([=]{ return n; }(), 0)); // expected-error@-1 {{non-local lambda expression cannot have a capture-default}} // expected-error@-2 {{invalid use of non-static data member 'n'}} int a = [=]{ return n; }(); // ok int b = [=]{ return [=]{ return n; }(); }(); // ok int c = []{ int k = 0; return [=]{ return k; }(); }(); // ok int d = []{ return [=]{ return n; }(); }(); // expected-error {{'this' cannot be implicitly captured in this context}} }; } namespace PR18473 { template<typename T> void f() { T t(0); (void) [=]{ int n = t; }; // expected-error {{deleted}} } template void f<int>(); struct NoCopy { NoCopy(int); NoCopy(const NoCopy &) = delete; // expected-note {{deleted}} operator int() const; }; template void f<NoCopy>(); // expected-note {{instantiation}} } void PR19249() { auto x = [&x]{}; // expected-error {{cannot appear in its own init}} } namespace PR20731 { template <class L, int X = sizeof(L)> void Job(L l); template <typename... Args> void Logger(Args &&... args) { auto len = Invalid_Function((args)...); // expected-error@-1 {{use of undeclared identifier 'Invalid_Function'}} Job([len]() {}); } void GetMethod() { Logger(); // expected-note@-1 {{in instantiation of function template specialization 'PR20731::Logger<>' requested here}} } template <typename T> struct A { T t; // expected-error@-1 {{field has incomplete type 'void'}} }; template <typename F> void g(F f) { auto a = A<decltype(f())>{}; // expected-note@-1 {{in instantiation of template class 'PR20731::A<void>' requested here}} auto xf = [a, f]() {}; int x = sizeof(xf); }; void f() { g([] {}); // expected-note-re@-1 {{in instantiation of function template specialization 'PR20731::g<(lambda at {{.*}}>' requested here}} } template <class _Rp> struct function { template <class _Fp> function(_Fp) { static_assert(sizeof(_Fp) > 0, "Type must be complete."); } }; template <typename T> void p(T t) { auto l = some_undefined_function(t); // expected-error@-1 {{use of undeclared identifier 'some_undefined_function'}} function<void()>(([l]() {})); } void q() { p(0); } // expected-note@-1 {{in instantiation of function template specialization 'PR20731::p<int>' requested here}} } namespace lambda_in_default_mem_init { template<typename T> void f() { struct S { int n = []{ return 0; }(); }; } template void f<int>(); template<typename T> void g() { struct S { int n = [](int n){ return n; }(0); }; } template void g<int>(); } namespace error_in_transform_prototype { template<class T> void f(T t) { // expected-error@+2 {{type 'int' cannot be used prior to '::' because it has no members}} // expected-error@+1 {{no member named 'ns' in 'error_in_transform_prototype::S'}} auto x = [](typename T::ns::type &k) {}; } class S {}; void foo() { f(5); // expected-note {{requested here}} f(S()); // expected-note {{requested here}} } } namespace PR21857 { template<typename Fn> struct fun : Fn { fun() = default; using Fn::operator(); }; template<typename Fn> fun<Fn> wrap(Fn fn); auto x = wrap([](){}); } namespace PR13987 { class Enclosing { void Method(char c = []()->char { int d = []()->int { struct LocalClass { int Method() { return 0; } }; return 0; }(); return d; }() ); }; } namespace PR23860 { template <class> struct A { void f(int x = []() { struct B { void g() {} }; return 0; }()); }; int main() { } A<int> a; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/devirtualize-vtable-marking.cpp
// RUN: %clang_cc1 -verify -std=c++11 %s // expected-no-diagnostics template <typename T> struct OwnPtr { T *p; ~OwnPtr() { static_assert(sizeof(T) > 0, "incomplete T"); delete p; } }; namespace use_vtable_for_vcall { struct Incomplete; struct A { virtual ~A() {} virtual void m() {} }; struct B : A { B(); virtual void m() { } virtual void m2() { static_cast<A *>(this)->m(); } OwnPtr<Incomplete> m_sqlError; }; void f() { // Since B's constructor is declared out of line, nothing in this file // references a vtable, so the destructor doesn't get built. A *b = new B(); b->m(); delete b; } } namespace dont_mark_qualified_vcall { struct Incomplete; struct A { virtual ~A() {} virtual void m() {} }; struct B : A { B(); // Previously we would mark B's vtable referenced to devirtualize this call to // A::m, even though it's not a virtual call. virtual void m() { A::m(); } OwnPtr<Incomplete> m_sqlError; }; B *f() { return new B(); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/uninit-variables-conditional.cpp
// RUN: %clang_cc1 -fsyntax-only -Wconditional-uninitialized -fsyntax-only %s -verify class Foo { public: Foo(); ~Foo(); operator bool(); }; int bar(); int baz(); int init(double *); // This case flags a false positive under -Wconditional-uninitialized because // the destructor in Foo fouls about the minor bit of path-sensitivity in // -Wuninitialized. double test() { double x; // expected-note{{initialize the variable 'x' to silence this warning}} if (bar() || baz() || Foo() || init(&x)) return 1.0; return x; // expected-warning {{variable 'x' may be uninitialized when used here}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-tautological-compare.cpp
// Force x86-64 because some of our heuristics are actually based // on integer sizes. // RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify -std=c++11 %s namespace RuntimeBehavior { // Avoid emitting tautological compare warnings when the code already has // compile time checks on variable sizes. const int kintmax = 2147483647; void test0(short x) { if (sizeof(x) < sizeof(int) || x < kintmax) {} if (x < kintmax) {} // expected-warning@-1{{comparison of constant 2147483647 with expression of type 'short' is always true}} } void test1(short x) { if (x < kintmax) {} // expected-warning@-1{{comparison of constant 2147483647 with expression of type 'short' is always true}} if (sizeof(x) < sizeof(int)) return; if (x < kintmax) {} } } namespace ArrayCompare { #define GetValue(ptr) ((ptr != 0) ? ptr[0] : 0) extern int a[] __attribute__((weak)); int b[] = {8,13,21}; struct { int x[10]; } c; const char str[] = "text"; void ignore() { if (a == 0) {} if (a != 0) {} (void)GetValue(b); } void test() { if (b == 0) {} // expected-warning@-1{{comparison of array 'b' equal to a null pointer is always false}} if (b != 0) {} // expected-warning@-1{{comparison of array 'b' not equal to a null pointer is always true}} if (0 == b) {} // expected-warning@-1{{comparison of array 'b' equal to a null pointer is always false}} if (0 != b) {} // expected-warning@-1{{comparison of array 'b' not equal to a null pointer is always true}} if (c.x == 0) {} // expected-warning@-1{{comparison of array 'c.x' equal to a null pointer is always false}} if (c.x != 0) {} // expected-warning@-1{{comparison of array 'c.x' not equal to a null pointer is always true}} if (str == 0) {} // expected-warning@-1{{comparison of array 'str' equal to a null pointer is always false}} if (str != 0) {} // expected-warning@-1{{comparison of array 'str' not equal to a null pointer is always true}} } } namespace FunctionCompare { #define CallFunction(f) ((f != 0) ? f() : 0) extern void a() __attribute__((weak)); void fun1(); int fun2(); int* fun3(); int* fun4(int); class S { public: static int foo(); }; void ignore() { if (a == 0) {} if (0 != a) {} (void)CallFunction(fun2); } void test() { if (fun1 == 0) {} // expected-warning@-1{{comparison of function 'fun1' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} if (fun2 == 0) {} // expected-warning@-1{{comparison of function 'fun2' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} // expected-note@-3{{suffix with parentheses to turn this into a function call}} if (fun3 == 0) {} // expected-warning@-1{{comparison of function 'fun3' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} // expected-note@-3{{suffix with parentheses to turn this into a function call}} if (fun4 == 0) {} // expected-warning@-1{{comparison of function 'fun4' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} if (nullptr != fun1) {} // expected-warning@-1{{comparison of function 'fun1' not equal to a null pointer is always true}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} if (nullptr != fun2) {} // expected-warning@-1{{comparison of function 'fun2' not equal to a null pointer is always true}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} if (nullptr != fun3) {} // expected-warning@-1{{comparison of function 'fun3' not equal to a null pointer is always true}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} // expected-note@-3{{suffix with parentheses to turn this into a function call}} if (nullptr != fun4) {} // expected-warning@-1{{comparison of function 'fun4' not equal to a null pointer is always true}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} if (S::foo == 0) {} // expected-warning@-1{{comparison of function 'S::foo' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} // expected-note@-3{{suffix with parentheses to turn this into a function call}} } } namespace PointerCompare { extern int a __attribute__((weak)); int b; static int c; class S { public: static int a; int b; }; void ignored() { if (&a == 0) {} } void test() { S s; if (&b == 0) {} // expected-warning@-1{{comparison of address of 'b' equal to a null pointer is always false}} if (&c == 0) {} // expected-warning@-1{{comparison of address of 'c' equal to a null pointer is always false}} if (&s.a == 0) {} // expected-warning@-1{{comparison of address of 's.a' equal to a null pointer is always false}} if (&s.b == 0) {} // expected-warning@-1{{comparison of address of 's.b' equal to a null pointer is always false}} if (&S::a == 0) {} // expected-warning@-1{{comparison of address of 'S::a' equal to a null pointer is always false}} } } namespace macros { #define assert(x) if (x) {} int array[5]; void fun(); int x; void test() { assert(array == 0); // expected-warning@-1{{comparison of array 'array' equal to a null pointer is always false}} assert(array != 0); // expected-warning@-1{{comparison of array 'array' not equal to a null pointer is always true}} assert(array == 0 && "expecting null pointer"); // expected-warning@-1{{comparison of array 'array' equal to a null pointer is always false}} assert(array != 0 && "expecting non-null pointer"); // expected-warning@-1{{comparison of array 'array' not equal to a null pointer is always true}} assert(fun == 0); // expected-warning@-1{{comparison of function 'fun' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} assert(fun != 0); // expected-warning@-1{{comparison of function 'fun' not equal to a null pointer is always true}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} assert(fun == 0 && "expecting null pointer"); // expected-warning@-1{{comparison of function 'fun' equal to a null pointer is always false}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} assert(fun != 0 && "expecting non-null pointer"); // expected-warning@-1{{comparison of function 'fun' not equal to a null pointer is always true}} // expected-note@-2{{prefix with the address-of operator to silence this warning}} assert(&x == 0); // expected-warning@-1{{comparison of address of 'x' equal to a null pointer is always false}} assert(&x != 0); // expected-warning@-1{{comparison of address of 'x' not equal to a null pointer is always true}} assert(&x == 0 && "expecting null pointer"); // expected-warning@-1{{comparison of address of 'x' equal to a null pointer is always false}} assert(&x != 0 && "expecting non-null pointer"); // expected-warning@-1{{comparison of address of 'x' not equal to a null pointer is always true}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx11-thread-local.cpp
// RUN: %clang_cc1 -std=c++11 -triple=x86_64-linux-gnu -verify %s struct S { static thread_local int a; static int b; // expected-note {{here}} thread_local int c; // expected-error {{'thread_local' is only allowed on variable declarations}} static thread_local int d; // expected-note {{here}} }; thread_local int S::a; thread_local int S::b; // expected-error {{thread-local declaration of 'b' follows non-thread-local declaration}} thread_local int S::c; // expected-error {{non-static data member defined out-of-line}} int S::d; // expected-error {{non-thread-local declaration of 'd' follows thread-local declaration}} thread_local int x[3]; thread_local int y[3]; thread_local int z[3]; // expected-note {{previous}} void f() { thread_local int x; static thread_local int y; extern thread_local int z; // expected-error {{redeclaration of 'z' with a different type}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/copy-constructor-error.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct S { S (S); // expected-error {{copy constructor must pass its first argument by reference}} }; S f(); void g() { S a( f() ); } class foo { foo(foo&, int); // expected-note {{previous}} foo(int); // expected-note {{previous}} foo(const foo&); // expected-note {{previous}} }; foo::foo(foo&, int = 0) { } // expected-error {{makes this constructor a copy constructor}} foo::foo(int = 0) { } // expected-error {{makes this constructor a default constructor}} foo::foo(const foo& = 0) { } //expected-error {{makes this constructor a default constructor}} namespace PR6064 { struct A { A() { } inline A(A&, int); // expected-note {{previous}} }; A::A(A&, int = 0) { } // expected-error {{makes this constructor a copy constructor}} void f() { A const a; A b(a); } } namespace PR10618 { struct A { A(int, int, int); // expected-note {{previous}} }; A::A(int a = 0, // expected-error {{makes this constructor a default constructor}} int b = 0, int c = 0) {} struct B { B(int); B(const B&, int); // expected-note {{previous}} }; B::B(const B& = B(0), // expected-error {{makes this constructor a default constructor}} int = 0) { } struct C { C(const C&, int); // expected-note {{previous}} }; C::C(const C&, int = 0) { // expected-error {{makes this constructor a copy constructor}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/typo-correction-delayed.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s struct A {}; struct B {}; struct D { A fizbin; // expected-note 2 {{declared here}} A foobar; // expected-note 2 {{declared here}} B roxbin; // expected-note 2 {{declared here}} B toobad; // expected-note 2 {{declared here}} void BooHoo(); void FoxBox(); }; void something(A, B); void test() { D obj; something(obj.fixbin, // expected-error {{did you mean 'fizbin'?}} obj.toobat); // expected-error {{did you mean 'toobad'?}} something(obj.toobat, // expected-error {{did you mean 'foobar'?}} obj.fixbin); // expected-error {{did you mean 'roxbin'?}} something(obj.fixbin, // expected-error {{did you mean 'fizbin'?}} obj.fixbin); // expected-error {{did you mean 'roxbin'?}} something(obj.toobat, // expected-error {{did you mean 'foobar'?}} obj.toobat); // expected-error {{did you mean 'toobad'?}} // Both members could be corrected to methods, but that isn't valid. something(obj.boohoo, // expected-error-re {{no member named 'boohoo' in 'D'{{$}}}} obj.foxbox); // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}} // The first argument has a usable correction but the second doesn't. something(obj.boobar, // expected-error-re {{no member named 'boobar' in 'D'{{$}}}} obj.foxbox); // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}} } // Ensure the delayed typo correction does the right thing when trying to // recover using a seemingly-valid correction for which a valid expression to // replace the TypoExpr cannot be created (but which does have a second // correction candidate that would be a valid and usable correction). class Foo { public: template <> void testIt(); // expected-error {{no function template matches}} void textIt(); // expected-note {{'textIt' declared here}} }; void testMemberExpr(Foo *f) { f->TestIt(); // expected-error {{no member named 'TestIt' in 'Foo'; did you mean 'textIt'?}} } void callee(double, double); void testNoCandidates() { callee(xxxxxx, // expected-error-re {{use of undeclared identifier 'xxxxxx'{{$}}}} zzzzzz); // expected-error-re {{use of undeclared identifier 'zzzzzz'{{$}}}} } class string {}; struct Item { void Nest(); string text(); Item* next(); // expected-note {{'next' declared here}} }; void testExprFilter(Item *i) { Item *j; j = i->Next(); // expected-error {{no member named 'Next' in 'Item'; did you mean 'next'?}} } // Test that initializer expressions are handled correctly and that the type // being initialized is taken into account when choosing a correction. namespace initializerCorrections { struct Node { string text() const; // Node* Next() is not implemented yet }; void f(Node *node) { // text is only an edit distance of 1 from Next, but would trigger type // conversion errors if used in this initialization expression. Node *next = node->Next(); // expected-error-re {{no member named 'Next' in 'initializerCorrections::Node'{{$}}}} } struct LinkedNode { LinkedNode* next(); // expected-note {{'next' declared here}} string text() const; }; void f(LinkedNode *node) { // text and next are equidistant from Next, but only one results in a valid // initialization expression. LinkedNode *next = node->Next(); // expected-error {{no member named 'Next' in 'initializerCorrections::LinkedNode'; did you mean 'next'?}} } struct NestedNode { NestedNode* Nest(); NestedNode* next(); string text() const; }; void f(NestedNode *node) { // There are two equidistant, usable corrections for Next: next and Nest NestedNode *next = node->Next(); // expected-error-re {{no member named 'Next' in 'initializerCorrections::NestedNode'{{$}}}} } } namespace PR21669 { void f(int *i) { // Check that arguments to a builtin with custom type checking are corrected // properly, since calls to such builtins bypass much of the normal code path // for building and checking the call. __atomic_load(i, i, something_something); // expected-error-re {{use of undeclared identifier 'something_something'{{$}}}} } } const int DefaultArg = 9; // expected-note {{'DefaultArg' declared here}} template <int I = defaultArg> struct S {}; // expected-error {{use of undeclared identifier 'defaultArg'; did you mean 'DefaultArg'?}} S<1> s; namespace foo {} void test_paren_suffix() { foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}} \ // expected-error {{expected expression}} } const int kNum = 10; // expected-note {{'kNum' declared here}} class SomeClass { int Kind; public: explicit SomeClass() : Kind(kSum) {} // expected-error {{use of undeclared identifier 'kSum'; did you mean 'kNum'?}} }; // There used to be an issue with typo resolution inside overloads. struct AssertionResult { ~AssertionResult(); }; AssertionResult Overload(const char *a); AssertionResult Overload(int a); void UseOverload() { // expected-note@+1 {{'result' declared here}} const char *result; // expected-error@+1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}} Overload(resulta); } namespace PR21925 { struct X { int get() { return 7; } // expected-note {{'get' declared here}} }; void test() { X variable; // expected-note {{'variable' declared here}} // expected-error@+2 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}} // expected-error@+1 {{no member named 'getX' in 'PR21925::X'; did you mean 'get'?}} int x = variableX.getX(); } } namespace PR21905 { int (*a) () = (void)Z; // expected-error-re {{use of undeclared identifier 'Z'{{$}}}} } namespace PR21947 { int blue; // expected-note {{'blue' declared here}} __typeof blur y; // expected-error {{use of undeclared identifier 'blur'; did you mean 'blue'?}} } namespace PR22092 { a = b ? : 0; // expected-error {{C++ requires a type specifier for all declarations}} \ // expected-error-re {{use of undeclared identifier 'b'{{$}}}} } extern long clock (void); struct Pointer { void set_xpos(int); void set_ypos(int); }; void MovePointer(Pointer &Click, int x, int y) { // expected-note 2 {{'Click' declared here}} click.set_xpos(x); // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}} click.set_ypos(x); // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}} } namespace PR22250 { // expected-error@+4 {{use of undeclared identifier 'size_t'; did you mean 'sizeof'?}} // expected-error-re@+3 {{use of undeclared identifier 'y'{{$}}}} // expected-error-re@+2 {{use of undeclared identifier 'z'{{$}}}} // expected-error@+1 {{expected ';' after top level declarator}} int getenv_s(size_t *y, char(&z)) {} } namespace PR22291 { template <unsigned I> void f() { unsigned *prio_bits_array; // expected-note {{'prio_bits_array' declared here}} // expected-error@+1 {{use of undeclared identifier 'prio_op_array'; did you mean 'prio_bits_array'?}} __atomic_store_n(prio_op_array + I, false, __ATOMIC_RELAXED); } } namespace PR22297 { double pow(double x, double y); struct TimeTicks { static void Now(); // expected-note {{'Now' declared here}} }; void f() { TimeTicks::now(); // expected-error {{no member named 'now' in 'PR22297::TimeTicks'; did you mean 'Now'?}} } } namespace PR23005 { void f() { int a = Unknown::b(c); } // expected-error {{use of undeclared identifier 'Unknown'}} // expected-error@-1 {{use of undeclared identifier 'c'}} } namespace PR23350 { int z = 1 ? N : ; // expected-error {{expected expression}} // expected-error-re@-1 {{use of undeclared identifier 'N'{{$}}}} } // PR 23285. This test must be at the end of the file to avoid additional, // unwanted diagnostics. // expected-error-re@+2 {{use of undeclared identifier 'uintmax_t'{{$}}}} // expected-error@+1 {{expected ';' after top level declarator}} unsigned int a = 0(uintmax_t
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/delete.cpp
// Test without PCH // RUN: %clang_cc1 -fsyntax-only -include %S/delete-mismatch.h -fdiagnostics-parseable-fixits -std=c++11 %s 2>&1 | FileCheck %s // Test with PCH // RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/delete-mismatch.h // RUN: %clang_cc1 -std=c++11 -include-pch %t -DWITH_PCH -fsyntax-only -verify %s -ast-dump void f(int a[10][20]) { delete a; // expected-warning {{'delete' applied to a pointer-to-array type}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:9}:"[]" } namespace MemberCheck { struct S { int *a = new int[5]; // expected-note4 {{allocated with 'new[]' here}} int *b; int *c; static int *d; S(); S(int); ~S() { delete a; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete b; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete[] c; // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}} } void f(); }; void S::f() { delete a; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete b; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} } S::S() : b(new int[1]), c(new int) {} // expected-note3 {{allocated with 'new[]' here}} // expected-note@-1 {{allocated with 'new' here}} S::S(int i) : b(new int[i]), c(new int) {} // expected-note3 {{allocated with 'new[]' here}} // expected-note@-1 {{allocated with 'new' here}} struct S2 : S { ~S2() { delete a; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} } }; int *S::d = new int[42]; // expected-note {{allocated with 'new[]' here}} void f(S *s) { int *a = new int[1]; // expected-note {{allocated with 'new[]' here}} delete a; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete s->a; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete s->b; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete s->c; delete s->d; delete S::d; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} } // At least one constructor initializes field with matching form of 'new'. struct MatchingNewIsOK { int *p; bool is_array_; MatchingNewIsOK() : p{new int}, is_array_(false) {} explicit MatchingNewIsOK(unsigned c) : p{new int[c]}, is_array_(true) {} ~MatchingNewIsOK() { if (is_array_) delete[] p; else delete p; } }; // At least one constructor's body is missing; no proof of mismatch. struct CantProve_MissingCtorDefinition { int *p; CantProve_MissingCtorDefinition(); CantProve_MissingCtorDefinition(int); ~CantProve_MissingCtorDefinition(); }; CantProve_MissingCtorDefinition::CantProve_MissingCtorDefinition() : p(new int) { } CantProve_MissingCtorDefinition::~CantProve_MissingCtorDefinition() { delete[] p; } struct base {}; struct derived : base {}; struct InitList { base *p, *p2 = nullptr, *p3{nullptr}, *p4; InitList(unsigned c) : p(new derived[c]), p4(nullptr) {} // expected-note {{allocated with 'new[]' here}} InitList(unsigned c, unsigned) : p{new derived[c]}, p4{nullptr} {} // expected-note {{allocated with 'new[]' here}} ~InitList() { delete p; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} delete [] p; delete p2; delete [] p3; delete p4; } }; } namespace NonMemberCheck { #define DELETE_ARRAY(x) delete[] (x) #define DELETE(x) delete (x) void f() { int *a = new int(5); // expected-note2 {{allocated with 'new' here}} delete[] a; // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}} int *b = new int; delete b; int *c{new int}; // expected-note {{allocated with 'new' here}} int *d{new int[1]}; // expected-note2 {{allocated with 'new[]' here}} delete [ ] c; // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:17}:"" delete d; // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:9}:"[]" DELETE_ARRAY(a); // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}} DELETE(d); // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}} } } #ifndef WITH_PCH pch_test::X::X() : a(new int[1]) // expected-note{{allocated with 'new[]' here}} { } pch_test::X::X(int i) : a(new int[i]) // expected-note{{allocated with 'new[]' here}} { } #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-c++11-extensions.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-extensions -verify %s long long ll1 = // expected-warning {{'long long' is a C++11 extension}} -42LL; // expected-warning {{'long long' is a C++11 extension}} unsigned long long ull1 = // expected-warning {{'long long' is a C++11 extension}} 42ULL; // expected-warning {{'long long' is a C++11 extension}} enum struct E1 { A, B }; // expected-warning {{scoped enumerations are a C++11 extension}} enum class E2 { C, D }; // expected-warning {{scoped enumerations are a C++11 extension}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/err_typecheck_assign_const.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s const int global = 5; // expected-note{{variable 'global' declared const here}} void test1() { global = 2; // expected-error{{cannot assign to variable 'global' with const-qualified type 'const int'}} } void test2 () { const int local = 5; // expected-note{{variable 'local' declared const here}} local = 0; // expected-error{{cannot assign to variable 'local' with const-qualified type 'const int'}} } void test2 (const int parameter) { // expected-note{{variable 'parameter' declared const here}} parameter = 2; // expected-error{{cannot assign to variable 'parameter' with const-qualified type 'const int'}} } class test3 { int field; const int const_field = 1; // expected-note 2{{non-static data member 'const_field' declared const here}} static const int static_const_field = 1; // expected-note 2{{variable 'static_const_field' declared const here}} void test() { const_field = 4; // expected-error{{cannot assign to non-static data member 'const_field' with const-qualified type 'const int'}} static_const_field = 4; // expected-error{{cannot assign to variable 'static_const_field' with const-qualified type 'const int'}} } void test_const() const { // expected-note 2{{member function 'test3::test_const' is declared const here}} field = 4; // expected-error{{cannot assign to non-static data member within const member function 'test_const'}} const_field = 4 ; // expected-error{{cannot assign to non-static data member 'const_field' with const-qualified type 'const int'}} static_const_field = 4; // expected-error{{cannot assign to variable 'static_const_field' with const-qualified type 'const int'}} } }; const int &return_const_ref(); // expected-note{{function 'return_const_ref' which returns const-qualified type 'const int &' declared here}} void test4() { return_const_ref() = 10; // expected-error{{cannot assign to return value because function 'return_const_ref' returns a const value}} } struct S5 { int field; const int const_field = 4; // expected-note {{non-static data member 'const_field' declared const here}} }; void test5() { S5 s5; s5.field = 5; s5.const_field = 5; // expected-error{{cannot assign to non-static data member 'const_field' with const-qualified type 'const int'}} } struct U1 { int a = 5; }; struct U2 { U1 u1; }; struct U3 { const U2 u2 = U2(); // expected-note{{non-static data member 'u2' declared const here}} }; struct U4 { U3 u3; }; void test6() { U4 u4; u4.u3.u2.u1.a = 5; // expected-error{{cannot assign to non-static data member 'u2' with const-qualified type 'const U2'}} } struct A { int z; }; struct B { A a; }; struct C { B b; C(); }; const C &getc(); // expected-note{{function 'getc' which returns const-qualified type 'const C &' declared here}} void test7() { const C c; // expected-note{{variable 'c' declared const here}} c.b.a.z = 5; // expected-error{{cannot assign to variable 'c' with const-qualified type 'const C'}} getc().b.a.z = 5; // expected-error{{cannot assign to return value because function 'getc' returns a const value}} } struct D { const int n; }; // expected-note 2{{non-static data member 'n' declared const here}} struct E { D *const d = 0; }; void test8() { extern D *const d; d->n = 0; // expected-error{{cannot assign to non-static data member 'n' with const-qualified type 'const int'}} E e; e.d->n = 0; // expected-error{{cannot assign to non-static data member 'n' with const-qualified type 'const int'}} } struct F { int n; }; struct G { const F *f; }; // expected-note{{non-static data member 'f' declared const here}} void test10() { const F *f; // expected-note{{variable 'f' declared const here}} f->n = 0; // expected-error{{cannot assign to variable 'f' with const-qualified type 'const F *'}} G g; g.f->n = 0; // expected-error{{cannot assign to non-static data member 'f' with const-qualified type 'const F *'}} } void test11( const int x, // expected-note{{variable 'x' declared const here}} const int& y // expected-note{{variable 'y' declared const here}} ) { x = 5; // expected-error{{cannot assign to variable 'x' with const-qualified type 'const int'}} y = 5; // expected-error{{cannot assign to variable 'y' with const-qualified type 'const int &'}} } struct H { const int a = 0; // expected-note{{non-static data member 'a' declared const here}} const int &b = a; // expected-note{{non-static data member 'b' declared const here}} }; void test12(H h) { h.a = 1; // expected-error {{cannot assign to non-static data member 'a' with const-qualified type 'const int'}} h.b = 2; // expected-error {{cannot assign to non-static data member 'b' with const-qualified type 'const int &'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/reinterpret-cast.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding -Wundefined-reinterpret-cast -Wno-unused-volatile-lvalue %s #include <stdint.h> enum test { testval = 1 }; struct structure { int m; }; typedef void (*fnptr)(); // Test the conversion to self. void self_conversion() { // T->T is allowed per [expr.reinterpret.cast]p2 so long as it doesn't // cast away constness, and is integral, enumeration, pointer or // pointer-to-member. int i = 0; (void)reinterpret_cast<int>(i); test e = testval; (void)reinterpret_cast<test>(e); // T*->T* is allowed int *pi = 0; (void)reinterpret_cast<int*>(pi); const int structure::*psi = 0; (void)reinterpret_cast<const int structure::*>(psi); structure s; (void)reinterpret_cast<structure>(s); // expected-error {{reinterpret_cast from 'structure' to 'structure' is not allowed}} float f = 0.0f; (void)reinterpret_cast<float>(f); // expected-error {{reinterpret_cast from 'float' to 'float' is not allowed}} } // Test conversion between pointer and integral types, as in /3 and /4. void integral_conversion() { void *vp = reinterpret_cast<void*>(testval); intptr_t i = reinterpret_cast<intptr_t>(vp); (void)reinterpret_cast<float*>(i); fnptr fnp = reinterpret_cast<fnptr>(i); (void)reinterpret_cast<char>(fnp); // expected-error {{cast from pointer to smaller type 'char' loses information}} (void)reinterpret_cast<intptr_t>(fnp); } void pointer_conversion() { int *p1 = 0; float *p2 = reinterpret_cast<float*>(p1); structure *p3 = reinterpret_cast<structure*>(p2); typedef int **ppint; ppint *deep = reinterpret_cast<ppint*>(p3); (void)reinterpret_cast<fnptr*>(deep); } void constness() { int ***const ipppc = 0; // Valid: T1* -> T2 const* int const *icp = reinterpret_cast<int const*>(ipppc); // Invalid: T1 const* -> T2* (void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'const int *' to 'int *' casts away qualifiers}} // Invalid: T1*** -> T2 const* const** int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'const int *const **' casts away qualifiers}} // Valid: T1* -> T2* int *ip = reinterpret_cast<int*>(icpcpp); // Valid: T* -> T const* (void)reinterpret_cast<int const*>(ip); // Valid: T*** -> T2 const* const* const* (void)reinterpret_cast<int const* const* const*>(ipppc); } void fnptrs() { typedef int (*fnptr2)(int); fnptr fp = 0; (void)reinterpret_cast<fnptr2>(fp); void *vp = reinterpret_cast<void*>(fp); (void)reinterpret_cast<fnptr>(vp); } void refs() { long l = 0; char &c = reinterpret_cast<char&>(l); // Bad: from rvalue (void)reinterpret_cast<int&>(&c); // expected-error {{reinterpret_cast from rvalue to reference type 'int &'}} } void memptrs() { const int structure::*psi = 0; (void)reinterpret_cast<const float structure::*>(psi); (void)reinterpret_cast<int structure::*>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'int structure::*' casts away qualifiers}} void (structure::*psf)() = 0; (void)reinterpret_cast<int (structure::*)()>(psf); (void)reinterpret_cast<void (structure::*)()>(psi); // expected-error-re {{reinterpret_cast from 'const int structure::*' to 'void (structure::*)(){{( __attribute__\(\(thiscall\)\))?}}' is not allowed}} (void)reinterpret_cast<int structure::*>(psf); // expected-error-re {{reinterpret_cast from 'void (structure::*)(){{( __attribute__\(\(thiscall\)\))?}}' to 'int structure::*' is not allowed}} // Cannot cast from integers to member pointers, not even the null pointer // literal. (void)reinterpret_cast<void (structure::*)()>(0); // expected-error-re {{reinterpret_cast from 'int' to 'void (structure::*)(){{( __attribute__\(\(thiscall\)\))?}}' is not allowed}} (void)reinterpret_cast<int structure::*>(0); // expected-error {{reinterpret_cast from 'int' to 'int structure::*' is not allowed}} } namespace PR5545 { // PR5545 class A; class B; void (A::*a)(); void (B::*b)() = reinterpret_cast<void (B::*)()>(a); } // <rdar://problem/8018292> void const_arrays() { typedef char STRING[10]; const STRING *s; const char *c; (void)reinterpret_cast<char *>(s); // expected-error {{reinterpret_cast from 'const STRING *' (aka 'char const (*)[10]') to 'char *' casts away qualifiers}} (void)reinterpret_cast<const STRING *>(c); } namespace PR9564 { struct a { int a : 10; }; a x; int *y = &reinterpret_cast<int&>(x.a); // expected-error {{not allowed}} __attribute((ext_vector_type(4))) typedef float v4; float& w(v4 &a) { return reinterpret_cast<float&>(a[1]); } // expected-error {{not allowed}} } void dereference_reinterpret_cast() { struct A {}; typedef A A2; class B {}; typedef B B2; A a; B b; A2 a2; B2 b2; long l; double d; float f; char c; unsigned char uc; void* v_ptr; (void)reinterpret_cast<double&>(l); // expected-warning {{reinterpret_cast from 'long' to 'double &' has undefined behavior}} (void)*reinterpret_cast<double*>(&l); // expected-warning {{dereference of type 'double *' that was reinterpret_cast from type 'long *' has undefined behavior}} (void)reinterpret_cast<double&>(f); // expected-warning {{reinterpret_cast from 'float' to 'double &' has undefined behavior}} (void)*reinterpret_cast<double*>(&f); // expected-warning {{dereference of type 'double *' that was reinterpret_cast from type 'float *' has undefined behavior}} (void)reinterpret_cast<float&>(l); // expected-warning {{reinterpret_cast from 'long' to 'float &' has undefined behavior}} (void)*reinterpret_cast<float*>(&l); // expected-warning {{dereference of type 'float *' that was reinterpret_cast from type 'long *' has undefined behavior}} (void)reinterpret_cast<float&>(d); // expected-warning {{reinterpret_cast from 'double' to 'float &' has undefined behavior}} (void)*reinterpret_cast<float*>(&d); // expected-warning {{dereference of type 'float *' that was reinterpret_cast from type 'double *' has undefined behavior}} // TODO: add warning for tag types (void)reinterpret_cast<A&>(b); (void)*reinterpret_cast<A*>(&b); (void)reinterpret_cast<B&>(a); (void)*reinterpret_cast<B*>(&a); (void)reinterpret_cast<A2&>(b2); (void)*reinterpret_cast<A2*>(&b2); (void)reinterpret_cast<B2&>(a2); (void)*reinterpret_cast<B2*>(&a2); // Casting to itself is allowed (void)reinterpret_cast<A&>(a); (void)*reinterpret_cast<A*>(&a); (void)reinterpret_cast<B&>(b); (void)*reinterpret_cast<B*>(&b); (void)reinterpret_cast<long&>(l); (void)*reinterpret_cast<long*>(&l); (void)reinterpret_cast<double&>(d); (void)*reinterpret_cast<double*>(&d); (void)reinterpret_cast<char&>(c); (void)*reinterpret_cast<char*>(&c); // Casting to and from chars are allowable (void)reinterpret_cast<A&>(c); (void)*reinterpret_cast<A*>(&c); (void)reinterpret_cast<B&>(c); (void)*reinterpret_cast<B*>(&c); (void)reinterpret_cast<long&>(c); (void)*reinterpret_cast<long*>(&c); (void)reinterpret_cast<double&>(c); (void)*reinterpret_cast<double*>(&c); (void)reinterpret_cast<char&>(l); (void)*reinterpret_cast<char*>(&l); (void)reinterpret_cast<char&>(d); (void)*reinterpret_cast<char*>(&d); (void)reinterpret_cast<char&>(f); (void)*reinterpret_cast<char*>(&f); // Casting from void pointer. (void)*reinterpret_cast<A*>(v_ptr); (void)*reinterpret_cast<B*>(v_ptr); (void)*reinterpret_cast<long*>(v_ptr); (void)*reinterpret_cast<double*>(v_ptr); (void)*reinterpret_cast<float*>(v_ptr); // Casting to void pointer (void)*reinterpret_cast<void*>(&a); // expected-warning {{ISO C++ does not allow}} (void)*reinterpret_cast<void*>(&b); // expected-warning {{ISO C++ does not allow}} (void)*reinterpret_cast<void*>(&l); // expected-warning {{ISO C++ does not allow}} (void)*reinterpret_cast<void*>(&d); // expected-warning {{ISO C++ does not allow}} (void)*reinterpret_cast<void*>(&f); // expected-warning {{ISO C++ does not allow}} } void reinterpret_cast_whitelist () { // the dynamic type of the object int a; float b; (void)reinterpret_cast<int&>(a); (void)*reinterpret_cast<int*>(&a); (void)reinterpret_cast<float&>(b); (void)*reinterpret_cast<float*>(&b); // a cv-qualified version of the dynamic object (void)reinterpret_cast<const int&>(a); (void)*reinterpret_cast<const int*>(&a); (void)reinterpret_cast<volatile int&>(a); (void)*reinterpret_cast<volatile int*>(&a); (void)reinterpret_cast<const volatile int&>(a); (void)*reinterpret_cast<const volatile int*>(&a); (void)reinterpret_cast<const float&>(b); (void)*reinterpret_cast<const float*>(&b); (void)reinterpret_cast<volatile float&>(b); (void)*reinterpret_cast<volatile float*>(&b); (void)reinterpret_cast<const volatile float&>(b); (void)*reinterpret_cast<const volatile float*>(&b); // a type that is the signed or unsigned type corresponding to the dynamic // type of the object signed d; unsigned e; (void)reinterpret_cast<signed&>(d); (void)*reinterpret_cast<signed*>(&d); (void)reinterpret_cast<signed&>(e); (void)*reinterpret_cast<signed*>(&e); (void)reinterpret_cast<unsigned&>(d); (void)*reinterpret_cast<unsigned*>(&d); (void)reinterpret_cast<unsigned&>(e); (void)*reinterpret_cast<unsigned*>(&e); // a type that is the signed or unsigned type corresponding a cv-qualified // version of the dynamic type the object (void)reinterpret_cast<const signed&>(d); (void)*reinterpret_cast<const signed*>(&d); (void)reinterpret_cast<const signed&>(e); (void)*reinterpret_cast<const signed*>(&e); (void)reinterpret_cast<const unsigned&>(d); (void)*reinterpret_cast<const unsigned*>(&d); (void)reinterpret_cast<const unsigned&>(e); (void)*reinterpret_cast<const unsigned*>(&e); (void)reinterpret_cast<volatile signed&>(d); (void)*reinterpret_cast<volatile signed*>(&d); (void)reinterpret_cast<volatile signed&>(e); (void)*reinterpret_cast<volatile signed*>(&e); (void)reinterpret_cast<volatile unsigned&>(d); (void)*reinterpret_cast<volatile unsigned*>(&d); (void)reinterpret_cast<volatile unsigned&>(e); (void)*reinterpret_cast<volatile unsigned*>(&e); (void)reinterpret_cast<const volatile signed&>(d); (void)*reinterpret_cast<const volatile signed*>(&d); (void)reinterpret_cast<const volatile signed&>(e); (void)*reinterpret_cast<const volatile signed*>(&e); (void)reinterpret_cast<const volatile unsigned&>(d); (void)*reinterpret_cast<const volatile unsigned*>(&d); (void)reinterpret_cast<const volatile unsigned&>(e); (void)*reinterpret_cast<const volatile unsigned*>(&e); // an aggregate or union type that includes one of the aforementioned types // among its members (including, recursively, a member of a subaggregate or // contained union) // TODO: checking is not implemented for tag types // a type that is a (possible cv-qualified) base class type of the dynamic // type of the object // TODO: checking is not implemented for tag types // a char or unsigned char type (void)reinterpret_cast<char&>(a); (void)*reinterpret_cast<char*>(&a); (void)reinterpret_cast<unsigned char&>(a); (void)*reinterpret_cast<unsigned char*>(&a); (void)reinterpret_cast<char&>(b); (void)*reinterpret_cast<char*>(&b); (void)reinterpret_cast<unsigned char&>(b); (void)*reinterpret_cast<unsigned char*>(&b); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx11-user-defined-literals-unused.cpp
// RUN: %clang_cc1 -std=c++11 -verify %s -Wunused namespace { double operator"" _x(long double value) { return double(value); } int operator"" _ii(long double value) { return int(value); } // expected-warning {{not needed and will not be emitted}} } namespace rdar13589856 { template<class T> double value() { return 3.2_x; } template<class T> int valuei() { return 3.2_ii; } double get_value() { return value<double>(); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-literal-conversion.cpp
// RUN: %clang_cc1 -fsyntax-only -Wliteral-conversion -verify %s void foo(int y); // Warn when a literal float or double is assigned or bound to an integer. void test0() { // Float int y0 = 1.2222F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} int y1 = (1.2222F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} int y2 = (((1.2222F))); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} int y3 = 12E-1F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} int y4 = 1.23E1F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 12.3 to 12}} // Double int y5 = 1.2222; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.2222 to 1}} int y6 = 12E-1; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.2 to 1}} int y7 = 1.23E1; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} int y8 = (1.23E1); // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} // Test assignment to an existing variable. y8 = 2.22F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 2.22 to 2}} // Test direct initialization. int y9(1.23F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.23 to 1}} // Test passing a literal floating-point value to a function that takes an integer. foo(1.2F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} int y10 = -1.2F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} // -Wliteral-conversion does NOT catch const values. // (-Wconversion DOES catch them.) static const float sales_tax_rate = .095F; int z = sales_tax_rate; foo(sales_tax_rate); // Expressions, such as those that indicate rounding-down, should NOT produce warnings. int x = 24 * 0.5; int y = (24*60*60) * 0.25; int pennies = 123.45 * 100; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // This is a test for an egregious hack in Clang that works around // issues with GCC's evolution. libstdc++ 4.2.x uses __is_pod as an // identifier (to declare a struct template like the one below), while // GCC 4.3 and newer make __is_pod a keyword. Clang treats __is_pod as // a keyword *unless* it is introduced following the struct keyword. template<typename T> struct __is_pod { // expected-warning {{keyword '__is_pod' will be made available as an identifier}} __is_pod() {} }; __is_pod<int> ipi; // Ditto for __is_same. template<typename T> struct __is_same { // expected-warning {{keyword '__is_same' will be made available as an identifier}} }; __is_same<int> isi; // Another, similar egregious hack for __is_signed, which is a type // trait in Embarcadero's compiler but is used as an identifier in // libstdc++. struct test_is_signed { static const bool __is_signed = true; // expected-warning {{keyword '__is_signed' will be made available as an identifier}} }; bool check_signed = test_is_signed::__is_signed; template<bool B> struct must_be_true {}; template<> struct must_be_true<false>; void foo() { bool b = __is_pod(int); must_be_true<__is_pod(int)> mbt; } // expected-warning@+1 {{declaration does not declare anything}} struct // expected-error {{declaration of anonymous struct must be a definition}} #pragma pack(pop) S { }; #if !__has_feature(is_pod) # error __is_pod should still be available. #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/bitfield.cpp
// RUN: %clang_cc1 %s -verify // expected-no-diagnostics namespace PromotionVersusMutation { typedef unsigned Unsigned; typedef signed Signed; struct T { unsigned n : 2; } t; typedef __typeof__(t.n) Unsigned; // Bitfield is unsigned typedef __typeof__(+t.n) Signed; // ... but promotes to signed. typedef __typeof__(t.n + 0) Signed; // Arithmetic promotes. typedef __typeof__(t.n = 0) Unsigned; // Assignment produces an lvalue... typedef __typeof__(t.n += 0) Unsigned; typedef __typeof__(t.n *= 0) Unsigned; typedef __typeof__(+(t.n = 0)) Signed; // ... which is a bit-field. typedef __typeof__(+(t.n += 0)) Signed; typedef __typeof__(+(t.n *= 0)) Signed; typedef __typeof__(++t.n) Unsigned; // Increment is equivalent to compound-assignment. typedef __typeof__(--t.n) Unsigned; typedef __typeof__(+(++t.n)) Signed; typedef __typeof__(+(--t.n)) Signed; typedef __typeof__(t.n++) Unsigned; // Post-increment's result has the type typedef __typeof__(t.n--) Unsigned; // of the operand... typedef __typeof__(+(t.n++)) Unsigned; // ... and is not a bit-field (because typedef __typeof__(+(t.n--)) Unsigned; // it's not a glvalue). }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/prefetch-enum.cpp
// RUN: %clang_cc1 -fsyntax-only %s -verify // expected-no-diagnostics // PR5679 enum X { A = 3 }; void Test() { char ch; __builtin_prefetch(&ch, 0, A); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/using-decl-templates.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s template<typename T> struct A { void f() { } struct N { }; // expected-note{{target of using declaration}} }; template<typename T> struct B : A<T> { using A<T>::f; using A<T>::N; // expected-error{{dependent using declaration resolved to type without 'typename'}} using A<T>::foo; // expected-error{{no member named 'foo'}} using A<double>::f; // expected-error{{using declaration refers into 'A<double>::', which is not a base class of 'B<int>'}} }; B<int> a; // expected-note{{in instantiation of template class 'B<int>' requested here}} template<typename T> struct C : A<T> { using A<T>::f; void f() { }; }; template <typename T> struct D : A<T> { using A<T>::f; void f(); }; template<typename T> void D<T>::f() { } template<typename T> struct E : A<T> { using A<T>::f; void g() { f(); } }; namespace test0 { struct Base { int foo; }; template<typename T> struct E : Base { using Base::foo; }; template struct E<int>; } // PR7896 namespace PR7896 { template <class T> struct Foo { int k (float); }; struct Baz { int k (int); }; template <class T> struct Bar : public Foo<T>, Baz { using Foo<T>::k; using Baz::k; int foo() { return k (1.0f); } }; template int Bar<int>::foo(); } // PR10883 namespace PR10883 { template <typename T> class Base { public: typedef long Container; }; template <typename T> class Derived : public Base<T> { public: using Base<T>::Container; void foo(const Container& current); // expected-error {{unknown type name 'Container'}} }; } template<typename T> class UsingTypenameNNS { using typename T::X; typename X::X x; }; namespace aliastemplateinst { template<typename T> struct A { }; template<typename T> using APtr = A<T*>; // expected-note{{previous use is here}} template struct APtr<int>; // expected-error{{elaborated type refers to a non-tag type}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/undefined-internal.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy %s // Make sure we don't produce invalid IR. // RUN: %clang_cc1 -emit-llvm-only %s namespace test1 { static void foo(); // expected-warning {{function 'test1::foo' has internal linkage but is not defined}} template <class T> static void bar(); // expected-warning {{function 'test1::bar<int>' has internal linkage but is not defined}} void test() { foo(); // expected-note {{used here}} bar<int>(); // expected-note {{used here}} } } namespace test2 { namespace { void foo(); // expected-warning {{function 'test2::(anonymous namespace)::foo' has internal linkage but is not defined}} extern int var; // expected-warning {{variable 'test2::(anonymous namespace)::var' has internal linkage but is not defined}} template <class T> void bar(); // expected-warning {{function 'test2::(anonymous namespace)::bar<int>' has internal linkage but is not defined}} } void test() { foo(); // expected-note {{used here}} var = 0; // expected-note {{used here}} bar<int>(); // expected-note {{used here}} } } namespace test3 { namespace { void foo(); extern int var; template <class T> void bar(); } void test() { foo(); var = 0; bar<int>(); } namespace { void foo() {} int var = 0; template <class T> void bar() {} } } namespace test4 { namespace { struct A { A(); // expected-warning {{function 'test4::(anonymous namespace)::A::A' has internal linkage but is not defined}} ~A();// expected-warning {{function 'test4::(anonymous namespace)::A::~A' has internal linkage but is not defined}} virtual void foo(); // expected-warning {{function 'test4::(anonymous namespace)::A::foo' has internal linkage but is not defined}} virtual void bar() = 0; virtual void baz(); // expected-warning {{function 'test4::(anonymous namespace)::A::baz' has internal linkage but is not defined}} }; } void test(A &a) { a.foo(); // expected-note {{used here}} a.bar(); a.baz(); // expected-note {{used here}} } struct Test : A { Test() {} // expected-note 2 {{used here}} }; } // rdar://problem/9014651 namespace test5 { namespace { struct A {}; } template <class N> struct B { static int var; // expected-warning {{variable 'test5::B<test5::(anonymous namespace)::A>::var' has internal linkage but is not defined}} static void foo(); // expected-warning {{function 'test5::B<test5::(anonymous namespace)::A>::foo' has internal linkage but is not defined}} }; void test() { B<A>::var = 0; // expected-note {{used here}} B<A>::foo(); // expected-note {{used here}} } } namespace test6 { template <class T> struct A { static const int zero = 0; static const int one = 1; static const int two = 2; int value; A() : value(zero) { value = one; } }; namespace { struct Internal; } void test() { A<Internal> a; a.value = A<Internal>::two; } } // We support (as an extension) private, undefined copy constructors when // a temporary is bound to a reference even in C++98. Similarly, we shouldn't // warn about this copy constructor being used without a definition. namespace PR9323 { namespace { struct Uncopyable { Uncopyable() {} private: Uncopyable(const Uncopyable&); // expected-note {{declared private here}} }; } void f(const Uncopyable&) {} void test() { f(Uncopyable()); // expected-warning {{C++98 requires an accessible copy constructor}} }; } namespace std { class type_info; }; namespace cxx11_odr_rules { // Note: the way this test is written isn't really ideal, but there really // isn't any other way to check that the odr-used logic for constants // is working without working implicit capture in lambda-expressions. // (The more accurate used-but-not-defined warning is the only other visible // effect of accurate odr-used computation.) // // Note that the warning in question can trigger in cases some people would // consider false positives; hopefully that happens rarely in practice. // // FIXME: Suppressing this test while I figure out how to fix a bug in the // odr-use marking code. namespace { struct A { static const int unused = 10; static const int used1 = 20; // xpected-warning {{internal linkage}} static const int used2 = 20; // xpected-warning {{internal linkage}} virtual ~A() {} }; } void a(int,int); A& p(const int&) { static A a; return a; } // Check handling of default arguments void b(int = A::unused); void tests() { // Basic test a(A::unused, A::unused); // Check that nesting an unevaluated or constant-evaluated context does // the right thing. a(A::unused, sizeof(int[10])); // Check that the checks work with unevaluated contexts (void)sizeof(p(A::used1)); (void)typeid(p(A::used1)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} xpected-note {{used here}} // Misc other testing a(A::unused, 1 ? A::used2 : A::used2); // xpected-note {{used here}} b(); } } namespace OverloadUse { namespace { void f(); void f(int); // expected-warning {{function 'OverloadUse::(anonymous namespace)::f' has internal linkage but is not defined}} } template<void x()> void t(int*) { x(); } template<void x(int)> void t(long*) { x(10); } // expected-note {{used here}} void g() { long a; t<f>(&a); } } namespace test7 { typedef struct { void bar(); void foo() { bar(); } } A; } namespace test8 { typedef struct { void bar(); // expected-warning {{function 'test8::(anonymous struct)::bar' has internal linkage but is not defined}} void foo() { bar(); // expected-note {{used here}} } } *A; } namespace test9 { namespace { struct X { virtual void notused() = 0; virtual void used() = 0; // expected-warning {{function 'test9::(anonymous namespace)::X::used' has internal linkage but is not defined}} }; } void test(X &x) { x.notused(); x.X::used(); // expected-note {{used here}} } } namespace test10 { namespace { struct X { virtual void notused() = 0; virtual void used() = 0; // expected-warning {{function 'test10::(anonymous namespace)::X::used' has internal linkage but is not defined}} void test() { notused(); (void)&X::notused; (this->*&X::notused)(); X::used(); // expected-note {{used here}} } }; struct Y : X { using X::notused; }; } } namespace test11 { namespace { struct A { virtual bool operator()() const = 0; virtual void operator!() const = 0; virtual bool operator+(const A&) const = 0; virtual int operator[](int) const = 0; virtual const A* operator->() const = 0; int member; }; struct B { bool operator()() const; // expected-warning {{function 'test11::(anonymous namespace)::B::operator()' has internal linkage but is not defined}} void operator!() const; // expected-warning {{function 'test11::(anonymous namespace)::B::operator!' has internal linkage but is not defined}} bool operator+(const B&) const; // expected-warning {{function 'test11::(anonymous namespace)::B::operator+' has internal linkage but is not defined}} int operator[](int) const; // expected-warning {{function 'test11::(anonymous namespace)::B::operator[]' has internal linkage but is not defined}} const B* operator->() const; // expected-warning {{function 'test11::(anonymous namespace)::B::operator->' has internal linkage but is not defined}} int member; }; } void test1(A &a1, A &a2) { a1(); !a1; a1 + a2; a1[0]; (void)a1->member; } void test2(B &b1, B &b2) { b1(); // expected-note {{used here}} !b1; // expected-note {{used here}} b1 + b2; // expected-note {{used here}} b1[0]; // expected-note {{used here}} (void)b1->member; // expected-note {{used here}} } } namespace test12 { class T1 {}; class T2 {}; class T3 {}; class T4 {}; class T5 {}; class T6 {}; class T7 {}; namespace { struct Cls { virtual void f(int) = 0; virtual void f(int, double) = 0; void g(int); // expected-warning {{function 'test12::(anonymous namespace)::Cls::g' has internal linkage but is not defined}} void g(int, double); virtual operator T1() = 0; virtual operator T2() = 0; virtual operator T3&() = 0; operator T4(); // expected-warning {{function 'test12::(anonymous namespace)::Cls::operator T4' has internal linkage but is not defined}} operator T5(); // expected-warning {{function 'test12::(anonymous namespace)::Cls::operator T5' has internal linkage but is not defined}} operator T6&(); // expected-warning {{function 'test12::(anonymous namespace)::Cls::operator test12::T6 &' has internal linkage but is not defined}} }; struct Cls2 { Cls2(T7); // expected-warning {{function 'test12::(anonymous namespace)::Cls2::Cls2' has internal linkage but is not defined}} }; } void test(Cls &c) { c.f(7); c.g(7); // expected-note {{used here}} (void)static_cast<T1>(c); T2 t2 = c; T3 &t3 = c; (void)static_cast<T4>(c); // expected-note {{used here}} T5 t5 = c; // expected-note {{used here}} T6 &t6 = c; // expected-note {{used here}} Cls2 obj1((T7())); // expected-note {{used here}} } } namespace test13 { namespace { struct X { virtual void f() { } }; struct Y : public X { virtual void f() = 0; virtual void g() { X::f(); } }; } } namespace test14 { extern "C" const int foo; int f() { return foo; } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overloaded-name.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s int ovl(int); // expected-note 3{{possible target for call}} float ovl(float); // expected-note 3{{possible target for call}} template<typename T> T ovl(T); // expected-note 3{{possible target for call}} void test(bool b) { (void)((void)0, ovl); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} // PR7863 (void)(b? ovl : &ovl); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} (void)(b? ovl<float> : &ovl); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} (void)(b? ovl<float> : ovl<float>); } namespace rdar9623945 { void f(...) { } class X { public: const char* text(void); void g(void) { f(text()); f(text); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}} f(text()); f(text); // 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/new-delete-predefined-decl-2.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -DQUALIFIED -fsyntax-only -verify %s // expected-no-diagnostics // PR5904 void f0(int *ptr) { #ifndef QUALIFIED operator delete(ptr); #endif } void f1(int *ptr) { ::operator delete[](ptr); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/string-plus-int.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-array-bounds %s -fpascal-strings // RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 -Wno-array-bounds -fpascal-strings | FileCheck %s void consume(const char* c) {} void consume(const unsigned char* c) {} void consume(const wchar_t* c) {} void consumeChar(char c) {} enum MyEnum { kMySmallEnum = 1, kMyEnum = 5 }; enum OperatorOverloadEnum { kMyOperatorOverloadedEnum = 5 }; const char* operator+(const char* c, OperatorOverloadEnum e) { return "yo"; } const char* operator+(OperatorOverloadEnum e, const char* c) { return "yo"; } void f(int index) { // Should warn. // CHECK: fix-it:"{{.*}}":{31:11-31:11}:"&" // CHECK: fix-it:"{{.*}}":{31:17-31:18}:"[" // CHECK: fix-it:"{{.*}}":{31:20-31:20}:"]" consume("foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consume("foo" + index); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consume("foo" + kMyEnum); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consume(5 + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consume(index + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consume(kMyEnum + "foo"); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} // FIXME: suggest replacing with "foo"[5] consumeChar(*("foo" + 5)); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consumeChar(*(5 + "foo")); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} consume(L"foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} // Should not warn. consume(&("foo"[3])); consume(&("foo"[index])); consume(&("foo"[kMyEnum])); consume("foo" + kMySmallEnum); consume(kMySmallEnum + "foo"); consume(L"foo" + 2); consume("foo" + 3); // Points at the \0 consume("foo" + 4); // Points 1 past the \0, which is legal too. consume("\pfoo" + 4); // Pascal strings don't have a trailing \0, but they // have a leading length byte, so this is fine too. consume("foo" + kMyOperatorOverloadedEnum); consume(kMyOperatorOverloadedEnum + "foo"); #define A "foo" #define B "bar" consume(A B + sizeof(A) - 1); } template <typename T> void PR21848() { (void)(sizeof(T) + ""); // expected-warning {{to a string does not append to the string}} expected-note {{use array indexing to silence this warning}} } template void PR21848<int>(); // expected-note {{in instantiation of function template specialization 'PR21848<int>' requested here}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overloaded-builtin-operators-0x.cpp
// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -std=c++11 -verify %s // expected-no-diagnostics template <class T> struct X { operator T() const {return T();} }; void test_char16t(X<char16_t> x) { bool b = x == char16_t(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-float-conversion.cpp
// RUN: %clang_cc1 -verify -fsyntax-only %s -Wfloat-conversion bool ReturnBool(float f) { return f; //expected-warning{{conversion}} } char ReturnChar(float f) { return f; //expected-warning{{conversion}} } int ReturnInt(float f) { return f; //expected-warning{{conversion}} } long ReturnLong(float f) { return f; //expected-warning{{conversion}} } void Convert(float f, double d, long double ld) { bool b; char c; int i; long l; b = f; //expected-warning{{conversion}} b = d; //expected-warning{{conversion}} b = ld; //expected-warning{{conversion}} c = f; //expected-warning{{conversion}} c = d; //expected-warning{{conversion}} c = ld; //expected-warning{{conversion}} i = f; //expected-warning{{conversion}} i = d; //expected-warning{{conversion}} i = ld; //expected-warning{{conversion}} l = f; //expected-warning{{conversion}} l = d; //expected-warning{{conversion}} l = ld; //expected-warning{{conversion}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/offsetof-0x.cpp
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof struct NonPOD { virtual void f(); int m; }; struct P { NonPOD fieldThatPointsToANonPODType; }; void f() { int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-standard-layout type 'P'}} } struct StandardLayout { int x; StandardLayout() {} }; int o = __builtin_offsetof(StandardLayout, x); // no-warning
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s template <class T> T&& declval() noexcept; template <class T> struct some_trait { static const bool value = false; }; template <class T> void swap(T& x, T& y) noexcept(some_trait<T>::value) { T tmp(static_cast<T&&>(x)); x = static_cast<T&&>(y); y = static_cast<T&&>(tmp); } template <class T, unsigned N> struct array { T data[N]; void swap(array& a) noexcept(noexcept(::swap(declval<T&>(), declval<T&>()))); }; struct DefaultOnly { DefaultOnly() = default; DefaultOnly(const DefaultOnly&) = delete; DefaultOnly& operator=(const DefaultOnly&) = delete; ~DefaultOnly() = default; }; int main() { array<DefaultOnly, 1> a, b; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/blocks-1.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++1y extern "C" int exit(int); typedef struct { unsigned long ps[30]; int qs[30]; } BobTheStruct; int main (int argc, const char * argv[]) { BobTheStruct inny; BobTheStruct outty; BobTheStruct (^copyStruct)(BobTheStruct); int i; for(i=0; i<30; i++) { inny.ps[i] = i * i * i; inny.qs[i] = -i * i * i; } copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; }; // pass-by-value intrinsically copies the argument outty = copyStruct(inny); if ( &inny == &outty ) { exit(1); } for(i=0; i<30; i++) { if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) { exit(1); } } return 0; } namespace rdar8134521 { void foo() { int (^P)(int) = reinterpret_cast<int(^)(int)>(1); P = (int(^)(int))(1); P = reinterpret_cast<int(^)(int)>((void*)1); P = (int(^)(int))((void*)1); } } namespace rdar11055105 { struct A { void foo(); }; template <class T> void foo(T &x) noexcept(noexcept(x.foo())); void (^block)() = ^{ A a; foo(a); }; } namespace LocalDecls { void f() { (void) ^{ extern int a; // expected-note {{previous}} extern int b(); // expected-note {{previous}} }; } void g() { (void) ^{ extern float a; // expected-error {{different type}} extern float b(); // expected-error {{cannot be overloaded}} }; } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/dllexport.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 %s // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template %s // Helper structs to make templates more expressive. struct ImplicitInst_Exported {}; struct ExplicitDecl_Exported {}; struct ExplicitInst_Exported {}; struct ExplicitSpec_Exported {}; struct ExplicitSpec_Def_Exported {}; struct ExplicitSpec_InlineDef_Exported {}; struct ExplicitSpec_NotExported {}; namespace { struct Internal {}; } struct External { int v; }; // Invalid usage. __declspec(dllexport) typedef int typedef1; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} typedef __declspec(dllexport) int typedef2; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} typedef int __declspec(dllexport) typedef3; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} typedef __declspec(dllexport) void (*FunTy)(); // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} enum __declspec(dllexport) Enum {}; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} #if __has_feature(cxx_strong_enums) enum class __declspec(dllexport) EnumClass {}; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} #endif //===----------------------------------------------------------------------===// // Globals //===----------------------------------------------------------------------===// // Export declaration. __declspec(dllexport) extern int ExternGlobalDecl; // dllexport implies a definition. __declspec(dllexport) int GlobalDef; // Export definition. __declspec(dllexport) int GlobalInit1 = 1; int __declspec(dllexport) GlobalInit2 = 1; // Declare, then export definition. __declspec(dllexport) extern int GlobalDeclInit; int GlobalDeclInit = 1; // Redeclarations __declspec(dllexport) extern int GlobalRedecl1; __declspec(dllexport) int GlobalRedecl1; __declspec(dllexport) extern int GlobalRedecl2; int GlobalRedecl2; extern int GlobalRedecl3; // expected-note{{previous declaration is here}} __declspec(dllexport) extern int GlobalRedecl3; // expected-warning{{redeclaration of 'GlobalRedecl3' should not add 'dllexport' attribute}} extern "C" { extern int GlobalRedecl4; // expected-note{{previous declaration is here}} __declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}} } // External linkage is required. __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}} __declspec(dllexport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllexport'}} namespace { __declspec(dllexport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllexport'}} namespace ns { __declspec(dllexport) int ExternalGlobal; } __declspec(dllexport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllexport'}} __declspec(dllexport) auto ExternalAutoTypeGlobal = External(); // Thread local variables are invalid. __declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}} // Export in local scope. void functionScope() { __declspec(dllexport) int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}} __declspec(dllexport) int LocalVarDef = 1; // expected-error{{'LocalVarDef' must have external linkage when declared 'dllexport'}} __declspec(dllexport) extern int ExternLocalVarDecl; __declspec(dllexport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllexport'}} } //===----------------------------------------------------------------------===// // Variable templates //===----------------------------------------------------------------------===// #if __has_feature(cxx_variable_templates) // Export declaration. template<typename T> __declspec(dllexport) extern int ExternVarTmplDecl; // dllexport implies a definition. template<typename T> __declspec(dllexport) int VarTmplDef; // Export definition. template<typename T> __declspec(dllexport) int VarTmplInit1 = 1; template<typename T> int __declspec(dllexport) VarTmplInit2 = 1; // Declare, then export definition. template<typename T> __declspec(dllexport) extern int VarTmplDeclInit; template<typename T> int VarTmplDeclInit = 1; // Redeclarations template<typename T> __declspec(dllexport) extern int VarTmplRedecl1; template<typename T> __declspec(dllexport) int VarTmplRedecl1 = 1; template<typename T> __declspec(dllexport) extern int VarTmplRedecl2; template<typename T> int VarTmplRedecl2 = 1; template<typename T> extern int VarTmplRedecl3; // expected-note{{previous declaration is here}} template<typename T> __declspec(dllexport) extern int VarTmplRedecl3; // expected-error{{redeclaration of 'VarTmplRedecl3' cannot add 'dllexport' attribute}} // External linkage is required. template<typename T> __declspec(dllexport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllexport'}} template<typename T> __declspec(dllexport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllexport'}} namespace { template<typename T> __declspec(dllexport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllexport'}} namespace ns { template<typename T> __declspec(dllexport) int ExternalVarTmpl = 1; } template<typename T> __declspec(dllexport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllexport'}} template<typename T> __declspec(dllexport) auto ExternalAutoTypeVarTmpl = External(); template External ExternalAutoTypeVarTmpl<ExplicitInst_Exported>; template<typename T> int VarTmpl = 1; template<typename T> __declspec(dllexport) int ExportedVarTmpl = 1; // Export implicit instantiation of an exported variable template. int useVarTmpl() { return ExportedVarTmpl<ImplicitInst_Exported>; } // Export explicit instantiation declaration of an exported variable template. extern template int ExportedVarTmpl<ExplicitDecl_Exported>; template int ExportedVarTmpl<ExplicitDecl_Exported>; // Export explicit instantiation definition of an exported variable template. template __declspec(dllexport) int ExportedVarTmpl<ExplicitInst_Exported>; // Export specialization of an exported variable template. template<> __declspec(dllexport) int ExportedVarTmpl<ExplicitSpec_Exported>; template<> __declspec(dllexport) int ExportedVarTmpl<ExplicitSpec_Def_Exported> = 1; // Not exporting specialization of an exported variable template without // explicit dllexport. template<> int ExportedVarTmpl<ExplicitSpec_NotExported>; // Export explicit instantiation declaration of a non-exported variable template. extern template __declspec(dllexport) int VarTmpl<ExplicitDecl_Exported>; template __declspec(dllexport) int VarTmpl<ExplicitDecl_Exported>; // Export explicit instantiation definition of a non-exported variable template. template __declspec(dllexport) int VarTmpl<ExplicitInst_Exported>; // Export specialization of a non-exported variable template. template<> __declspec(dllexport) int VarTmpl<ExplicitSpec_Exported>; template<> __declspec(dllexport) int VarTmpl<ExplicitSpec_Def_Exported> = 1; #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Functions //===----------------------------------------------------------------------===// // Export function declaration. Check different placements. __attribute__((dllexport)) void decl1A(); // Sanity check with __attribute__ __declspec(dllexport) void decl1B(); void __attribute__((dllexport)) decl2A(); void __declspec(dllexport) decl2B(); // Export function definition. __declspec(dllexport) void def() {} // extern "C" extern "C" __declspec(dllexport) void externC() {} // Export inline function. __declspec(dllexport) inline void inlineFunc1() {} inline void __attribute__((dllexport)) inlineFunc2() {} __declspec(dllexport) inline void inlineDecl(); void inlineDecl() {} __declspec(dllexport) void inlineDef(); inline void inlineDef() {} // Redeclarations __declspec(dllexport) void redecl1(); __declspec(dllexport) void redecl1() {} __declspec(dllexport) void redecl2(); void redecl2() {} void redecl3(); // expected-note{{previous declaration is here}} __declspec(dllexport) void redecl3(); // expected-warning{{redeclaration of 'redecl3' should not add 'dllexport' attribute}} extern "C" { void redecl4(); // expected-note{{previous declaration is here}} __declspec(dllexport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllexport' attribute}} } void redecl5(); // expected-note{{previous declaration is here}} __declspec(dllexport) inline void redecl5() {} // expected-warning{{redeclaration of 'redecl5' should not add 'dllexport' attribute}} // Friend functions struct FuncFriend { friend __declspec(dllexport) void friend1(); friend __declspec(dllexport) void friend2(); friend void friend3(); // expected-note{{previous declaration is here}} friend void friend4(); // expected-note{{previous declaration is here}} }; __declspec(dllexport) void friend1() {} void friend2() {} __declspec(dllexport) void friend3() {} // expected-warning{{redeclaration of 'friend3' should not add 'dllexport' attribute}} __declspec(dllexport) inline void friend4() {} // expected-warning{{redeclaration of 'friend4' should not add 'dllexport' attribute}} // Implicit declarations can be redeclared with dllexport. __declspec(dllexport) void* operator new(__SIZE_TYPE__ n); // External linkage is required. __declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}} __declspec(dllexport) Internal internalRetFunc(); // expected-error{{'internalRetFunc' must have external linkage when declared 'dllexport'}} namespace { __declspec(dllexport) void internalFunc() {} } // expected-error{{'(anonymous namespace)::internalFunc' must have external linkage when declared 'dllexport'}} namespace ns { __declspec(dllexport) void externalFunc() {} } // Export deleted function. __declspec(dllexport) void deletedFunc() = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) inline void deletedInlineFunc() = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} //===----------------------------------------------------------------------===// // Function templates //===----------------------------------------------------------------------===// // Export function template declaration. Check different placements. template<typename T> __declspec(dllexport) void funcTmplDecl1(); template<typename T> void __declspec(dllexport) funcTmplDecl2(); // Export function template definition. template<typename T> __declspec(dllexport) void funcTmplDef() {} // Export inline function template. template<typename T> __declspec(dllexport) inline void inlineFuncTmpl1() {} template<typename T> inline void __attribute__((dllexport)) inlineFuncTmpl2() {} template<typename T> __declspec(dllexport) inline void inlineFuncTmplDecl(); template<typename T> void inlineFuncTmplDecl() {} template<typename T> __declspec(dllexport) void inlineFuncTmplDef(); template<typename T> inline void inlineFuncTmplDef() {} // Redeclarations template<typename T> __declspec(dllexport) void funcTmplRedecl1(); template<typename T> __declspec(dllexport) void funcTmplRedecl1() {} template<typename T> __declspec(dllexport) void funcTmplRedecl2(); template<typename T> void funcTmplRedecl2() {} template<typename T> void funcTmplRedecl3(); // expected-note{{previous declaration is here}} template<typename T> __declspec(dllexport) void funcTmplRedecl3(); // expected-error{{redeclaration of 'funcTmplRedecl3' cannot add 'dllexport' attribute}} template<typename T> void funcTmplRedecl4(); // expected-note{{previous declaration is here}} template<typename T> __declspec(dllexport) inline void funcTmplRedecl4() {} // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllexport' attribute}} // Function template friends struct FuncTmplFriend { template<typename T> friend __declspec(dllexport) void funcTmplFriend1(); template<typename T> friend __declspec(dllexport) void funcTmplFriend2(); template<typename T> friend void funcTmplFriend3(); // expected-note{{previous declaration is here}} template<typename T> friend void funcTmplFriend4(); // expected-note{{previous declaration is here}} }; template<typename T> __declspec(dllexport) void funcTmplFriend1() {} template<typename T> void funcTmplFriend2() {} template<typename T> __declspec(dllexport) void funcTmplFriend3() {} // expected-error{{redeclaration of 'funcTmplFriend3' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) inline void funcTmplFriend4() {} // expected-error{{redeclaration of 'funcTmplFriend4' cannot add 'dllexport' attribute}} // External linkage is required. template<typename T> __declspec(dllexport) static int staticFuncTmpl(); // expected-error{{'staticFuncTmpl' must have external linkage when declared 'dllexport'}} template<typename T> __declspec(dllexport) Internal internalRetFuncTmpl(); // expected-error{{'internalRetFuncTmpl' must have external linkage when declared 'dllexport'}} namespace { template<typename T> __declspec(dllexport) void internalFuncTmpl(); } // expected-error{{'(anonymous namespace)::internalFuncTmpl' must have external linkage when declared 'dllexport'}} namespace ns { template<typename T> __declspec(dllexport) void externalFuncTmpl(); } template<typename T> void funcTmpl() {} template<typename T> __declspec(dllexport) void exportedFuncTmplDecl(); template<typename T> __declspec(dllexport) void exportedFuncTmpl() {} // Export implicit instantiation of an exported function template. void useFunTmplDecl() { exportedFuncTmplDecl<ImplicitInst_Exported>(); } void useFunTmplDef() { exportedFuncTmpl<ImplicitInst_Exported>(); } // Export explicit instantiation declaration of an exported function template. extern template void exportedFuncTmpl<ExplicitDecl_Exported>(); template void exportedFuncTmpl<ExplicitDecl_Exported>(); // Export explicit instantiation definition of an exported function template. template void exportedFuncTmpl<ExplicitInst_Exported>(); // Export specialization of an exported function template. template<> __declspec(dllexport) void exportedFuncTmpl<ExplicitSpec_Exported>(); template<> __declspec(dllexport) void exportedFuncTmpl<ExplicitSpec_Def_Exported>() {} template<> __declspec(dllexport) inline void exportedFuncTmpl<ExplicitSpec_InlineDef_Exported>() {} // Not exporting specialization of an exported function template without // explicit dllexport. template<> void exportedFuncTmpl<ExplicitSpec_NotExported>() {} // Export explicit instantiation declaration of a non-exported function template. extern template __declspec(dllexport) void funcTmpl<ExplicitDecl_Exported>(); template __declspec(dllexport) void funcTmpl<ExplicitDecl_Exported>(); // Export explicit instantiation definition of a non-exported function template. template __declspec(dllexport) void funcTmpl<ExplicitInst_Exported>(); // Export specialization of a non-exported function template. template<> __declspec(dllexport) void funcTmpl<ExplicitSpec_Exported>(); template<> __declspec(dllexport) void funcTmpl<ExplicitSpec_Def_Exported>() {} template<> __declspec(dllexport) inline void funcTmpl<ExplicitSpec_InlineDef_Exported>() {} //===----------------------------------------------------------------------===// // Classes //===----------------------------------------------------------------------===// namespace { struct __declspec(dllexport) AnonymousClass {}; // expected-error{{(anonymous namespace)::AnonymousClass' must have external linkage when declared 'dllexport'}} } class __declspec(dllexport) ClassDecl; class __declspec(dllexport) ClassDef {}; #ifdef MS // expected-warning@+3{{'dllexport' attribute ignored}} #endif template <typename T> struct PartiallySpecializedClassTemplate {}; template <typename T> struct __declspec(dllexport) PartiallySpecializedClassTemplate<T*> { void f() {} }; template <typename T> struct ExpliciallySpecializedClassTemplate {}; template <> struct __declspec(dllexport) ExpliciallySpecializedClassTemplate<int> { void f() {} }; // Don't instantiate class members of implicitly instantiated templates, even if they are exported. struct IncompleteType; template <typename T> struct __declspec(dllexport) ImplicitlyInstantiatedExportedTemplate { int f() { return sizeof(T); } // no-error }; ImplicitlyInstantiatedExportedTemplate<IncompleteType> implicitlyInstantiatedExportedTemplate; // Don't instantiate class members of templates with explicit instantiation declarations, even if they are exported. struct IncompleteType2; template <typename T> struct __declspec(dllexport) ExportedTemplateWithExplicitInstantiationDecl { // expected-note{{attribute is here}} int f() { return sizeof(T); } // no-error }; extern template struct ExportedTemplateWithExplicitInstantiationDecl<IncompleteType2>; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} // Instantiate class members for explicitly instantiated exported templates. struct IncompleteType3; // expected-note{{forward declaration of 'IncompleteType3'}} template <typename T> struct __declspec(dllexport) ExplicitlyInstantiatedExportedTemplate { int f() { return sizeof(T); } // expected-error{{invalid application of 'sizeof' to an incomplete type 'IncompleteType3'}} }; template struct ExplicitlyInstantiatedExportedTemplate<IncompleteType3>; // expected-note{{in instantiation of member function 'ExplicitlyInstantiatedExportedTemplate<IncompleteType3>::f' requested here}} // In MS mode, instantiate members of class templates that are base classes of exported classes. #ifdef MS // expected-note@+3{{forward declaration of 'IncompleteType4'}} // expected-note@+3{{in instantiation of member function 'BaseClassTemplateOfExportedClass<IncompleteType4>::f' requested here}} #endif struct IncompleteType4; template <typename T> struct BaseClassTemplateOfExportedClass { #ifdef MS // expected-error@+2{{invalid application of 'sizeof' to an incomplete type 'IncompleteType4'}} #endif int f() { return sizeof(T); }; }; struct __declspec(dllexport) ExportedBaseClass : public BaseClassTemplateOfExportedClass<IncompleteType4> {}; // Don't instantiate members of explicitly exported class templates that are base classes of exported classes. struct IncompleteType5; template <typename T> struct __declspec(dllexport) ExportedBaseClassTemplateOfExportedClass { int f() { return sizeof(T); }; // no-error }; struct __declspec(dllexport) ExportedBaseClass2 : public ExportedBaseClassTemplateOfExportedClass<IncompleteType5> {}; // Warn about explicit instantiation declarations of dllexport classes. template <typename T> struct ExplicitInstantiationDeclTemplate {}; extern template struct __declspec(dllexport) ExplicitInstantiationDeclTemplate<int>; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} expected-note{{attribute is here}} template <typename T> struct __declspec(dllexport) ExplicitInstantiationDeclExportedTemplate {}; // expected-note{{attribute is here}} extern template struct ExplicitInstantiationDeclExportedTemplate<int>; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} namespace { struct InternalLinkageType {}; } struct __declspec(dllexport) PR23308 { void f(InternalLinkageType*); }; void PR23308::f(InternalLinkageType*) {} // No error; we don't try to export f because it has internal linkage. //===----------------------------------------------------------------------===// // Classes with template base classes //===----------------------------------------------------------------------===// template <typename T> class ClassTemplate {}; template <typename T> class __declspec(dllexport) ExportedClassTemplate {}; template <typename T> class __declspec(dllimport) ImportedClassTemplate {}; 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>; // ClassTemplate<int> gets exported. class __declspec(dllexport) DerivedFromTemplate : public ClassTemplate<int> {}; // ClassTemplate<int> is already exported. class __declspec(dllexport) DerivedFromTemplate2 : public ClassTemplate<int> {}; // ExportedTemplate is explicitly exported. class __declspec(dllexport) DerivedFromExportedTemplate : public ExportedClassTemplate<int> {}; // ImportedTemplate is explicitly imported. class __declspec(dllexport) DerivedFromImportedTemplate : public ImportedClassTemplate<int> {}; class DerivedFromTemplateD : public ClassTemplate<double> {}; // Base class previously implicitly instantiated without attribute; it will get propagated. class __declspec(dllexport) DerivedFromTemplateD2 : public ClassTemplate<double> {}; // Base class has explicit instantiation declaration; the attribute will get propagated. extern template class ClassTemplate<float>; class __declspec(dllexport) DerivedFromTemplateF : public ClassTemplate<float> {}; class __declspec(dllexport) DerivedFromTemplateB : public ClassTemplate<bool> {}; // The second derived class doesn't change anything, the attribute that was propagated first wins. class __declspec(dllimport) DerivedFromTemplateB2 : public ClassTemplate<bool> {}; #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(dllexport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {}; // Base class alredy specialized with export attribute. struct __declspec(dllexport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate<int> {}; // Base class already specialized with import attribute. struct __declspec(dllexport) 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(dllexport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {}; // Base class already instantiated with export attribute. struct __declspec(dllexport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate<int> {}; // Base class already instantiated with import attribute. struct __declspec(dllexport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate<int> {}; template <typename T> struct ExplicitInstantiationDeclTemplateBase { void func() {} }; extern template struct ExplicitInstantiationDeclTemplateBase<int>; struct __declspec(dllexport) DerivedFromExplicitInstantiationDeclTemplateBase : public ExplicitInstantiationDeclTemplateBase<int> {}; //===----------------------------------------------------------------------===// // Precedence //===----------------------------------------------------------------------===// // dllexport takes precedence over dllimport if both are specified. __attribute__((dllimport, dllexport)) extern int PrecedenceExternGlobal1A; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllimport) __declspec(dllexport) extern int PrecedenceExternGlobal1B; // expected-warning{{'dllimport' attribute ignored}} __attribute__((dllexport, dllimport)) extern int PrecedenceExternGlobal2A; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllexport) __declspec(dllimport) extern int PrecedenceExternGlobal2B; // expected-warning{{'dllimport' attribute ignored}} __attribute__((dllimport, dllexport)) int PrecedenceGlobal1A; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B; // expected-warning{{'dllimport' attribute ignored}} __attribute__((dllexport, dllimport)) int PrecedenceGlobal2A; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllexport) extern int PrecedenceExternGlobalRedecl1; __declspec(dllimport) extern int PrecedenceExternGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllimport) extern int PrecedenceExternGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllexport) extern int PrecedenceExternGlobalRedecl2; __declspec(dllexport) extern int PrecedenceGlobalRedecl1; __declspec(dllimport) int PrecedenceGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllimport) extern int PrecedenceGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}} __declspec(dllexport) int PrecedenceGlobalRedecl2; void __attribute__((dllimport, dllexport)) precedence1A() {} // expected-warning{{'dllimport' attribute ignored}} void __declspec(dllimport) __declspec(dllexport) precedence1B() {} // expected-warning{{'dllimport' attribute ignored}} void __attribute__((dllexport, dllimport)) precedence2A() {} // expected-warning{{'dllimport' attribute ignored}} void __declspec(dllexport) __declspec(dllimport) precedence2B() {} // expected-warning{{'dllimport' attribute ignored}} void __declspec(dllimport) precedenceRedecl1(); // expected-warning{{'dllimport' attribute ignored}} void __declspec(dllexport) precedenceRedecl1() {} void __declspec(dllexport) precedenceRedecl2(); void __declspec(dllimport) precedenceRedecl2() {} // expected-warning{{'dllimport' attribute ignored}} //===----------------------------------------------------------------------===// // Class members //===----------------------------------------------------------------------===// // Export individual members of a class. struct ExportMembers { struct Nested { __declspec(dllexport) void normalDef(); }; __declspec(dllexport) void normalDecl(); __declspec(dllexport) void normalDef(); __declspec(dllexport) void normalInclass() {} __declspec(dllexport) void normalInlineDef(); __declspec(dllexport) inline void normalInlineDecl(); __declspec(dllexport) virtual void virtualDecl(); __declspec(dllexport) virtual void virtualDef(); __declspec(dllexport) virtual void virtualInclass() {} __declspec(dllexport) virtual void virtualInlineDef(); __declspec(dllexport) virtual inline void virtualInlineDecl(); __declspec(dllexport) static void staticDecl(); __declspec(dllexport) static void staticDef(); __declspec(dllexport) static void staticInclass() {} __declspec(dllexport) static void staticInlineDef(); __declspec(dllexport) static inline void staticInlineDecl(); protected: __declspec(dllexport) void protectedDef(); private: __declspec(dllexport) void privateDef(); public: __declspec(dllexport) int Field; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} __declspec(dllexport) static int StaticField; __declspec(dllexport) static int StaticFieldDef; __declspec(dllexport) static const int StaticConstField; __declspec(dllexport) static const int StaticConstFieldDef; __declspec(dllexport) static const int StaticConstFieldEqualInit = 1; __declspec(dllexport) static const int StaticConstFieldBraceInit{1}; __declspec(dllexport) constexpr static int ConstexprField = 1; __declspec(dllexport) constexpr static int ConstexprFieldDef = 1; }; void ExportMembers::Nested::normalDef() {} void ExportMembers::normalDef() {} inline void ExportMembers::normalInlineDef() {} void ExportMembers::normalInlineDecl() {} void ExportMembers::virtualDef() {} inline void ExportMembers::virtualInlineDef() {} void ExportMembers::virtualInlineDecl() {} void ExportMembers::staticDef() {} inline void ExportMembers::staticInlineDef() {} void ExportMembers::staticInlineDecl() {} void ExportMembers::protectedDef() {} void ExportMembers::privateDef() {} int ExportMembers::StaticFieldDef; const int ExportMembers::StaticConstFieldDef = 1; constexpr int ExportMembers::ConstexprFieldDef; // Export on member definitions. struct ExportMemberDefs { __declspec(dllexport) void normalDef(); __declspec(dllexport) void normalInlineDef(); __declspec(dllexport) inline void normalInlineDecl(); __declspec(dllexport) virtual void virtualDef(); __declspec(dllexport) virtual void virtualInlineDef(); __declspec(dllexport) virtual inline void virtualInlineDecl(); __declspec(dllexport) static void staticDef(); __declspec(dllexport) static void staticInlineDef(); __declspec(dllexport) static inline void staticInlineDecl(); __declspec(dllexport) static int StaticField; __declspec(dllexport) static const int StaticConstField; __declspec(dllexport) constexpr static int ConstexprField = 1; }; __declspec(dllexport) void ExportMemberDefs::normalDef() {} __declspec(dllexport) inline void ExportMemberDefs::normalInlineDef() {} __declspec(dllexport) void ExportMemberDefs::normalInlineDecl() {} __declspec(dllexport) void ExportMemberDefs::virtualDef() {} __declspec(dllexport) inline void ExportMemberDefs::virtualInlineDef() {} __declspec(dllexport) void ExportMemberDefs::virtualInlineDecl() {} __declspec(dllexport) void ExportMemberDefs::staticDef() {} __declspec(dllexport) inline void ExportMemberDefs::staticInlineDef() {} __declspec(dllexport) void ExportMemberDefs::staticInlineDecl() {} __declspec(dllexport) int ExportMemberDefs::StaticField; __declspec(dllexport) const int ExportMemberDefs::StaticConstField = 1; __declspec(dllexport) constexpr int ExportMemberDefs::ConstexprField; // Export special member functions. struct ExportSpecials { __declspec(dllexport) ExportSpecials() {} __declspec(dllexport) ~ExportSpecials(); __declspec(dllexport) inline ExportSpecials(const ExportSpecials&); __declspec(dllexport) ExportSpecials& operator=(const ExportSpecials&); __declspec(dllexport) ExportSpecials(ExportSpecials&&); __declspec(dllexport) ExportSpecials& operator=(ExportSpecials&&); }; ExportSpecials::~ExportSpecials() {} ExportSpecials::ExportSpecials(const ExportSpecials&) {} inline ExportSpecials& ExportSpecials::operator=(const ExportSpecials&) { return *this; } ExportSpecials::ExportSpecials(ExportSpecials&&) {} ExportSpecials& ExportSpecials::operator=(ExportSpecials&&) { return *this; } // Export allocation functions. extern "C" void* malloc(__SIZE_TYPE__ size); extern "C" void free(void* p); struct ExportAlloc { __declspec(dllexport) void* operator new(__SIZE_TYPE__); __declspec(dllexport) void* operator new[](__SIZE_TYPE__); __declspec(dllexport) void operator delete(void*); __declspec(dllexport) void operator delete[](void*); }; void* ExportAlloc::operator new(__SIZE_TYPE__ n) { return malloc(n); } void* ExportAlloc::operator new[](__SIZE_TYPE__ n) { return malloc(n); } void ExportAlloc::operator delete(void* p) { free(p); } void ExportAlloc::operator delete[](void* p) { free(p); } // Export deleted member functions. struct ExportDeleted { __declspec(dllexport) ExportDeleted() = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) ~ExportDeleted() = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) ExportDeleted(const ExportDeleted&) = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) ExportDeleted& operator=(const ExportDeleted&) = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) ExportDeleted(ExportDeleted&&) = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) ExportDeleted& operator=(ExportDeleted&&) = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} __declspec(dllexport) void deleted() = delete; // expected-error{{attribute 'dllexport' cannot be applied to a deleted function}} }; // Export defaulted member functions. struct ExportDefaulted { __declspec(dllexport) ExportDefaulted() = default; __declspec(dllexport) ~ExportDefaulted() = default; __declspec(dllexport) ExportDefaulted(const ExportDefaulted&) = default; __declspec(dllexport) ExportDefaulted& operator=(const ExportDefaulted&) = default; __declspec(dllexport) ExportDefaulted(ExportDefaulted&&) = default; __declspec(dllexport) ExportDefaulted& operator=(ExportDefaulted&&) = default; }; // Export defaulted member function definitions. struct ExportDefaultedDefs { __declspec(dllexport) ExportDefaultedDefs(); __declspec(dllexport) ~ExportDefaultedDefs(); __declspec(dllexport) inline ExportDefaultedDefs(const ExportDefaultedDefs&); __declspec(dllexport) ExportDefaultedDefs& operator=(const ExportDefaultedDefs&); __declspec(dllexport) ExportDefaultedDefs(ExportDefaultedDefs&&); __declspec(dllexport) ExportDefaultedDefs& operator=(ExportDefaultedDefs&&); }; // Export definitions. __declspec(dllexport) ExportDefaultedDefs::ExportDefaultedDefs() = default; ExportDefaultedDefs::~ExportDefaultedDefs() = default; // Export inline declaration and definition. __declspec(dllexport) ExportDefaultedDefs::ExportDefaultedDefs(const ExportDefaultedDefs&) = default; inline ExportDefaultedDefs& ExportDefaultedDefs::operator=(const ExportDefaultedDefs&) = default; __declspec(dllexport) ExportDefaultedDefs::ExportDefaultedDefs(ExportDefaultedDefs&&) = default; ExportDefaultedDefs& ExportDefaultedDefs::operator=(ExportDefaultedDefs&&) = default; // Redeclarations cannot add dllexport. struct MemberRedecl { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // 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 void virtualInlineDef(); // 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 void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} 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(dllexport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllexport' attribute}} __declspec(dllexport) inline void MemberRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllexport' attribute}} __declspec(dllexport) void MemberRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllexport' attribute}} __declspec(dllexport) void MemberRedecl::virtualDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllexport' attribute}} __declspec(dllexport) inline void MemberRedecl::virtualInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllexport' attribute}} __declspec(dllexport) void MemberRedecl::virtualInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllexport' attribute}} __declspec(dllexport) void MemberRedecl::staticDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllexport' attribute}} __declspec(dllexport) inline void MemberRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllexport' attribute}} __declspec(dllexport) void MemberRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllexport' attribute}} __declspec(dllexport) int MemberRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllexport' attribute}} __declspec(dllexport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllexport' attribute}} __declspec(dllexport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllexport' attribute}} //===----------------------------------------------------------------------===// // Class member templates //===----------------------------------------------------------------------===// struct ExportMemberTmpl { template<typename T> __declspec(dllexport) void normalDecl(); template<typename T> __declspec(dllexport) void normalDef(); template<typename T> __declspec(dllexport) void normalInclass() {} template<typename T> __declspec(dllexport) void normalInlineDef(); template<typename T> __declspec(dllexport) inline void normalInlineDecl(); template<typename T> __declspec(dllexport) static void staticDecl(); template<typename T> __declspec(dllexport) static void staticDef(); template<typename T> __declspec(dllexport) static void staticInclass() {} template<typename T> __declspec(dllexport) static void staticInlineDef(); template<typename T> __declspec(dllexport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template<typename T> __declspec(dllexport) static int StaticField; template<typename T> __declspec(dllexport) static int StaticFieldDef; template<typename T> __declspec(dllexport) static const int StaticConstField; template<typename T> __declspec(dllexport) static const int StaticConstFieldDef; template<typename T> __declspec(dllexport) static const int StaticConstFieldEqualInit = 1; template<typename T> __declspec(dllexport) static const int StaticConstFieldBraceInit{1}; template<typename T> __declspec(dllexport) constexpr static int ConstexprField = 1; template<typename T> __declspec(dllexport) constexpr static int ConstexprFieldDef = 1; #endif // __has_feature(cxx_variable_templates) }; template<typename T> void ExportMemberTmpl::normalDef() {} template<typename T> inline void ExportMemberTmpl::normalInlineDef() {} template<typename T> void ExportMemberTmpl::normalInlineDecl() {} template<typename T> void ExportMemberTmpl::staticDef() {} template<typename T> inline void ExportMemberTmpl::staticInlineDef() {} template<typename T> void ExportMemberTmpl::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template<typename T> int ExportMemberTmpl::StaticFieldDef; template<typename T> const int ExportMemberTmpl::StaticConstFieldDef = 1; template<typename T> constexpr int ExportMemberTmpl::ConstexprFieldDef; #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllexport. struct MemTmplRedecl { template<typename T> void normalDef(); // expected-note{{previous declaration is here}} template<typename T> void normalInlineDef(); // 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 void staticInlineDef(); // expected-note{{previous declaration is here}} template<typename T> static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #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(dllexport) void MemTmplRedecl::normalDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) inline void MemTmplRedecl::normalInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void MemTmplRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void MemTmplRedecl::staticDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) inline void MemTmplRedecl::staticInlineDef() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void MemTmplRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllexport' attribute}} #if __has_feature(cxx_variable_templates) template<typename T> __declspec(dllexport) int MemTmplRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticField' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllexport' attribute}} #endif // __has_feature(cxx_variable_templates) struct MemFunTmpl { template<typename T> void normalDef() {} template<typename T> __declspec(dllexport) void exportedNormal() {} template<typename T> static void staticDef() {} template<typename T> __declspec(dllexport) static void exportedStatic() {} }; // Export implicit instantiation of an exported member function template. void useMemFunTmpl() { MemFunTmpl().exportedNormal<ImplicitInst_Exported>(); MemFunTmpl().exportedStatic<ImplicitInst_Exported>(); } // Export explicit instantiation declaration of an exported member function // template. extern template void MemFunTmpl::exportedNormal<ExplicitDecl_Exported>(); template void MemFunTmpl::exportedNormal<ExplicitDecl_Exported>(); extern template void MemFunTmpl::exportedStatic<ExplicitDecl_Exported>(); template void MemFunTmpl::exportedStatic<ExplicitDecl_Exported>(); // Export explicit instantiation definition of an exported member function // template. template void MemFunTmpl::exportedNormal<ExplicitInst_Exported>(); template void MemFunTmpl::exportedStatic<ExplicitInst_Exported>(); // Export specialization of an exported member function template. template<> __declspec(dllexport) void MemFunTmpl::exportedNormal<ExplicitSpec_Exported>(); template<> __declspec(dllexport) void MemFunTmpl::exportedNormal<ExplicitSpec_Def_Exported>() {} template<> __declspec(dllexport) inline void MemFunTmpl::exportedNormal<ExplicitSpec_InlineDef_Exported>() {} template<> __declspec(dllexport) void MemFunTmpl::exportedStatic<ExplicitSpec_Exported>(); template<> __declspec(dllexport) void MemFunTmpl::exportedStatic<ExplicitSpec_Def_Exported>() {} template<> __declspec(dllexport) inline void MemFunTmpl::exportedStatic<ExplicitSpec_InlineDef_Exported>() {} // Not exporting specialization of an exported member function template without // explicit dllexport. template<> void MemFunTmpl::exportedNormal<ExplicitSpec_NotExported>() {} template<> void MemFunTmpl::exportedStatic<ExplicitSpec_NotExported>() {} // Export explicit instantiation declaration of a non-exported member function // template. extern template __declspec(dllexport) void MemFunTmpl::normalDef<ExplicitDecl_Exported>(); template __declspec(dllexport) void MemFunTmpl::normalDef<ExplicitDecl_Exported>(); extern template __declspec(dllexport) void MemFunTmpl::staticDef<ExplicitDecl_Exported>(); template __declspec(dllexport) void MemFunTmpl::staticDef<ExplicitDecl_Exported>(); // Export explicit instantiation definition of a non-exported member function // template. template __declspec(dllexport) void MemFunTmpl::normalDef<ExplicitInst_Exported>(); template __declspec(dllexport) void MemFunTmpl::staticDef<ExplicitInst_Exported>(); // Export specialization of a non-exported member function template. template<> __declspec(dllexport) void MemFunTmpl::normalDef<ExplicitSpec_Exported>(); template<> __declspec(dllexport) void MemFunTmpl::normalDef<ExplicitSpec_Def_Exported>() {} template<> __declspec(dllexport) inline void MemFunTmpl::normalDef<ExplicitSpec_InlineDef_Exported>() {} template<> __declspec(dllexport) void MemFunTmpl::staticDef<ExplicitSpec_Exported>(); template<> __declspec(dllexport) void MemFunTmpl::staticDef<ExplicitSpec_Def_Exported>() {} template<> __declspec(dllexport) inline void MemFunTmpl::staticDef<ExplicitSpec_InlineDef_Exported>() {} #if __has_feature(cxx_variable_templates) struct MemVarTmpl { template<typename T> static const int StaticVar = 1; template<typename T> __declspec(dllexport) static const int ExportedStaticVar = 1; }; template<typename T> const int MemVarTmpl::StaticVar; template<typename T> const int MemVarTmpl::ExportedStaticVar; // Export implicit instantiation of an exported member variable template. int useMemVarTmpl() { return MemVarTmpl::ExportedStaticVar<ImplicitInst_Exported>; } // Export explicit instantiation declaration of an exported member variable // template. extern template const int MemVarTmpl::ExportedStaticVar<ExplicitDecl_Exported>; template const int MemVarTmpl::ExportedStaticVar<ExplicitDecl_Exported>; // Export explicit instantiation definition of an exported member variable // template. template const int MemVarTmpl::ExportedStaticVar<ExplicitInst_Exported>; // Export specialization of an exported member variable template. template<> __declspec(dllexport) const int MemVarTmpl::ExportedStaticVar<ExplicitSpec_Exported>; template<> __declspec(dllexport) const int MemVarTmpl::ExportedStaticVar<ExplicitSpec_Def_Exported> = 1; // Not exporting specialization of an exported member variable template without // explicit dllexport. template<> const int MemVarTmpl::ExportedStaticVar<ExplicitSpec_NotExported>; // Export explicit instantiation declaration of a non-exported member variable // template. extern template __declspec(dllexport) const int MemVarTmpl::StaticVar<ExplicitDecl_Exported>; template __declspec(dllexport) const int MemVarTmpl::StaticVar<ExplicitDecl_Exported>; // Export explicit instantiation definition of a non-exported member variable // template. template __declspec(dllexport) const int MemVarTmpl::StaticVar<ExplicitInst_Exported>; // Export specialization of a non-exported member variable template. template<> __declspec(dllexport) const int MemVarTmpl::StaticVar<ExplicitSpec_Exported>; template<> __declspec(dllexport) const int MemVarTmpl::StaticVar<ExplicitSpec_Def_Exported> = 1; #endif // __has_feature(cxx_variable_templates) //===----------------------------------------------------------------------===// // Class template members //===----------------------------------------------------------------------===// // Export individual members of a class template. template<typename T> struct ExportClassTmplMembers { __declspec(dllexport) void normalDecl(); __declspec(dllexport) void normalDef(); __declspec(dllexport) void normalInclass() {} __declspec(dllexport) void normalInlineDef(); __declspec(dllexport) inline void normalInlineDecl(); __declspec(dllexport) virtual void virtualDecl(); __declspec(dllexport) virtual void virtualDef(); __declspec(dllexport) virtual void virtualInclass() {} __declspec(dllexport) virtual void virtualInlineDef(); __declspec(dllexport) virtual inline void virtualInlineDecl(); __declspec(dllexport) static void staticDecl(); __declspec(dllexport) static void staticDef(); __declspec(dllexport) static void staticInclass() {} __declspec(dllexport) static void staticInlineDef(); __declspec(dllexport) static inline void staticInlineDecl(); protected: __declspec(dllexport) void protectedDef(); private: __declspec(dllexport) void privateDef(); public: __declspec(dllexport) int Field; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} __declspec(dllexport) static int StaticField; __declspec(dllexport) static int StaticFieldDef; __declspec(dllexport) static const int StaticConstField; __declspec(dllexport) static const int StaticConstFieldDef; __declspec(dllexport) static const int StaticConstFieldEqualInit = 1; __declspec(dllexport) static const int StaticConstFieldBraceInit{1}; __declspec(dllexport) constexpr static int ConstexprField = 1; __declspec(dllexport) constexpr static int ConstexprFieldDef = 1; }; template<typename T> void ExportClassTmplMembers<T>::normalDef() {} template<typename T> inline void ExportClassTmplMembers<T>::normalInlineDef() {} template<typename T> void ExportClassTmplMembers<T>::normalInlineDecl() {} template<typename T> void ExportClassTmplMembers<T>::virtualDef() {} template<typename T> inline void ExportClassTmplMembers<T>::virtualInlineDef() {} template<typename T> void ExportClassTmplMembers<T>::virtualInlineDecl() {} template<typename T> void ExportClassTmplMembers<T>::staticDef() {} template<typename T> inline void ExportClassTmplMembers<T>::staticInlineDef() {} template<typename T> void ExportClassTmplMembers<T>::staticInlineDecl() {} template<typename T> void ExportClassTmplMembers<T>::protectedDef() {} template<typename T> void ExportClassTmplMembers<T>::privateDef() {} template<typename T> int ExportClassTmplMembers<T>::StaticFieldDef; template<typename T> const int ExportClassTmplMembers<T>::StaticConstFieldDef = 1; template<typename T> constexpr int ExportClassTmplMembers<T>::ConstexprFieldDef; template struct ExportClassTmplMembers<ImplicitInst_Exported>; // Redeclarations cannot add dllexport. template<typename T> struct CTMR /*ClassTmplMemberRedecl*/ { void normalDef(); // expected-note{{previous declaration is here}} void normalInlineDef(); // 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 void virtualInlineDef(); // 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 void staticInlineDef(); // expected-note{{previous declaration is here}} static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} 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(dllexport) void CTMR<T>::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) inline void CTMR<T>::normalInlineDef() {} // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void CTMR<T>::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void CTMR<T>::virtualDef() {} // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) inline void CTMR<T>::virtualInlineDef() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void CTMR<T>::virtualInlineDecl() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void CTMR<T>::staticDef() {} // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) inline void CTMR<T>::staticInlineDef() {} // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) void CTMR<T>::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) int CTMR<T>::StaticField = 1; // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) const int CTMR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllexport' attribute}} template<typename T> __declspec(dllexport) constexpr int CTMR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllexport' attribute}} //===----------------------------------------------------------------------===// // Class template member templates //===----------------------------------------------------------------------===// template<typename T> struct ExportClsTmplMemTmpl { template<typename U> __declspec(dllexport) void normalDecl(); template<typename U> __declspec(dllexport) void normalDef(); template<typename U> __declspec(dllexport) void normalInclass() {} template<typename U> __declspec(dllexport) void normalInlineDef(); template<typename U> __declspec(dllexport) inline void normalInlineDecl(); template<typename U> __declspec(dllexport) static void staticDecl(); template<typename U> __declspec(dllexport) static void staticDef(); template<typename U> __declspec(dllexport) static void staticInclass() {} template<typename U> __declspec(dllexport) static void staticInlineDef(); template<typename U> __declspec(dllexport) static inline void staticInlineDecl(); #if __has_feature(cxx_variable_templates) template<typename U> __declspec(dllexport) static int StaticField; template<typename U> __declspec(dllexport) static int StaticFieldDef; template<typename U> __declspec(dllexport) static const int StaticConstField; template<typename U> __declspec(dllexport) static const int StaticConstFieldDef; template<typename U> __declspec(dllexport) static const int StaticConstFieldEqualInit = 1; template<typename U> __declspec(dllexport) static const int StaticConstFieldBraceInit{1}; template<typename U> __declspec(dllexport) constexpr static int ConstexprField = 1; template<typename U> __declspec(dllexport) constexpr static int ConstexprFieldDef = 1; #endif // __has_feature(cxx_variable_templates) }; template<typename T> template<typename U> void ExportClsTmplMemTmpl<T>::normalDef() {} template<typename T> template<typename U> inline void ExportClsTmplMemTmpl<T>::normalInlineDef() {} template<typename T> template<typename U> void ExportClsTmplMemTmpl<T>::normalInlineDecl() {} template<typename T> template<typename U> void ExportClsTmplMemTmpl<T>::staticDef() {} template<typename T> template<typename U> inline void ExportClsTmplMemTmpl<T>::staticInlineDef() {} template<typename T> template<typename U> void ExportClsTmplMemTmpl<T>::staticInlineDecl() {} #if __has_feature(cxx_variable_templates) template<typename T> template<typename U> int ExportClsTmplMemTmpl<T>::StaticFieldDef; template<typename T> template<typename U> const int ExportClsTmplMemTmpl<T>::StaticConstFieldDef = 1; template<typename T> template<typename U> constexpr int ExportClsTmplMemTmpl<T>::ConstexprFieldDef; #endif // __has_feature(cxx_variable_templates) // Redeclarations cannot add dllexport. template<typename T> struct CTMTR /*ClassTmplMemberTmplRedecl*/ { template<typename U> void normalDef(); // expected-note{{previous declaration is here}} template<typename U> void normalInlineDef(); // 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 void staticInlineDef(); // expected-note{{previous declaration is here}} template<typename U> static inline void staticInlineDecl(); // expected-note{{previous declaration is here}} #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(dllexport) void CTMTR<T>::normalDef() {} // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) inline void CTMTR<T>::normalInlineDef() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) void CTMTR<T>::normalInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) void CTMTR<T>::staticDef() {} // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) inline void CTMTR<T>::staticInlineDef() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) void CTMTR<T>::staticInlineDecl() {} // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllexport' attribute}} #if __has_feature(cxx_variable_templates) template<typename T> template<typename U> __declspec(dllexport) int CTMTR<T>::StaticField = 1; // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) const int CTMTR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) constexpr int CTMTR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllexport' attribute}} #endif // __has_feature(cxx_variable_templates) // FIXME: Precedence rules seem to be different for classes.
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/function-extern-c.cpp
// RUN: %clang_cc1 -Wreturn-type -fsyntax-only -std=c++11 -verify %s class A { public: A(const A&); }; struct S { int i; double d; virtual void B() {} }; union U { struct { int i; virtual void B() {} // Can only do this in C++11 } t; }; struct S2 { int i; double d; }; extern "C" U f3( void ); // expected-warning {{'f3' has C-linkage specified, but returns user-defined type 'U' which is incompatible with C}} extern "C" S f0(void); // expected-warning {{'f0' has C-linkage specified, but returns user-defined type 'S' which is incompatible with C}} extern "C" A f4( void ); // expected-warning {{'f4' has C-linkage specified, but returns user-defined type 'A' which is incompatible with C}} // These should all be fine extern "C" S2 f5( void ); extern "C" void f2( A x ); extern "C" void f6( S s ); extern "C" void f7( U u ); extern "C" double f8(void); extern "C" long long f11( void ); extern "C" A *f10( void ); extern "C" struct mypodstruct f12(); // expected-warning {{'f12' has C-linkage specified, but returns incomplete type 'struct mypodstruct' which could be incompatible with C}} namespace test2 { // FIXME: we should probably suppress the first warning as the second one // is more precise. // For now this tests that a second 'extern "C"' is not necessary to trigger // the warning. struct A; extern "C" A f(void); // expected-warning {{'f' has C-linkage specified, but returns incomplete type 'test2::A' which could be incompatible with C}} struct A { A(const A&); }; A f(void); // no warning. warning is already issued on first declaration. } namespace test3 { struct A { A(const A&); }; extern "C" { // Don't warn for static functions. static A f(void); } } // rdar://13364028 namespace rdar13364028 { class A { public: virtual int x(); }; extern "C" { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreturn-type-c-linkage" A xyzzy(); #pragma clang diagnostic pop A bbb(); // expected-warning {{'bbb' has C-linkage specified, but returns user-defined type 'rdar13364028::A' which is incompatible with C}} A ccc() { // expected-warning {{'ccc' has C-linkage specified, but returns user-defined type 'rdar13364028::A' which is incompatible with C}} return A(); }; } A xyzzy(); A xyzzy() { return A(); } A bbb() { return A(); } A bbb(); A ccc(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/for-range-dereference.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s struct Data { }; struct T { Data *begin(); Data *end(); }; struct NoBegin { Data *end(); }; struct DeletedEnd : public T { Data *begin(); Data *end() = delete; //expected-note {{'end' has been explicitly marked deleted here}} }; struct DeletedADLBegin { }; int* begin(DeletedADLBegin) = delete; //expected-note {{candidate function has been explicitly deleted}} \ expected-note 5 {{candidate function not viable: no known conversion}} struct PrivateEnd { Data *begin(); private: Data *end(); // expected-note 2 {{declared private here}} }; struct ADLNoEnd { }; Data * begin(ADLNoEnd); // expected-note 6 {{candidate function not viable: no known conversion}} struct OverloadedStar { T operator*(); }; void f() { T t; for (auto i : t) { } T *pt; for (auto i : pt) { } // expected-error{{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}} int arr[10]; for (auto i : arr) { } int (*parr)[10]; for (auto i : parr) { }// expected-error{{invalid range expression of type 'int (*)[10]'; did you mean to dereference it with '*'?}} NoBegin NB; for (auto i : NB) { }// expected-error{{range type 'NoBegin' has 'end' member but no 'begin' member}} NoBegin *pNB; for (auto i : pNB) { }// expected-error{{invalid range expression of type 'NoBegin *'; no viable 'begin' function available}} NoBegin **ppNB; for (auto i : ppNB) { }// expected-error{{invalid range expression of type 'NoBegin **'; no viable 'begin' function available}} NoBegin *****pppppNB; for (auto i : pppppNB) { }// expected-error{{invalid range expression of type 'NoBegin *****'; no viable 'begin' function available}} ADLNoEnd ANE; for (auto i : ANE) { } // expected-error{{invalid range expression of type 'ADLNoEnd'; no viable 'end' function available}} ADLNoEnd *pANE; for (auto i : pANE) { } // expected-error{{invalid range expression of type 'ADLNoEnd *'; no viable 'begin' function available}} DeletedEnd DE; for (auto i : DE) { } // expected-error{{attempt to use a deleted function}} \ expected-note {{when looking up 'end' function for range expression of type 'DeletedEnd'}} DeletedEnd *pDE; for (auto i : pDE) { } // expected-error {{invalid range expression of type 'DeletedEnd *'; no viable 'begin' function available}} PrivateEnd PE; // FIXME: This diagnostic should be improved, as it does not specify that // the range is invalid. for (auto i : PE) { } // expected-error{{'end' is a private member of 'PrivateEnd'}} PrivateEnd *pPE; for (auto i : pPE) { }// expected-error {{invalid range expression of type 'PrivateEnd *'}} // expected-error@-1 {{'end' is a private member of 'PrivateEnd'}} DeletedADLBegin DAB; for (auto i : DAB) { } // expected-error {{call to deleted function 'begin'}}\ expected-note {{when looking up 'begin' function for range expression of type 'DeletedADLBegin'}} OverloadedStar OS; for (auto i : *OS) { } for (auto i : OS) { } // expected-error {{invalid range expression of type 'OverloadedStar'; did you mean to dereference it with '*'?}} for (Data *p : pt) { } // expected-error {{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}} // expected-error@-1 {{no viable conversion from 'Data' to 'Data *'}} // expected-note@4 {{selected 'begin' function with iterator type 'Data *'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-sizeof-array-argument %s // extern "C" void *memset(void *, int, unsigned); extern "C" void *memmove(void *s1, const void *s2, unsigned n); extern "C" void *memcpy(void *s1, const void *s2, unsigned n); extern "C" void *memcmp(void *s1, const void *s2, unsigned n); struct S {int a, b, c, d;}; typedef S* PS; struct Foo {}; typedef const Foo& CFooRef; typedef const Foo CFoo; typedef volatile Foo VFoo; typedef const volatile Foo CVFoo; typedef double Mat[4][4]; template <class Dest, class Source> inline Dest bit_cast(const Source& source) { Dest dest; memcpy(&dest, &source, sizeof(dest)); return dest; } // http://www.lysator.liu.se/c/c-faq/c-2.html#2-6 void f(Mat m, const Foo& const_foo, char *buffer) { S s; S* ps = &s; PS ps2 = &s; char arr[5]; char* parr[5]; Foo foo; char* heap_buffer = new char[42]; /* Should warn */ memset(&s, 0, sizeof(&s)); // \ // expected-warning {{'memset' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?}} memset(ps, 0, sizeof(ps)); // \ // expected-warning {{'memset' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} memset(ps2, 0, sizeof(ps2)); // \ // expected-warning {{'memset' call operates on objects of type 'S' while the size is based on a different type 'PS' (aka 'S *')}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} memset(ps2, 0, sizeof(typeof(ps2))); // \ // expected-warning {{argument to 'sizeof' in 'memset' call is the same pointer type}} memset(ps2, 0, sizeof(PS)); // \ // expected-warning {{argument to 'sizeof' in 'memset' call is the same pointer type}} memset(heap_buffer, 0, sizeof(heap_buffer)); // \ // expected-warning {{'memset' call operates on objects of type 'char' while the size is based on a different type 'char *'}} expected-note{{did you mean to provide an explicit length?}} memcpy(&s, 0, sizeof(&s)); // \ // expected-warning {{'memcpy' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?}} memcpy(0, &s, sizeof(&s)); // \ // expected-warning {{'memcpy' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?}} memmove(ps, 0, sizeof(ps)); // \ // expected-warning {{'memmove' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} memcmp(ps, 0, sizeof(ps)); // \ // expected-warning {{'memcmp' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} /* Shouldn't warn */ memset((void*)&s, 0, sizeof(&s)); memset(&s, 0, sizeof(s)); memset(&s, 0, sizeof(S)); memset(&s, 0, sizeof(const S)); memset(&s, 0, sizeof(volatile S)); memset(&s, 0, sizeof(volatile const S)); memset(&foo, 0, sizeof(CFoo)); memset(&foo, 0, sizeof(VFoo)); memset(&foo, 0, sizeof(CVFoo)); memset(ps, 0, sizeof(*ps)); memset(ps2, 0, sizeof(*ps2)); memset(ps2, 0, sizeof(typeof(*ps2))); memset(arr, 0, sizeof(arr)); memset(parr, 0, sizeof(parr)); memcpy(&foo, &const_foo, sizeof(Foo)); memcpy((void*)&s, 0, sizeof(&s)); memcpy(0, (void*)&s, sizeof(&s)); char *cptr; memcpy(&cptr, buffer, sizeof(cptr)); memcpy((char*)&cptr, buffer, sizeof(cptr)); CFooRef cfoo = foo; memcpy(&foo, &cfoo, sizeof(Foo)); memcpy(0, &arr, sizeof(arr)); typedef char Buff[8]; memcpy(0, &arr, sizeof(Buff)); unsigned char* puc; bit_cast<char*>(puc); float* pf; bit_cast<int*>(pf); int iarr[14]; memset(&iarr[0], 0, sizeof iarr); memset(iarr, 0, sizeof iarr); int* iparr[14]; memset(&iparr[0], 0, sizeof iparr); memset(iparr, 0, sizeof iparr); memset(m, 0, sizeof(Mat)); // Copy to raw buffer shouldn't warn either memcpy(&foo, &arr, sizeof(Foo)); memcpy(&arr, &foo, sizeof(Foo)); // Shouldn't warn, and shouldn't crash either. memset(({ if (0) {} while (0) {} for (;;) {} &s; }), 0, sizeof(s)); } namespace ns { void memset(void* s, char c, int n); void f(int* i) { memset(i, 0, sizeof(i)); } } extern "C" int strncmp(const char *s1, const char *s2, unsigned n); extern "C" int strncasecmp(const char *s1, const char *s2, unsigned n); extern "C" char *strncpy(char *det, const char *src, unsigned n); extern "C" char *strncat(char *dst, const char *src, unsigned n); extern "C" char *strndup(const char *src, unsigned n); void strcpy_and_friends() { const char* FOO = "<- should be an array instead"; const char* BAR = "<- this, too"; strncmp(FOO, BAR, sizeof(FOO)); // \ // expected-warning {{'strncmp' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} strncasecmp(FOO, BAR, sizeof(FOO)); // \ // expected-warning {{'strncasecmp' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} char buff[80]; strncpy(buff, BAR, sizeof(BAR)); // \ // expected-warning {{'strncpy' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} strndup(FOO, sizeof(FOO)); // \ // expected-warning {{'strndup' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/trivial-destructor.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // expected-no-diagnostics struct T1 { }; static_assert(__has_trivial_destructor(T1), "T1 has trivial destructor!"); struct T2 { ~T2(); }; static_assert(!__has_trivial_destructor(T2), "T2 has a user-declared destructor!"); struct T3 { virtual void f(); }; static_assert(__has_trivial_destructor(T3), "T3 has a virtual function (but still a trivial destructor)!"); struct T4 : virtual T3 { }; static_assert(__has_trivial_destructor(T4), "T4 has a virtual base class! (but still a trivial destructor)!"); struct T5 : T1 { }; static_assert(__has_trivial_destructor(T5), "All the direct base classes of T5 have trivial destructors!"); struct T6 { T5 t5; T1 t1[2][2]; static T2 t2; }; static_assert(__has_trivial_destructor(T6), "All nonstatic data members of T6 have trivial destructors!"); struct T7 { T2 t2; }; static_assert(!__has_trivial_destructor(T7), "t2 does not have a trivial destructor!"); struct T8 : T2 { }; static_assert(!__has_trivial_destructor(T8), "The base class T2 does not have a trivial destructor!");
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/ms-interface.cpp
// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11 __interface I1 { // expected-error@+1 {{user-declared constructor is not permitted within an interface type}} I1(); // expected-error@+1 {{user-declared destructor is not permitted within an interface type}} ~I1(); virtual void fn1() const; // expected-error@+1 {{operator 'operator!' is not permitted within an interface type}} bool operator!(); // expected-error@+1 {{operator 'operator int' is not permitted within an interface type}} operator int(); // expected-error@+1 {{nested class I1::(anonymous) is not permitted within an interface type}} struct { int a; }; void fn2() { struct A { }; // should be ignored: not a nested class } protected: // expected-error {{interface types cannot specify 'protected' access}} typedef void void_t; using int_t = int; private: // expected-error {{interface types cannot specify 'private' access}} static_assert(true, "oops"); }; __interface I2 { // expected-error@+1 {{data member 'i' is not permitted within an interface type}} int i; // expected-error@+1 {{static member function 'fn1' is not permitted within an interface type}} static int fn1(); private: // expected-error {{interface types cannot specify 'private' access}} // expected-error@+1 {{non-public member function 'fn2' is not permitted within an interface type}} void fn2(); protected: // expected-error {{interface types cannot specify 'protected' access}} // expected-error@+1 {{non-public member function 'fn3' is not permitted within an interface type}} void fn3(); public: void fn4(); }; // expected-error@+1 {{'final' keyword not permitted with interface types}} __interface I3 final { }; __interface I4 : I1, I2 { void fn1() const override; // expected-error@+1 {{'final' keyword not permitted with interface types}} void fn2() final; }; // expected-error@+1 {{interface type cannot inherit from non-public 'interface I1'}} __interface I5 : private I1 { }; template <typename X> __interface I6 : X { }; struct S { }; class C { }; __interface I { }; static_assert(!__is_interface_class(S), "oops"); static_assert(!__is_interface_class(C), "oops"); static_assert(__is_interface_class(I), "oops"); // expected-error@55 {{interface type cannot inherit from 'struct S'}} // expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}} struct S1 : I6<S> { }; // expected-error@55 {{interface type cannot inherit from 'class C'}} // expected-note@+1 {{in instantiation of template class 'I6<C>' requested here}} class C1 : I6<C> { }; class C2 : I6<I> { };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-unsequenced.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused %s int f(int, int = 0); struct A { int x, y; }; struct S { S(int, int); int n; }; void test() { int a; int xs[10]; ++a = 0; // ok a + ++a; // expected-warning {{unsequenced modification and access to 'a'}} a = ++a; // ok a + a++; // expected-warning {{unsequenced modification and access to 'a'}} a = a++; // expected-warning {{multiple unsequenced modifications to 'a'}} ++ ++a; // ok (a++, a++); // ok ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}} a++ + a++; // expected-warning {{multiple unsequenced modifications}} (a++, a) = 0; // ok, increment is sequenced before value computation of LHS a = xs[++a]; // ok a = xs[a++]; // expected-warning {{multiple unsequenced modifications}} (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification and access}} a = (++a, ++a); // ok a = (a++, ++a); // ok a = (a++, a++); // expected-warning {{multiple unsequenced modifications}} f(a, a); // ok f(a = 0, a); // expected-warning {{unsequenced modification and access}} f(a, a += 0); // expected-warning {{unsequenced modification and access}} f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}} a = f(++a); // ok a = f(a++); // ok a = f(++a, a++); // expected-warning {{multiple unsequenced modifications}} // Compound assignment "A OP= B" is equivalent to "A = A OP B" except that A // is evaluated only once. (++a, a) = 1; // ok (++a, a) += 1; // ok a = ++a; // ok a += ++a; // expected-warning {{unsequenced modification and access}} A agg1 = { a++, a++ }; // ok A agg2 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}} S str1(a++, a++); // expected-warning {{multiple unsequenced modifications}} S str2 = { a++, a++ }; // ok S str3 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}} struct Z { A a; S s; } z = { { ++a, ++a }, { ++a, ++a } }; // ok a = S { ++a, a++ }.n; // ok A { ++a, a++ }.x; // ok a = A { ++a, a++ }.x; // expected-warning {{unsequenced modifications}} A { ++a, a++ }.x + A { ++a, a++ }.y; // expected-warning {{unsequenced modifications}} (xs[2] && (a = 0)) + a; // ok (0 && (a = 0)) + a; // ok (1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access}} (xs[3] || (a = 0)) + a; // ok (0 || (a = 0)) + a; // expected-warning {{unsequenced modification and access}} (1 || (a = 0)) + a; // ok (xs[4] ? a : ++a) + a; // ok (0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access}} (1 ? a : ++a) + a; // ok (0 ? a : a++) + a; // expected-warning {{unsequenced modification and access}} (1 ? a : a++) + a; // ok (xs[5] ? ++a : ++a) + a; // FIXME: warn here (++a, xs[6] ? ++a : 0) + a; // expected-warning {{unsequenced modification and access}} // Here, the read of the fourth 'a' might happen before or after the write to // the second 'a'. a += (a++, a) + a; // expected-warning {{unsequenced modification and access}} int *p = xs; a = *(a++, p); // ok a = a++ && a; // ok A *q = &agg1; (q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and access to 'q'}} // This has undefined behavior if a == 0; otherwise, the side-effect of the // increment is sequenced before the value computation of 'f(a, a)', which is // sequenced before the value computation of the '&&', which is sequenced // before the assignment. We treat the sequencing in '&&' as being // unconditional. a = a++ && f(a, a); // This has undefined behavior if a != 0. FIXME: We should diagnose this. (a && a++) + a; (xs[7] && ++a) * (!xs[7] && ++a); // ok xs[0] = (a = 1, a); // ok (a -= 128) &= 128; // ok ++a += 1; // ok xs[8] ? ++a + a++ : 0; // expected-warning {{multiple unsequenced modifications}} xs[8] ? 0 : ++a + a++; // expected-warning {{multiple unsequenced modifications}} xs[8] ? ++a : a++; // ok xs[8] && (++a + a++); // expected-warning {{multiple unsequenced modifications}} xs[8] || (++a + a++); // expected-warning {{multiple unsequenced modifications}} (__builtin_classify_type(++a) ? 1 : 0) + ++a; // ok (__builtin_constant_p(++a) ? 1 : 0) + ++a; // ok (__builtin_object_size(&(++a, a), 0) ? 1 : 0) + ++a; // ok (__builtin_expect(++a, 0) ? 1 : 0) + ++a; // expected-warning {{multiple unsequenced modifications}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/conversion-delete-expr.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // Test1 struct B { operator char *(); // expected-note {{conversion to pointer type}} }; struct D : B { operator int *(); // expected-note {{conversion to pointer type}} }; void f (D d) { delete d; // expected-error {{ambiguous conversion of delete expression of type 'D' to a pointer}} } // Test2 struct B1 { operator int *(); }; struct D1 : B1 { operator int *(); }; void f1 (D1 d) { delete d; } // Test3 struct B2 { operator const int *(); // expected-note {{conversion to pointer type}} }; struct D2 : B2 { operator int *(); // expected-note {{conversion to pointer type}} }; void f2 (D2 d) { delete d; // expected-error {{ambiguous conversion of delete expression of type 'D2' to a pointer}} } // Test4 struct B3 { operator const int *(); // expected-note {{conversion to pointer type}} }; struct A3 { operator const int *(); // expected-note {{conversion to pointer type}} }; struct D3 : A3, B3 { }; void f3 (D3 d) { delete d; // expected-error {{ambiguous conversion of delete expression of type 'D3' to a pointer}} } // Test5 struct X { operator int(); operator int*(); }; void f4(X x) { delete x; delete x; } // Test6 struct X1 { operator int(); operator int*(); template<typename T> operator T*() const; // converts to any pointer! }; void f5(X1 x) { delete x; } // OK. In selecting a conversion to pointer function, template convesions are skipped. // Test7 struct Base { operator int*(); }; struct Derived : Base { // not the same function as Base's non-const operator int() operator int*() const; }; void foo6(const Derived cd, Derived d) { // overload resolution selects Derived::operator int*() const; delete cd; delete d; } // Test8 struct BB { template<typename T> operator T*() const; }; struct DD : BB { template<typename T> operator T*() const; // hides base conversion operator int *() const; }; void foo7 (DD d) { // OK. In selecting a conversion to pointer function, template convesions are skipped. delete d; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/ms-exception-spec.cpp
// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions // expected-no-diagnostics void f() throw(...) { }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/captured-statements.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -fblocks void test_nest_lambda() { int x; int y; [&,y]() { int z; #pragma clang __debug captured { x = y; // OK y = z; // expected-error{{cannot assign to a variable captured by copy in a non-mutable lambda}} z = y; // OK } }(); int a; #pragma clang __debug captured { int b; int c; [&,c]() { a = b; // OK b = c; // OK c = a; // expected-error{{cannot assign to a variable captured by copy in a non-mutable lambda}} }(); } } class test_obj_capture { int a; void b(); static void test() { test_obj_capture c; #pragma clang __debug captured { (void)c.a; } // OK #pragma clang __debug captured { c.b(); } // OK } }; class test_this_capture { int a; void b(); void test() { #pragma clang __debug captured { (void)this; } // OK #pragma clang __debug captured { (void)a; } // OK #pragma clang __debug captured { b(); } // OK } }; template <typename T> void template_capture_var() { T x; // expected-error{{declaration of reference variable 'x' requires an initializer}} #pragma clang _debug captured { (void)x; } } template <typename T> class Val { T v; public: void set(const T &v0) { #pragma clang __debug captured { v = v0; } } }; void test_capture_var() { template_capture_var<int>(); // OK template_capture_var<int&>(); // expected-note{{in instantiation of function template specialization 'template_capture_var<int &>' requested here}} Val<float> Obj; Obj.set(0.0f); // OK } template <typename S, typename T> S template_capture_var(S x, T y) { // expected-note{{variable 'y' declared const here}} #pragma clang _debug captured { x++; y++; // expected-error{{cannot assign to variable 'y' with const-qualified type 'const int'}} } return x; } // Check if can recover from a template error. void test_capture_var_error() { template_capture_var<int, int>(0, 1); // OK template_capture_var<int, const int>(0, 1); // expected-note{{in instantiation of function template specialization 'template_capture_var<int, const int>' requested here}} template_capture_var<int, int>(0, 1); // OK } template <typename T> void template_capture_in_lambda() { T x, y; [=, &y]() { #pragma clang __debug captured { y += x; } }(); } void test_lambda() { template_capture_in_lambda<int>(); // OK } struct Foo { void foo() { } static void bar() { } }; template <typename T> void template_capture_func(T &t) { #pragma clang __debug captured { t.foo(); } #pragma clang __debug captured { T::bar(); } } void test_template_capture_func() { Foo Obj; template_capture_func(Obj); } template <typename T> T captured_sum(const T &a, const T &b) { T result; #pragma clang __debug captured { result = a + b; } return result; } template <typename T, typename... Args> T captured_sum(const T &a, const Args&... args) { T result; #pragma clang __debug captured { result = a + captured_sum(args...); } return result; } void test_capture_variadic() { (void)captured_sum(1, 2, 3); // OK (void)captured_sum(1, 2, 3, 4, 5); // OK } void test_capture_with_attributes() { [[]] // expected-error {{an attribute list cannot appear here}} #pragma clang __debug captured { } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/decltype-overloaded-functions.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 void f(); // expected-note{{possible target for call}} void f(int); // expected-note{{possible target for call}} decltype(f) a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{variable has incomplete type 'decltype(f())' (aka 'void')}} template<typename T> struct S { decltype(T::f) * f; // expected-error {{call to non-static member function without an object argument}} }; struct K { void f(); void f(int); }; S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}} namespace PR13978 { template<typename T> struct S { decltype(1) f(); }; template<typename T> decltype(1) S<T>::f() { return 1; } // This case is ill-formed (no diagnostic required) because the decltype // expressions are functionally equivalent but not equivalent. It would // be acceptable for us to reject this case. template<typename T> struct U { struct A {}; decltype(A{}) f(); }; template<typename T> decltype(typename U<T>::A{}) U<T>::f() {} // This case is valid. template<typename T> struct V { struct A {}; decltype(typename V<T>::A{}) f(); }; template<typename T> decltype(typename V<T>::A{}) V<T>::f() {} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/virtual-override-x86.cpp
// RUN: %clang_cc1 -triple=i686-pc-win32 -fsyntax-only -verify %s -std=c++11 namespace PR14339 { class A { public: virtual void __attribute__((thiscall)) f(); // expected-note{{overridden virtual function is here}} }; class B : public A { public: void __attribute__((cdecl)) f(); // expected-error{{virtual function 'f' has different calling convention attributes ('void () __attribute__((cdecl))') than the function it overrides (which has calling convention 'void () __attribute__((thiscall))'}} }; class C : public A { public: void __attribute__((thiscall)) f(); // This override is correct }; class D : public A { public: void f(); // This override is correct because thiscall is the default calling convention for class members }; class E { public: virtual void __attribute__((stdcall)) g(); // expected-note{{overridden virtual function is here}} }; class F : public E { public: void g(); // expected-error{{virtual function 'g' has different calling convention attributes ('void () __attribute__((thiscall))') than the function it overrides (which has calling convention 'void () __attribute__((stdcall))'}} }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overload-call.cpp
// RUN: %clang_cc1 -pedantic -verify %s int* f(int) { return 0; } float* f(float) { return 0; } void f(); void test_f(int iv, float fv) { float* fp = f(fv); int* ip = f(iv); } int* g(int, float, int); // expected-note {{candidate function}} float* g(int, int, int); // expected-note {{candidate function}} double* g(int, float, float); // expected-note {{candidate function}} char* g(int, float, ...); // expected-note {{candidate function}} void g(); void test_g(int iv, float fv) { int* ip1 = g(iv, fv, 0); float* fp1 = g(iv, iv, 0); double* dp1 = g(iv, fv, fv); char* cp1 = g(0, 0); char* cp2 = g(0, 0, 0, iv, fv); double* dp2 = g(0, fv, 1.5); // expected-error {{call to 'g' is ambiguous}} } double* h(double f); int* h(int); void test_h(float fv, unsigned char cv) { double* dp = h(fv); int* ip = h(cv); } int* i(int); double* i(long); void test_i(short sv, int iv, long lv, unsigned char ucv) { int* ip1 = i(sv); int* ip2 = i(iv); int* ip3 = i(ucv); double* dp1 = i(lv); } int* j(void*); double* j(bool); void test_j(int* ip) { int* ip1 = j(ip); } int* k(char*); double* k(bool); void test_k() { int* ip1 = k("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}} int* ip2 = k(("foo")); // expected-warning{{conversion from string literal to 'char *' is deprecated}} double* dp1 = k(L"foo"); } int* l(wchar_t*); double* l(bool); void test_l() { int* ip1 = l(L"foo"); // expected-warning{{conversion from string literal to 'wchar_t *' is deprecated}} double* dp1 = l("foo"); } int* m(const char*); double* m(char*); void test_m() { int* ip = m("foo"); } int* n(char*); double* n(void*); class E; void test_n(E* e) { char ca[7]; int* ip1 = n(ca); int* ip2 = n("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}} float fa[7]; double* dp1 = n(fa); double* dp2 = n(e); } enum PromotesToInt { PromotesToIntValue = -1 }; enum PromotesToUnsignedInt { PromotesToUnsignedIntValue = __INT_MAX__ * 2U }; int* o(int); double* o(unsigned int); float* o(long); void test_o() { int* ip1 = o(PromotesToIntValue); double* dp1 = o(PromotesToUnsignedIntValue); } int* p(int); double* p(double); void test_p() { int* ip = p((short)1); double* dp = p(1.0f); } struct Bits { signed short int_bitfield : 5; unsigned int uint_bitfield : 8; }; int* bitfields(int, int); float* bitfields(unsigned int, int); void test_bitfield(Bits bits, int x) { int* ip = bitfields(bits.int_bitfield, 0); float* fp = bitfields(bits.uint_bitfield, 0u); } int* multiparm(long, int, long); // expected-note {{candidate function}} float* multiparm(int, int, int); // expected-note {{candidate function}} double* multiparm(int, int, short); // expected-note {{candidate function}} void test_multiparm(long lv, short sv, int iv) { int* ip1 = multiparm(lv, iv, lv); int* ip2 = multiparm(lv, sv, lv); float* fp1 = multiparm(iv, iv, iv); float* fp2 = multiparm(sv, iv, iv); double* dp1 = multiparm(sv, sv, sv); double* dp2 = multiparm(iv, sv, sv); multiparm(sv, sv, lv); // expected-error {{call to 'multiparm' is ambiguous}} } // Test overloading based on qualification vs. no qualification // conversion. int* quals1(int const * p); char* quals1(int * p); int* quals2(int const * const * pp); char* quals2(int * * pp); int* quals3(int const * * const * ppp); char* quals3(int *** ppp); void test_quals(int * p, int * * pp, int * * * ppp) { char* q1 = quals1(p); char* q2 = quals2(pp); char* q3 = quals3(ppp); } // Test overloading based on qualification ranking (C++ 13.3.2)p3. int* quals_rank1(int const * p); float* quals_rank1(int const volatile *p); char* quals_rank1(char*); double* quals_rank1(const char*); int* quals_rank2(int const * const * pp); float* quals_rank2(int * const * pp); void quals_rank3(int const * const * const volatile * p); // expected-note{{candidate function}} void quals_rank3(int const * const volatile * const * p); // expected-note{{candidate function}} void quals_rank3(int const *); // expected-note{{candidate function}} void quals_rank3(int volatile *); // expected-note{{candidate function}} void test_quals_ranking(int * p, int volatile *pq, int * * pp, int * * * ppp) { int* q1 = quals_rank1(p); float* q2 = quals_rank1(pq); double* q3 = quals_rank1("string literal"); char a[17]; const char* ap = a; char* q4 = quals_rank1(a); double* q5 = quals_rank1(ap); float* q6 = quals_rank2(pp); quals_rank3(ppp); // expected-error {{call to 'quals_rank3' is ambiguous}} quals_rank3(p); // expected-error {{call to 'quals_rank3' is ambiguous}} quals_rank3(pq); } // Test overloading based on derived-to-base conversions class A { }; class B : public A { }; class C : public B { }; class D : public C { }; int* derived1(A*); char* derived1(const A*); float* derived1(void*); int* derived2(A*); float* derived2(B*); int* derived3(A*); float* derived3(const B*); char* derived3(C*); void test_derived(B* b, B const* bc, C* c, const C* cc, void* v, D* d) { int* d1 = derived1(b); char* d2 = derived1(bc); int* d3 = derived1(c); char* d4 = derived1(cc); float* d5 = derived1(v); float* d6 = derived2(b); float* d7 = derived2(c); char* d8 = derived3(d); } void derived4(C*); // expected-note{{candidate function not viable: cannot convert from base class pointer 'A *' to derived class pointer 'C *' for 1st argument}} void test_base(A* a) { derived4(a); // expected-error{{no matching function for call to 'derived4}} } // Test overloading of references. // (FIXME: tests binding to determine candidate sets, not overload // resolution per se). int* intref(int&); float* intref(const int&); void intref_test() { float* ir1 = intref(5); float* ir2 = intref(5.5); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 5.5 to 5}} } void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}} void test_base(A& a) { derived5(a); // expected-error{{no matching function for call to 'derived5}} } // Test reference binding vs. standard conversions. int& bind_vs_conv(const double&); float& bind_vs_conv(int); void bind_vs_conv_test() { int& i1 = bind_vs_conv(1.0f); float& f1 = bind_vs_conv((short)1); } // Test that cv-qualifiers get subsumed in the reference binding. struct X { }; struct Y { }; struct Z : X, Y { }; int& cvqual_subsume(X&); // expected-note{{candidate function}} float& cvqual_subsume(const Y&); // expected-note{{candidate function}} int& cvqual_subsume2(X&); // expected-note{{candidate function}} float& cvqual_subsume2(volatile Y&); // expected-note{{candidate function}} void cvqual_subsume_test(Z z) { cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous}} cvqual_subsume2(z); // expected-error{{call to 'cvqual_subsume2' is ambiguous}} } // Test overloading with cv-qualification differences in reference // binding. int& cvqual_diff(X&); float& cvqual_diff(const X&); void cvqual_diff_test(X x, Z z) { int& i1 = cvqual_diff(x); int& i2 = cvqual_diff(z); } // Test overloading with derived-to-base differences in reference // binding. struct Z2 : Z { }; int& db_rebind(X&); long& db_rebind(Y&); float& db_rebind(Z&); void db_rebind_test(Z2 z2) { float& f1 = db_rebind(z2); } class string { }; class opt : public string { }; struct SR { SR(const string&); }; void f(SR) { } void g(opt o) { f(o); } namespace PR5756 { int &a(void*, int); float &a(void*, float); void b() { int &ir = a(0,0); (void)ir; } } // Tests the exact text used to note the candidates namespace test1 { template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, int u = 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} // PR 11857 void foo(int n); // expected-note {{candidate function not viable: requires single argument 'n', but 2 arguments were provided}} void foo(unsigned n = 10); // expected-note {{candidate function not viable: allows at most single argument 'n', but 2 arguments were provided}} void bar(int n, int u = 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}} void baz(int n = 0, int u = 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}} void test() { foo(4, "hello"); //expected-error {{no matching function for call to 'foo'}} bar(); //expected-error {{no matching function for call to 'bar'}} baz(3, 4, 5); // expected-error {{no matching function for call to 'baz'}} } } // PR 6014 namespace test2 { struct QFixed { QFixed(int i); QFixed(long i); }; bool operator==(const QFixed &f, int i); class qrgb666 { inline operator unsigned int () const; inline bool operator==(const qrgb666 &v) const; inline bool operator!=(const qrgb666 &v) const { return !(*this == v); } }; } // PR 6117 namespace test3 { struct Base {}; struct Incomplete; void foo(Base *); // expected-note 2 {{cannot convert argument of incomplete type}} void foo(Base &); // expected-note 2 {{cannot convert argument of incomplete type}} void test(Incomplete *P) { foo(P); // expected-error {{no matching function for call to 'foo'}} foo(*P); // expected-error {{no matching function for call to 'foo'}} } } namespace DerivedToBaseVsVoid { struct A { }; struct B : A { }; float &f(void *); int &f(const A*); void g(B *b) { int &ir = f(b); } } // PR 6398 + PR 6421 namespace test4 { class A; class B { static void foo(); // expected-note {{not viable}} static void foo(int*); // expected-note {{not viable}} static void foo(long*); // expected-note {{not viable}} void bar(A *a) { foo(a); // expected-error {{no matching function for call}} } }; } namespace DerivedToBase { struct A { }; struct B : A { }; struct C : B { }; int &f0(const A&); float &f0(B); void g() { float &fr = f0(C()); } } namespace PR6483 { struct X0 { operator const unsigned int & () const; }; struct X1 { operator unsigned int & () const; }; void f0(const bool &); void f1(bool &); // expected-note 2{{not viable}} void g(X0 x0, X1 x1) { f0(x0); f1(x0); // expected-error{{no matching function for call}} f0(x1); f1(x1); // expected-error{{no matching function for call}} } } namespace PR6078 { struct A { A(short); // expected-note{{candidate constructor}} A(long); // expected-note{{candidate constructor}} }; struct S { typedef void ft(A); operator ft*(); }; void f() { S()(0); // expected-error{{conversion from 'int' to 'PR6078::A' is ambiguous}} } } namespace PR6177 { struct String { String(char const*); }; void f(bool const volatile&); int &f(String); void g() { int &r = f(""); } } namespace PR7095 { struct X { }; struct Y { operator const X*(); private: operator X*(); }; void f(const X *); void g(Y y) { f(y); } } namespace PR7224 { class A {}; class B : public A {}; int &foo(A *const d); float &foo(const A *const d); void bar() { B *const d = 0; B const *const d2 = 0; int &ir = foo(d); float &fr = foo(d2); } } namespace NontrivialSubsequence { struct X0; class A { operator X0 *(); public: operator const X0 *(); }; A a; void foo( void const * ); void g() { foo(a); } } // rdar://rdar8499524 namespace rdar8499524 { struct W {}; struct S { S(...); }; void g(const S&); void f() { g(W()); } } namespace rdar9173984 { template <typename T, unsigned long N> int &f(const T (&)[N]); template <typename T> float &f(const T *); void test() { int arr[2] = {0, 0}; int *arrp = arr; int &ir = f(arr); float &fr = f(arrp); } } namespace PR9507 { void f(int * const&); // expected-note{{candidate function}} void f(int const(&)[1]); // expected-note{{candidate function}} int main() { int n[1]; f(n); // expected-error{{call to 'f' is ambiguous}} } } namespace rdar9803316 { void foo(float); int &foo(int); void bar() { int &ir = (&foo)(0); } } namespace IncompleteArg { // Ensure that overload resolution attempts to complete argument types when // performing ADL. template<typename T> struct S { friend int f(const S&); }; extern S<int> s; int k = f(s); template<typename T> struct Op { friend bool operator==(const Op &, const Op &); }; extern Op<char> op; bool b = op == op; // ... and not in other cases! Nothing here requires U<int()> to be complete. // (Note that instantiating U<int()> will fail.) template<typename T> struct U { T t; }; struct Consumer { template<typename T> int operator()(const U<T> &); }; template<typename T> U<T> &make(); Consumer c; int n = sizeof(c(make<int()>())); } namespace PR12142 { void fun(int (*x)[10]); // expected-note{{candidate function not viable: 1st argument ('const int (*)[10]') would lose const qualifier}} void g() { fun((const int(*)[10])0); } // expected-error{{no matching function for call to 'fun'}} } // DR1152: Take 'volatile' into account when handling reference bindings in // overload resolution. namespace PR12931 { void f(const int &, ...); void f(const volatile int &, int); void g() { f(0, 0); } } void test5() { struct { typedef void F1(int); typedef void F2(double); operator F1*(); // expected-note{{conversion candidate}} operator F2*(); // expected-note{{conversion candidate}} } callable; callable(); // expected-error{{no matching function for call}} } namespace PR20218 { void f(void (*const &)()); // expected-note 2{{candidate}} void f(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}} void g(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}} void g(void (*const &)()); // expected-note 2{{candidate}} void x(); typedef void (&fr)(); struct Y { operator fr(); } y; void h() { f(x); // expected-error {{ambiguous}} g(x); // expected-error {{ambiguous}} f(y); // expected-error {{ambiguous}} g(y); // expected-error {{ambiguous}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-weak.cpp
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s static int test0 __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} static void test1() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} namespace test2 __attribute__((weak)) { // expected-warning {{'weak' attribute only applies to variables, functions and classes}} } namespace { int test3 __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} void test4() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} } struct Test5 { static void test5() __attribute__((weak)); // no error }; namespace { struct Test6 { static void test6() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} }; } // GCC rejects the instantiation with the internal type, but some existing // code expects it. It is also not that different from giving hidden visibility // to parts of a template that have explicit default visibility, so we accept // this. template <class T> struct Test7 { void test7() __attribute__((weak)) {} static int var __attribute__((weak)); }; template <class T> int Test7<T>::var; namespace { class Internal {}; } template struct Test7<Internal>; template struct Test7<int>; class __attribute__((weak)) Test8 {}; // OK __attribute__((weak)) auto Test9 = Internal(); // expected-error {{weak declaration cannot have internal linkage}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx0x-type-convert-construct.cpp
// RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -verify %s void f() { char *u8str; u8str = u8"a UTF-8 string"; // expected-error {{assigning to 'char *' from incompatible type 'const char [15]'}} char16_t *ustr; ustr = u"a UTF-16 string"; // expected-error {{assigning to 'char16_t *' from incompatible type 'const char16_t [16]'}} char32_t *Ustr; Ustr = U"a UTF-32 string"; // expected-error {{assigning to 'char32_t *' from incompatible type 'const char32_t [16]'}} char *Rstr; Rstr = R"foo(a raw string)foo"; // expected-warning{{ISO C++11 does not allow conversion from string literal to 'char *'}} wchar_t *LRstr; LRstr = LR"foo(a wide raw string)foo"; // expected-warning{{ISO C++11 does not allow conversion from string literal to 'wchar_t *'}} char *u8Rstr; u8Rstr = u8R"foo(a UTF-8 raw string)foo"; // expected-error {{assigning to 'char *' from incompatible type 'const char [19]'}} char16_t *uRstr; uRstr = uR"foo(a UTF-16 raw string)foo"; // expected-error {{assigning to 'char16_t *' from incompatible type 'const char16_t [20]'}} char32_t *URstr; URstr = UR"foo(a UTF-32 raw string)foo"; // expected-error {{assigning to 'char32_t *' from incompatible type 'const char32_t [20]'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/member-name-lookup.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { int a; // expected-note 4{{member found by ambiguous name lookup}} static int b; static int c; // expected-note 2{{member found by ambiguous name lookup}} enum E { enumerator }; typedef int type; static void f(int); void f(float); // expected-note 2{{member found by ambiguous name lookup}} static void static_f(int); static void static_f(double); }; struct B : A { int d; // expected-note 2{{member found by ambiguous name lookup}} enum E2 { enumerator2 }; enum E3 { enumerator3 }; // expected-note 2{{member found by ambiguous name lookup}} }; struct C : A { int c; // expected-note 2{{member found by ambiguous name lookup}} int d; // expected-note 2{{member found by ambiguous name lookup}} enum E3 { enumerator3_2 }; // expected-note 2{{member found by ambiguous name lookup}} }; struct D : B, C { void test_lookup(); }; void test_lookup(D d) { d.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}} (void)d.b; // okay d.c; // expected-error{{member 'c' found in multiple base classes of different types}} d.d; // expected-error{{member 'd' found in multiple base classes of different types}} d.f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}} d.static_f(0); // okay D::E e = D::enumerator; // okay D::type t = 0; // okay D::E2 e2 = D::enumerator2; // okay D::E3 e3; // expected-error{{multiple base classes}} } void D::test_lookup() { a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}} (void)b; // okay c; // expected-error{{member 'c' found in multiple base classes of different types}} d; // expected-error{{member 'd' found in multiple base classes of different types}} f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}} static_f(0); // okay E e = enumerator; // okay type t = 0; // okay E2 e2 = enumerator2; // okay E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}} } struct B2 : virtual A { int d; // expected-note 2{{member found by ambiguous name lookup}} enum E2 { enumerator2 }; enum E3 { enumerator3 }; // expected-note 2 {{member found by ambiguous name lookup}} }; struct C2 : virtual A { int c; int d; // expected-note 2{{member found by ambiguous name lookup}} enum E3 { enumerator3_2 }; // expected-note 2{{member found by ambiguous name lookup}} }; struct D2 : B2, C2 { void test_virtual_lookup(); }; struct F : A { }; struct G : F, D2 { void test_virtual_lookup(); }; void test_virtual_lookup(D2 d2, G g) { (void)d2.a; (void)d2.b; (void)d2.c; // okay d2.d; // expected-error{{member 'd' found in multiple base classes of different types}} d2.f(0); // okay d2.static_f(0); // okay D2::E e = D2::enumerator; // okay D2::type t = 0; // okay D2::E2 e2 = D2::enumerator2; // okay D2::E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}} g.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}} g.static_f(0); // okay } void D2::test_virtual_lookup() { (void)a; (void)b; (void)c; // okay d; // expected-error{{member 'd' found in multiple base classes of different types}} f(0); // okay static_f(0); // okay E e = enumerator; // okay type t = 0; // okay E2 e2 = enumerator2; // okay E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}} } void G::test_virtual_lookup() { a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}} static_f(0); // okay } struct HasMemberType1 { struct type { }; // expected-note{{member found by ambiguous name lookup}} }; struct HasMemberType2 { struct type { }; // expected-note{{member found by ambiguous name lookup}} }; struct HasAnotherMemberType : HasMemberType1, HasMemberType2 { struct type { }; }; struct UsesAmbigMemberType : HasMemberType1, HasMemberType2 { type t; // expected-error{{member 'type' found in multiple base classes of different types}} }; struct X0 { struct Inner { static const int m; }; static const int n = 17; }; const int X0::Inner::m = n;
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-unused-local-typedef-x86asm.cpp
// REQUIRES: x86-registered-target // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -std=c++11 -Wunused-local-typedef -verify -fasm-blocks %s // expected-no-diagnostics void use_in_asm() { typedef struct { int a; int b; } A; __asm mov eax, [eax].A.b using Alias = struct { int a; int b; }; __asm mov eax, [eax].Alias.b }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/long-virtual-inheritance-chain.cpp
// RUN: %clang_cc1 -fsyntax-only %s class test0 { virtual void f(); }; class test1 : virtual test0 { virtual void f(); }; class test2 : virtual test1 { virtual void f(); }; class test3 : virtual test2 { virtual void f(); }; class test4 : virtual test3 { virtual void f(); }; class test5 : virtual test4 { virtual void f(); }; class test6 : virtual test5 { virtual void f(); }; class test7 : virtual test6 { virtual void f(); }; class test8 : virtual test7 { virtual void f(); }; class test9 : virtual test8 { virtual void f(); }; class test10 : virtual test9 { virtual void f(); }; class test11 : virtual test10 { virtual void f(); }; class test12 : virtual test11 { virtual void f(); }; class test13 : virtual test12 { virtual void f(); }; class test14 : virtual test13 { virtual void f(); }; class test15 : virtual test14 { virtual void f(); }; class test16 : virtual test15 { virtual void f(); }; class test17 : virtual test16 { virtual void f(); }; class test18 : virtual test17 { virtual void f(); }; class test19 : virtual test18 { virtual void f(); }; class test20 : virtual test19 { virtual void f(); }; class test21 : virtual test20 { virtual void f(); }; class test22 : virtual test21 { virtual void f(); }; class test23 : virtual test22 { virtual void f(); }; class test24 : virtual test23 { virtual void f(); }; class test25 : virtual test24 { virtual void f(); }; class test26 : virtual test25 { virtual void f(); }; class test27 : virtual test26 { virtual void f(); }; class test28 : virtual test27 { virtual void f(); }; class test29 : virtual test28 { virtual void f(); }; class test30 : virtual test29 { virtual void f(); }; class test31 : virtual test30 { virtual void f(); }; class test32 : virtual test31 { virtual void f(); }; class test33 : virtual test32 { virtual void f(); }; class test34 : virtual test33 { virtual void f(); }; class test35 : virtual test34 { virtual void f(); }; class test36 : virtual test35 { virtual void f(); }; class test37 : virtual test36 { virtual void f(); }; class test38 : virtual test37 { virtual void f(); }; class test39 : virtual test38 { virtual void f(); }; class test40 : virtual test39 { virtual void f(); }; class test41 : virtual test40 { virtual void f(); }; class test42 : virtual test41 { virtual void f(); }; class test43 : virtual test42 { virtual void f(); }; class test44 : virtual test43 { virtual void f(); }; class test45 : virtual test44 { virtual void f(); }; class test46 : virtual test45 { virtual void f(); }; class test47 : virtual test46 { virtual void f(); }; class test48 : virtual test47 { virtual void f(); }; class test49 : virtual test48 { virtual void f(); }; class test50 : virtual test49 { virtual void f(); };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-unused.cpp
// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -fsyntax-only %s namespace ns_unused { typedef int Int_unused __attribute__((unused)); } namespace ns_not_unused { typedef int Int_not_unused; } void f() { ns_not_unused::Int_not_unused i1; // expected-warning {{unused variable}} ns_unused::Int_unused i0; // expected-warning {{'Int_unused' was marked unused but was used}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/complex-init-list.cpp
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic // expected-no-diagnostics // This file tests the clang extension which allows initializing the components // of a complex number individually using an initialization list. Basically, // if you have an explicit init list for a complex number that contains two // initializers, this extension kicks in to turn it into component-wise // initialization. // // See also the testcase for the C version of this extension in // test/Sema/complex-init-list.c. // Basic testcase // (No pedantic warning is necessary because _Complex is not part of C++.) _Complex float valid1 = { 1.0f, 2.0f };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
// RUN: %clang_cc1 -std=c++1y %s -include %s -verify #ifndef INCLUDED #define INCLUDED #pragma clang system_header namespace std { using size_t = decltype(sizeof(0)); struct duration {}; duration operator""ns(unsigned long long); duration operator""us(unsigned long long); duration operator""ms(unsigned long long); duration operator""s(unsigned long long); duration operator""min(unsigned long long); duration operator""h(unsigned long long); struct string {}; string operator""s(const char*, size_t); template<typename T> struct complex {}; complex<float> operator""if(long double); complex<float> operator""if(unsigned long long); complex<double> operator""i(long double); complex<double> operator""i(unsigned long long); complex<long double> operator""il(long double); complex<long double> operator""il(unsigned long long); } #else using namespace std; duration a = 1ns, b = 1us, c = 1ms, d = 1s, e = 1min, f = 1h; string s = "foo"s; char error = 'x's; // expected-error {{invalid suffix}} expected-error {{expected ';'}} int _1z = 1z; // expected-error {{invalid suffix}} int _1b = 1b; // expected-error {{invalid digit}} complex<float> cf1 = 1if, cf2 = 2.if, cf3 = 0x3if; complex<double> cd1 = 1i, cd2 = 2.i, cd3 = 0b0110101i; complex<long double> cld1 = 1il, cld2 = 2.il, cld3 = 0047il; #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/expression-traits.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions %s // // Tests for "expression traits" intrinsics such as __is_lvalue_expr. // // For the time being, these tests are written against the 2003 C++ // standard (ISO/IEC 14882:2003 -- see draft at // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2001/n1316/). // // C++0x has its own, more-refined, idea of lvalues and rvalues. // If/when we need to support those, we'll need to track both // standard documents. #if !__has_feature(cxx_static_assert) # define CONCAT_(X_, Y_) CONCAT1_(X_, Y_) # define CONCAT1_(X_, Y_) X_ ## Y_ // This emulation can be used multiple times on one line (and thus in // a macro), except at class scope # define static_assert(b_, m_) \ typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1] #endif // Tests are broken down according to section of the C++03 standard // (ISO/IEC 14882:2003(E)) // Assertion macros encoding the following two paragraphs // // basic.lval/1 Every expression is either an lvalue or an rvalue. // // expr.prim/5 A parenthesized expression is a primary expression whose type // and value are identical to those of the enclosed expression. The // presence of parentheses does not affect whether the expression is // an lvalue. // // Note: these asserts cannot be made at class scope in C++03. Put // them in a member function instead. #define ASSERT_LVALUE(expr) \ static_assert(__is_lvalue_expr(expr), "should be an lvalue"); \ static_assert(__is_lvalue_expr((expr)), \ "the presence of parentheses should have" \ " no effect on lvalueness (expr.prim/5)"); \ static_assert(!__is_rvalue_expr(expr), "should be an lvalue"); \ static_assert(!__is_rvalue_expr((expr)), \ "the presence of parentheses should have" \ " no effect on lvalueness (expr.prim/5)") #define ASSERT_RVALUE(expr); \ static_assert(__is_rvalue_expr(expr), "should be an rvalue"); \ static_assert(__is_rvalue_expr((expr)), \ "the presence of parentheses should have" \ " no effect on lvalueness (expr.prim/5)"); \ static_assert(!__is_lvalue_expr(expr), "should be an rvalue"); \ static_assert(!__is_lvalue_expr((expr)), \ "the presence of parentheses should have" \ " no effect on lvalueness (expr.prim/5)") enum Enum { Enumerator }; int ReturnInt(); void ReturnVoid(); Enum ReturnEnum(); void basic_lval_5() { // basic.lval/5: The result of calling a function that does not return // a reference is an rvalue. ASSERT_RVALUE(ReturnInt()); ASSERT_RVALUE(ReturnVoid()); ASSERT_RVALUE(ReturnEnum()); } int& ReturnIntReference(); extern Enum& ReturnEnumReference(); void basic_lval_6() { // basic.lval/6: An expression which holds a temporary object resulting // from a cast to a nonreference type is an rvalue (this includes // the explicit creation of an object using functional notation struct IntClass { explicit IntClass(int = 0); IntClass(char const*); operator int() const; }; struct ConvertibleToIntClass { operator IntClass() const; }; ConvertibleToIntClass b; // Make sure even trivial conversions are not detected as lvalues int intLvalue = 0; ASSERT_RVALUE((int)intLvalue); ASSERT_RVALUE((short)intLvalue); ASSERT_RVALUE((long)intLvalue); // Same tests with function-call notation ASSERT_RVALUE(int(intLvalue)); ASSERT_RVALUE(short(intLvalue)); ASSERT_RVALUE(long(intLvalue)); char charLValue = 'x'; ASSERT_RVALUE((signed char)charLValue); ASSERT_RVALUE((unsigned char)charLValue); ASSERT_RVALUE(static_cast<int>(IntClass())); IntClass intClassLValue; ASSERT_RVALUE(static_cast<int>(intClassLValue)); ASSERT_RVALUE(static_cast<IntClass>(ConvertibleToIntClass())); ConvertibleToIntClass convertibleToIntClassLValue; ASSERT_RVALUE(static_cast<IntClass>(convertibleToIntClassLValue)); typedef signed char signed_char; typedef unsigned char unsigned_char; ASSERT_RVALUE(signed_char(charLValue)); ASSERT_RVALUE(unsigned_char(charLValue)); ASSERT_RVALUE(int(IntClass())); ASSERT_RVALUE(int(intClassLValue)); ASSERT_RVALUE(IntClass(ConvertibleToIntClass())); ASSERT_RVALUE(IntClass(convertibleToIntClassLValue)); } void conv_ptr_1() { // conv.ptr/1: A null pointer constant is an integral constant // expression (5.19) rvalue of integer type that evaluates to // zero. ASSERT_RVALUE(0); } void expr_6() { // expr/6: If an expression initially has the type "reference to T" // (8.3.2, 8.5.3), ... the expression is an lvalue. int x = 0; int& referenceToInt = x; ASSERT_LVALUE(referenceToInt); ASSERT_LVALUE(ReturnIntReference()); } void expr_prim_2() { // 5.1/2 A string literal is an lvalue; all other // literals are rvalues. ASSERT_LVALUE("foo"); ASSERT_RVALUE(1); ASSERT_RVALUE(1.2); ASSERT_RVALUE(10UL); } void expr_prim_3() { // 5.1/3: The keyword "this" names a pointer to the object for // which a nonstatic member function (9.3.2) is invoked. ...The // expression is an rvalue. struct ThisTest { void f() { ASSERT_RVALUE(this); } }; } extern int variable; void Function(); struct BaseClass { virtual ~BaseClass(); int BaseNonstaticMemberFunction(); static int BaseStaticMemberFunction(); int baseDataMember; }; struct Class : BaseClass { static void function(); static int variable; template <class T> struct NestedClassTemplate {}; template <class T> static int& NestedFuncTemplate() { return variable; } // expected-note{{possible target for call}} template <class T> int& NestedMemfunTemplate() { return variable; } // expected-note{{possible target for call}} int operator*() const; template <class T> int operator+(T) const; // expected-note{{possible target for call}} int NonstaticMemberFunction(); static int StaticMemberFunction(); int dataMember; int& referenceDataMember; static int& staticReferenceDataMember; static int staticNonreferenceDataMember; enum Enum { Enumerator }; operator long() const; Class(); Class(int,int); void expr_prim_4() { // 5.1/4: The operator :: followed by an identifier, a // qualified-id, or an operator-function-id is a primary- // expression. ...The result is an lvalue if the entity is // a function or variable. ASSERT_LVALUE(::Function); // identifier: function ASSERT_LVALUE(::variable); // identifier: variable // the only qualified-id form that can start without "::" (and thus // be legal after "::" ) is // // ::<sub>opt</sub> nested-name-specifier template<sub>opt</sub> unqualified-id ASSERT_LVALUE(::Class::function); // qualified-id: function ASSERT_LVALUE(::Class::variable); // qualified-id: variable // The standard doesn't give a clear answer about whether these // should really be lvalues or rvalues without some surrounding // context that forces them to be interpreted as naming a // particular function template specialization (that situation // doesn't come up in legal pure C++ programs). This language // extension simply rejects them as requiring additional context __is_lvalue_expr(::Class::NestedFuncTemplate); // qualified-id: template \ // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} __is_lvalue_expr(::Class::NestedMemfunTemplate); // qualified-id: template \ // expected-error{{reference to non-static member function must be called}} __is_lvalue_expr(::Class::operator+); // operator-function-id: template \ // expected-error{{reference to non-static member function must be called}} //ASSERT_RVALUE(::Class::operator*); // operator-function-id: member function } void expr_prim_7() { // expr.prim/7 An identifier is an id-expression provided it has been // suitably declared (clause 7). [Note: ... ] The type of the // expression is the type of the identifier. The result is the // entity denoted by the identifier. The result is an lvalue if // the entity is a function, variable, or data member... (cont'd) ASSERT_LVALUE(Function); // identifier: function ASSERT_LVALUE(StaticMemberFunction); // identifier: function ASSERT_LVALUE(variable); // identifier: variable ASSERT_LVALUE(dataMember); // identifier: data member //ASSERT_RVALUE(NonstaticMemberFunction); // identifier: member function // (cont'd)...A nested-name-specifier that names a class, // optionally followed by the keyword template (14.2), and then // followed by the name of a member of either that class (9.2) or // one of its base classes... is a qualified-id... The result is // the member. The type of the result is the type of the // member. The result is an lvalue if the member is a static // member function or a data member. ASSERT_LVALUE(Class::dataMember); ASSERT_LVALUE(Class::StaticMemberFunction); //ASSERT_RVALUE(Class::NonstaticMemberFunction); // identifier: member function ASSERT_LVALUE(Class::baseDataMember); ASSERT_LVALUE(Class::BaseStaticMemberFunction); //ASSERT_RVALUE(Class::BaseNonstaticMemberFunction); // identifier: member function } }; void expr_call_10() { // expr.call/10: A function call is an lvalue if and only if the // result type is a reference. This statement is partially // redundant with basic.lval/5 basic_lval_5(); ASSERT_LVALUE(ReturnIntReference()); ASSERT_LVALUE(ReturnEnumReference()); } namespace Namespace { int x; void function(); } void expr_prim_8() { // expr.prim/8 A nested-name-specifier that names a namespace // (7.3), followed by the name of a member of that namespace (or // the name of a member of a namespace made visible by a // using-directive ) is a qualified-id; 3.4.3.2 describes name // lookup for namespace members that appear in qualified-ids. The // result is the member. The type of the result is the type of the // member. The result is an lvalue if the member is a function or // a variable. ASSERT_LVALUE(Namespace::x); ASSERT_LVALUE(Namespace::function); } void expr_sub_1(int* pointer) { // expr.sub/1 A postfix expression followed by an expression in // square brackets is a postfix expression. One of the expressions // shall have the type "pointer to T" and the other shall have // enumeration or integral type. The result is an lvalue of type // "T." ASSERT_LVALUE(pointer[1]); // The expression E1[E2] is identical (by definition) to *((E1)+(E2)). ASSERT_LVALUE(*(pointer+1)); } void expr_type_conv_1() { // expr.type.conv/1 A simple-type-specifier (7.1.5) followed by a // parenthesized expression-list constructs a value of the specified // type given the expression list. ... If the expression list // specifies more than a single value, the type shall be a class with // a suitably declared constructor (8.5, 12.1), and the expression // T(x1, x2, ...) is equivalent in effect to the declaration T t(x1, // x2, ...); for some invented temporary variable t, with the result // being the value of t as an rvalue. ASSERT_RVALUE(Class(2,2)); } void expr_type_conv_2() { // expr.type.conv/2 The expression T(), where T is a // simple-type-specifier (7.1.5.2) for a non-array complete object // type or the (possibly cv-qualified) void type, creates an // rvalue of the specified type, ASSERT_RVALUE(int()); ASSERT_RVALUE(Class()); ASSERT_RVALUE(void()); } void expr_ref_4() { // Applies to expressions of the form E1.E2 // If E2 is declared to have type "reference to T", then E1.E2 is // an lvalue;.... Otherwise, one of the following rules applies. ASSERT_LVALUE(Class().staticReferenceDataMember); ASSERT_LVALUE(Class().referenceDataMember); // - If E2 is a static data member, and the type of E2 is T, then // E1.E2 is an lvalue; ... ASSERT_LVALUE(Class().staticNonreferenceDataMember); ASSERT_LVALUE(Class().staticReferenceDataMember); // - If E2 is a non-static data member, ... If E1 is an lvalue, // then E1.E2 is an lvalue... Class lvalue; ASSERT_LVALUE(lvalue.dataMember); ASSERT_RVALUE(Class().dataMember); // - If E1.E2 refers to a static member function, ... then E1.E2 // is an lvalue ASSERT_LVALUE(Class().StaticMemberFunction); // - Otherwise, if E1.E2 refers to a non-static member function, // then E1.E2 is not an lvalue. //ASSERT_RVALUE(Class().NonstaticMemberFunction); // - If E2 is a member enumerator, and the type of E2 is T, the // expression E1.E2 is not an lvalue. The type of E1.E2 is T. ASSERT_RVALUE(Class().Enumerator); ASSERT_RVALUE(lvalue.Enumerator); } void expr_post_incr_1(int x) { // expr.post.incr/1 The value obtained by applying a postfix ++ is // the value that the operand had before applying the // operator... The result is an rvalue. ASSERT_RVALUE(x++); } void expr_dynamic_cast_2() { // expr.dynamic.cast/2: If T is a pointer type, v shall be an // rvalue of a pointer to complete class type, and the result is // an rvalue of type T. Class instance; ASSERT_RVALUE(dynamic_cast<Class*>(&instance)); // If T is a reference type, v shall be an // lvalue of a complete class type, and the result is an lvalue of // the type referred to by T. ASSERT_LVALUE(dynamic_cast<Class&>(instance)); } void expr_dynamic_cast_5() { // expr.dynamic.cast/5: If T is "reference to cv1 B" and v has type // "cv2 D" such that B is a base class of D, the result is an // lvalue for the unique B sub-object of the D object referred // to by v. typedef BaseClass B; typedef Class D; D object; ASSERT_LVALUE(dynamic_cast<B&>(object)); } // expr.dynamic.cast/8: The run-time check logically executes as follows: // // - If, in the most derived object pointed (referred) to by v, v // points (refers) to a public base class subobject of a T object, and // if only one object of type T is derived from the sub-object pointed // (referred) to by v, the result is a pointer (an lvalue referring) // to that T object. // // - Otherwise, if v points (refers) to a public base class sub-object // of the most derived object, and the type of the most derived object // has a base class, of type T, that is unambiguous and public, the // result is a pointer (an lvalue referring) to the T sub-object of // the most derived object. // // The mention of "lvalue" in the text above appears to be a // defect that is being corrected by the response to UK65 (see // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2841.html). #if 0 void expr_typeid_1() { // expr.typeid/1: The result of a typeid expression is an lvalue... ASSERT_LVALUE(typeid(1)); } #endif void expr_static_cast_1(int x) { // expr.static.cast/1: The result of the expression // static_cast<T>(v) is the result of converting the expression v // to type T. If T is a reference type, the result is an lvalue; // otherwise, the result is an rvalue. ASSERT_LVALUE(static_cast<int&>(x)); ASSERT_RVALUE(static_cast<int>(x)); } void expr_reinterpret_cast_1() { // expr.reinterpret.cast/1: The result of the expression // reinterpret_cast<T>(v) is the result of converting the // expression v to type T. If T is a reference type, the result is // an lvalue; otherwise, the result is an rvalue ASSERT_RVALUE(reinterpret_cast<int*>(0)); char const v = 0; ASSERT_LVALUE(reinterpret_cast<char const&>(v)); } void expr_unary_op_1(int* pointer, struct incomplete* pointerToIncompleteType) { // expr.unary.op/1: The unary * operator performs indirection: the // expression to which it is applied shall be a pointer to an // object type, or a pointer to a function type and the result is // an lvalue referring to the object or function to which the // expression points. ASSERT_LVALUE(*pointer); ASSERT_LVALUE(*Function); // [Note: a pointer to an incomplete type // (other than cv void ) can be dereferenced. ] ASSERT_LVALUE(*pointerToIncompleteType); } void expr_pre_incr_1(int operand) { // expr.pre.incr/1: The operand of prefix ++ ... shall be a // modifiable lvalue.... The value is the new value of the // operand; it is an lvalue. ASSERT_LVALUE(++operand); } void expr_cast_1(int x) { // expr.cast/1: The result of the expression (T) cast-expression // is of type T. The result is an lvalue if T is a reference type, // otherwise the result is an rvalue. ASSERT_LVALUE((void(&)())expr_cast_1); ASSERT_LVALUE((int&)x); ASSERT_RVALUE((void(*)())expr_cast_1); ASSERT_RVALUE((int)x); } void expr_mptr_oper() { // expr.mptr.oper/6: The result of a .* expression is an lvalue // only if its first operand is an lvalue and its second operand // is a pointer to data member... (cont'd) typedef Class MakeRValue; ASSERT_RVALUE(MakeRValue().*(&Class::dataMember)); //ASSERT_RVALUE(MakeRValue().*(&Class::NonstaticMemberFunction)); Class lvalue; ASSERT_LVALUE(lvalue.*(&Class::dataMember)); //ASSERT_RVALUE(lvalue.*(&Class::NonstaticMemberFunction)); // (cont'd)...The result of an ->* expression is an lvalue only // if its second operand is a pointer to data member. If the // second operand is the null pointer to member value (4.11), the // behavior is undefined. ASSERT_LVALUE((&lvalue)->*(&Class::dataMember)); //ASSERT_RVALUE((&lvalue)->*(&Class::NonstaticMemberFunction)); } void expr_cond(bool cond) { // 5.16 Conditional operator [expr.cond] // // 2 If either the second or the third operand has type (possibly // cv-qualified) void, one of the following shall hold: // // - The second or the third operand (but not both) is a // (possibly parenthesized) throw-expression (15.1); the result // is of the type and value category of the other. Class classLvalue; ASSERT_RVALUE(cond ? throw 1 : (void)0); ASSERT_RVALUE(cond ? (void)0 : throw 1); ASSERT_RVALUE(cond ? throw 1 : 0); ASSERT_RVALUE(cond ? 0 : throw 1); ASSERT_LVALUE(cond ? throw 1 : classLvalue); ASSERT_LVALUE(cond ? classLvalue : throw 1); // - Both the second and the third operands have type void; the result // is of type void and is an rvalue. [Note: this includes the case // where both operands are throw-expressions. ] ASSERT_RVALUE(cond ? (void)1 : (void)0); ASSERT_RVALUE(cond ? throw 1 : throw 0); // expr.cond/4: If the second and third operands are lvalues and // have the same type, the result is of that type and is an // lvalue. ASSERT_LVALUE(cond ? classLvalue : classLvalue); int intLvalue = 0; ASSERT_LVALUE(cond ? intLvalue : intLvalue); // expr.cond/5:Otherwise, the result is an rvalue. typedef Class MakeRValue; ASSERT_RVALUE(cond ? MakeRValue() : classLvalue); ASSERT_RVALUE(cond ? classLvalue : MakeRValue()); ASSERT_RVALUE(cond ? MakeRValue() : MakeRValue()); ASSERT_RVALUE(cond ? classLvalue : intLvalue); ASSERT_RVALUE(cond ? intLvalue : int()); } void expr_ass_1(int x) { // expr.ass/1: There are several assignment operators, all of // which group right-to-left. All require a modifiable lvalue as // their left operand, and the type of an assignment expression is // that of its left operand. The result of the assignment // operation is the value stored in the left operand after the // assignment has taken place; the result is an lvalue. ASSERT_LVALUE(x = 1); ASSERT_LVALUE(x += 1); ASSERT_LVALUE(x -= 1); ASSERT_LVALUE(x *= 1); ASSERT_LVALUE(x /= 1); ASSERT_LVALUE(x %= 1); ASSERT_LVALUE(x ^= 1); ASSERT_LVALUE(x &= 1); ASSERT_LVALUE(x |= 1); } void expr_comma(int x) { // expr.comma: A pair of expressions separated by a comma is // evaluated left-to-right and the value of the left expression is // discarded... result is an lvalue if its right operand is. // Can't use the ASSERT_XXXX macros without adding parens around // the comma expression. static_assert(__is_lvalue_expr(x,x), "expected an lvalue"); static_assert(__is_rvalue_expr(x,1), "expected an rvalue"); static_assert(__is_lvalue_expr(1,x), "expected an lvalue"); static_assert(__is_rvalue_expr(1,1), "expected an rvalue"); } #if 0 template<typename T> void f(); // FIXME These currently fail void expr_fun_lvalue() { ASSERT_LVALUE(&f<int>); } void expr_fun_rvalue() { ASSERT_RVALUE(f<int>); } #endif template <int NonTypeNonReferenceParameter, int& NonTypeReferenceParameter> void check_temp_param_6() { ASSERT_RVALUE(NonTypeNonReferenceParameter); ASSERT_LVALUE(NonTypeReferenceParameter); } int AnInt = 0; void temp_param_6() { check_temp_param_6<3,AnInt>(); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/templated-friend-decl.cpp
// RUN: %clang_cc1 %s template <typename T> struct Foo { template <typename U> struct Bar {}; // The templated declaration for class Bar should not be instantiated when // Foo<int> is. This is to protect against PR5848; for now, this "parses" but // requires a rewrite of the templated friend code to be properly fixed. template <typename U> friend struct Bar; }; Foo<int> x;
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-unused-comparison.cpp
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -Wno-unused -Wunused-comparison %s struct A { bool operator==(const A&); bool operator!=(const A&); bool operator<(const A&); bool operator>(const A&); bool operator<=(const A&); bool operator>=(const A&); A operator|=(const A&); operator bool(); }; void test() { int x, *p; A a, b; x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} x != 7; // expected-warning {{inequality comparison result unused}} \ // expected-note {{use '|=' to turn this inequality comparison into an or-assignment}} x < 7; // expected-warning {{relational comparison result unused}} x > 7; // expected-warning {{relational comparison result unused}} x <= 7; // expected-warning {{relational comparison result unused}} x >= 7; // expected-warning {{relational comparison result unused}} 7 == x; // expected-warning {{equality comparison result unused}} p == p; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} \ // expected-warning {{self-comparison always evaluates to true}} a == a; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} a == b; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} a != b; // expected-warning {{inequality comparison result unused}} \ // expected-note {{use '|=' to turn this inequality comparison into an or-assignment}} a < b; // expected-warning {{relational comparison result unused}} a > b; // expected-warning {{relational comparison result unused}} a <= b; // expected-warning {{relational comparison result unused}} a >= b; // expected-warning {{relational comparison result unused}} A() == b; // expected-warning {{equality comparison result unused}} if (42) x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} else if (42) x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} else x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} do x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} while (false); while (false) x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} for (x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} x == 7; // No warning -- result is used x == 7) // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} switch (42) default: x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} switch (42) case 42: x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} switch (42) { case 1: case 2: default: case 3: case 4: x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} } (void)(x == 7); (void)(p == p); // expected-warning {{self-comparison always evaluates to true}} { bool b = x == 7; } { bool b = ({ x == 7; // expected-warning {{equality comparison result unused}} \ // expected-note {{use '=' to turn this equality comparison into an assignment}} x == 7; }); } // no warning on the second, its result is used! #define EQ(x,y) (x) == (y) EQ(x, 5); #undef EQ (void)sizeof(1 < 2, true); // No warning; unevaluated context. } namespace PR10291 { template<typename T> class X { public: X() : i(0) { } void foo() { throw i == 0u ? 5 : 6; } private: int i; }; X<int> x; } namespace PR19724 { class stream { } cout, cin; stream &operator<(stream &s, int); bool operator<(stream &s, stream &s2); void test() { cout < 5; // no warning, operator returns a reference cout < cin; // expected-warning {{relational comparison result unused}} } } namespace PR19791 { struct S { void operator!=(int); int operator==(int); }; void test() { S s; s != 1; s == 1; // expected-warning{{equality comparison result unused}} // expected-note@-1{{use '=' to turn this equality comparison into an assignment}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/constexpr-printing.cpp
// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu struct S; constexpr int extract(const S &s); struct S { constexpr S() : n(extract(*this)), m(0) {} // expected-note {{in call to 'extract(s1)'}} constexpr S(int k) : n(k), m(extract(*this)) {} int n, m; }; constexpr int extract(const S &s) { return s.n; } // expected-note {{read of object outside its lifetime is not allowed in a constant expression}} constexpr S s1; // ok void f() { constexpr S s1; // expected-error {{constant expression}} expected-note {{in call to 'S()'}} constexpr S s2(10); } typedef __attribute__((vector_size(16))) int vector_int; struct T { constexpr T() : arr() {} int arr[4]; }; struct U : T { constexpr U(const int *p) : T(), another(), p(p) {} constexpr U(const U &u) : T(), another(), p(u.p) {} T another; const int *p; }; constexpr U u1(&u1.arr[2]); constexpr int test_printing(int a, float b, _Complex int c, _Complex float d, int *e, int &f, vector_int g, U h) { return *e; // expected-note {{read of non-constexpr variable 'u2'}} } U u2(0); // expected-note {{here}} static_assert(test_printing(12, 39.762, 3 + 4i, 12.9 + 3.6i, &u2.arr[4], u2.another.arr[2], (vector_int){5, 1, 2, 3}, u1) == 0, ""); // \ expected-error {{constant expression}} \ expected-note {{in call to 'test_printing(12, 3.976200e+01, 3+4i, 1.290000e+01+3.600000e+00i, &u2.T::arr[4], u2.another.arr[2], {5, 1, 2, 3}, {{{}}, {{}}, &u1.T::arr[2]})'}} struct V { // FIXME: when we can generate these as constexpr constructors, remove the // explicit definitions. constexpr V() : arr{[255] = 42} {} constexpr V(const V &v) : arr{[255] = 42} {} int arr[256]; }; constexpr V v; constexpr int get(const int *p) { return *p; } // expected-note {{read of dereferenced one-past-the-end pointer}} constexpr int passLargeArray(V v) { return get(v.arr+256); } // expected-note {{in call to 'get(&v.arr[256])'}} static_assert(passLargeArray(v) == 0, ""); // expected-error {{constant expression}} expected-note {{in call to 'passLargeArray({{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...}})'}} union Union { constexpr Union(int n) : b(n) {} constexpr Union(const Union &u) : b(u.b) {} int a, b; }; constexpr Union myUnion = 76; constexpr int badness(Union u) { return u.a + u.b; } // expected-note {{read of member 'a' of union with active member 'b'}} static_assert(badness(myUnion), ""); // expected-error {{constant expression}} \ expected-note {{in call to 'badness({.b = 76})'}} struct MemPtrTest { int n; void f(); }; MemPtrTest mpt; // expected-note {{here}} constexpr int MemPtr(int (MemPtrTest::*a), void (MemPtrTest::*b)(), int &c) { return c; // expected-note {{read of non-constexpr variable 'mpt'}} } static_assert(MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.*&MemPtrTest::n), ""); // expected-error {{constant expression}} \ expected-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.n)'}} template<typename CharT> constexpr CharT get(const CharT *p) { return p[-1]; } // expected-note 5{{}} constexpr char c = get("test\0\\\"\t\a\b\234"); // \ expected-error {{}} expected-note {{"test\000\\\"\t\a\b\234"}} constexpr char c8 = get(u8"test\0\\\"\t\a\b\234"); // \ expected-error {{}} expected-note {{u8"test\000\\\"\t\a\b\234"}} constexpr char16_t c16 = get(u"test\0\\\"\t\a\b\234\u1234"); // \ expected-error {{}} expected-note {{u"test\000\\\"\t\a\b\234\u1234"}} constexpr char32_t c32 = get(U"test\0\\\"\t\a\b\234\u1234\U0010ffff"); // \ expected-error {{}} expected-note {{U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"}} constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234\xffffffff"); // \ expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF"}} constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}} typedef decltype(sizeof(int)) LabelDiffTy; constexpr LabelDiffTy mulBy3(LabelDiffTy x) { return x * 3; } // expected-note {{subexpression}} void LabelDiffTest() { static_assert(mulBy3((LabelDiffTy)&&a-(LabelDiffTy)&&b) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}} a:b:return; } constexpr bool test_bool_printing(bool b) { return 1 / !(2*b | !(2*b)); } // expected-note 2{{division by zero}} constexpr bool test_bool_0 = test_bool_printing(false); // expected-error {{constant expr}} expected-note {{in call to 'test_bool_printing(false)'}} constexpr bool test_bool_1 = test_bool_printing(true); // expected-error {{constant expr}} expected-note {{in call to 'test_bool_printing(true)'}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/c99-variable-length-array-cxx11.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wvla-extension %s struct StillPOD { StillPOD() = default; }; struct StillPOD2 { StillPOD np; }; struct NonPOD { NonPOD(int) {} }; struct POD { int x; int y; }; // We allow VLAs of POD types, only. void vla(int N) { int array1[N]; // expected-warning{{variable length arrays are a C99 feature}} POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}} StillPOD array3[N]; // expected-warning{{variable length arrays are a C99 feature}} StillPOD2 array4[N][3]; // expected-warning{{variable length arrays are a C99 feature}} NonPOD array5[N]; // expected-error{{variable length array of non-POD element type 'NonPOD'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/unknown-anytype.cpp
// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -verify %s namespace test0 { extern __unknown_anytype test0; extern __unknown_anytype test1(); extern __unknown_anytype test2(int); } namespace test1 { extern __unknown_anytype foo; int test() { // TODO: it would be great if the 'cannot initialize' errors // turned into something more interesting. It's just a matter of // making sure that these locations check for placeholder types // properly. int x = foo; // expected-error {{'foo' has unknown type}} int y = 0 + foo; // expected-error {{'foo' has unknown type}} return foo; // expected-error {{'foo' has unknown type}} } } namespace test2 { extern __unknown_anytype foo(); void test() { foo(); // expected-error {{'foo' has unknown return type}} } } namespace test3 { extern __unknown_anytype foo; void test() { foo(); // expected-error {{call to unsupported expression with unknown type}} ((void(void)) foo)(); // expected-error {{variable 'foo' with unknown type cannot be given a function type}} } } // rdar://problem/9899447 namespace test4 { extern __unknown_anytype test0(...); extern __unknown_anytype test1(...); void test() { void (*fn)(int) = (void(*)(int)) test0; int x = (int) test1; // expected-error {{function 'test1' with unknown type must be given a function type}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/template-implicit-vars.cpp
// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s template<typename T> void f(T t) { T a[] = {t}; for (auto x : a) {} } void g() { f(1); } // CHECK: VarDecl {{.*}} implicit used __range // CHECK: VarDecl {{.*}} implicit used __range // CHECK: VarDecl {{.*}} implicit used __begin // CHECK: VarDecl {{.*}} implicit used __end
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx-member-pointer-op.cpp
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s struct C { static int (C::* a); }; typedef void (C::*pmfc)(); void g(pmfc) { C *c; c->*pmfc(); // expected-error {{invalid use of pointer to member type after ->*}} C c1; c1.*pmfc(); // expected-error {{invalid use of pointer to member type after .*}} c->*(pmfc()); // expected-error {{invalid use of pointer to member type after ->*}} c1.*((pmfc())); // expected-error {{invalid use of pointer to member type after .*}} } int a(C* x) { return x->*C::a; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp
// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks %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 namespace explicit_argument_variadics { template<class ... Ts> void print(Ts ... ) { } struct X { }; struct Y { }; struct Z { }; int test() { { auto L = [](auto ... as) { }; L.operator()<bool>(true); } { auto L = [](auto a) { }; L.operator()<bool>(false); } { auto L = [](auto a, auto b) { }; L.operator()<bool>(false, 'a'); } { auto L = [](auto a, auto b) { }; L.operator()<bool, char>(false, 'a'); } { auto L = [](auto a, auto b, auto ... cs) { }; L.operator()<bool, char>(false, 'a'); L.operator()<bool, char, const char*>(false, 'a', "jim"); } { auto L = [](auto ... As) { }; L.operator()<bool, double>(false, 3.14, "abc"); } { auto L = [](auto A, auto B, auto ... As) { }; L.operator()<bool>(false, 3.14, "abc"); L.operator()<bool, char>(false, 3.14, "abc"); //expected-warning{{implicit conversion}} L.operator()<X, Y, bool, Z>(X{}, Y{}, 3.14, Z{}, X{}); //expected-warning{{implicit conversion}} } { auto L = [](auto ... As) { print("\nL::As = ", As ...); return [](decltype(As) ... as, auto ... Bs) { print("\nL::Inner::as = ", as ...); print("\nL::Inner::Bs = ", Bs ...); return 4; }; }; auto M = L.operator()<bool, double>(false, 3.14, "abc"); M(false, 6.26, "jim", true); M.operator()<bool>(true, 6.26, "jim", false, 3.14); } { auto L = [](auto A, auto ... As) { print("\nL::As = ", As ...); return [](decltype(As) ... as, decltype(A) a, auto ... Bs) { print("\nL::Inner::as = ", as ...); print("\nL::Inner::Bs = ", Bs ...); return 4; }; }; auto M = L.operator()<bool, double>(false, 3.14, "abc"); M(6.26, "jim", true); M.operator()<X>(6.26, "jim", false, X{}, Y{}, Z{}); } return 0; } int run = test(); } // end ns explicit_argument_extension #ifdef PR18499_FIXED namespace variadic_expansion { void f(int &, char &); template <typename ... T> void g(T &... t) { f([&a(t)]()->decltype(auto) { return a; }() ...); f([&a(f([&b(t)]()->decltype(auto) { return b; }()...), t)]()->decltype(auto) { return a; }()...); } void h(int i, char c) { g(i, c); } } #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-aligned.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics typedef struct S1 { char c; } S1 __attribute__((aligned(8))); static_assert(alignof(S1) == 8, "attribute ignored"); static_assert(alignof(struct S1) == 1, "attribute applied to original type"); typedef struct __attribute__((aligned(8))) S2 { char c; } AS; static_assert(alignof(S2) == 8, "attribute not propagated"); static_assert(alignof(struct S2) == 8, "attribute ignored"); typedef struct __attribute__((aligned(4))) S3 { char c; } S3 __attribute__((aligned(8))); static_assert(alignof(S3) == 8, "attribute ignored"); static_assert(alignof(struct S3) == 4, "attribute clobbered");
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-new-overaligned-2.cpp
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s // expected-no-diagnostics // This test verifies that we don't warn when the global operator new is // overridden. That's why we can't merge this with the other test file. void* operator new(unsigned long); void* operator new[](unsigned long); struct Test { template <typename T> struct SeparateCacheLines { T data; } __attribute__((aligned(256))); SeparateCacheLines<int> high_contention_data[10]; }; void helper() { Test t; new Test; new Test[10]; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/using-directive.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s namespace A { short i; // expected-note 2{{candidate found by name lookup is 'A::i'}} namespace B { long i; // expected-note{{candidate found by name lookup is 'A::B::i'}} void f() {} // expected-note{{candidate function}} int k; namespace E {} // \ expected-note{{candidate found by name lookup is 'A::B::E'}} } namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}} namespace C { using namespace B; namespace E {} // \ expected-note{{candidate found by name lookup is 'A::C::E'}} } void f() {} // expected-note{{candidate function}} class K1 { void foo(); }; void local_i() { char i; using namespace A; using namespace B; int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay } namespace B { int j; } void ambig_i() { using namespace A; using namespace A::B; (void) i; // expected-error{{reference to 'i' is ambiguous}} f(); // expected-error{{call to 'f' is ambiguous}} (void) j; // okay using namespace C; (void) k; // okay using namespace E; // expected-error{{reference to 'E' is ambiguous}} } struct K2 {}; // expected-note 2{{candidate found by name lookup is 'A::K2'}} } struct K2 {}; // expected-note 2{{candidate found by name lookup is 'K2'}} using namespace A; void K1::foo() {} // okay struct K2 *k2; // expected-error{{reference to 'K2' is ambiguous}} K2 *k3; // expected-error{{reference to 'K2' is ambiguous}} class X { // expected-note{{candidate found by name lookup is 'X'}} // FIXME: produce a suitable error message for this using namespace A; // expected-error{{not allowed}} }; namespace N { struct K2; struct K2 { }; } namespace Ni { int i(); // expected-note{{candidate found by name lookup is 'Ni::i'}} } namespace NiTest { using namespace A; using namespace Ni; int test() { return i; // expected-error{{reference to 'i' is ambiguous}} } } namespace OneTag { struct X; // expected-note{{candidate found by name lookup is 'OneTag::X'}} } namespace OneFunction { void X(); // expected-note{{candidate found by name lookup is 'OneFunction::X'}} } namespace TwoTag { struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}} } namespace FuncHidesTagAmbiguity { using namespace OneTag; using namespace OneFunction; using namespace TwoTag; void test() { (void)X(); // expected-error{{reference to 'X' is ambiguous}} } } // PR5479 namespace Aliased { void inAliased(); } namespace Alias = Aliased; using namespace Alias; void testAlias() { inAliased(); } namespace N { void f2(int); } extern "C++" { using namespace N; void f3() { f2(1); } } void f4() { f2(1); } // PR7517 using namespace std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}} using namespace ::std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}} namespace test1 { namespace ns { typedef int test1; } template <class T> using namespace ns; // expected-error {{cannot template a using directive}} // Test that we recovered okay. test1 x; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/constexpr-value-init.cpp
// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++11 -fsyntax-only -verify struct A { constexpr A() : a(b + 1), b(a + 1) {} // expected-note {{outside its lifetime}} int a; int b; }; struct B { A a; }; constexpr A a; // ok, zero initialization precedes static initialization void f() { constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}} } constexpr B b1; // expected-error {{without a user-provided default constructor}} constexpr B b2 = B(); // ok static_assert(b2.a.a == 1, ""); static_assert(b2.a.b == 2, ""); struct C { int c; }; struct D : C { int d; }; constexpr C c1; // expected-error {{without a user-provided default constructor}} constexpr C c2 = C(); // ok constexpr D d1; // expected-error {{without a user-provided default constructor}} constexpr D d2 = D(); // ok with DR1452 static_assert(D().c == 0, ""); static_assert(D().d == 0, ""); struct V : virtual C {}; template<typename T> struct Z : T { constexpr Z() : V() {} }; constexpr int n = Z<V>().c; // expected-error {{constant expression}} expected-note {{virtual base class}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/runtimediag-ppe.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value %s // Make sure diagnostics that we don't print based on runtime control // flow are delayed correctly in cases where we can't immediately tell whether // the context is unevaluated. namespace std { class type_info; } int& NP(int); void test1() { (void)typeid(NP(1 << 32)); } class Poly { virtual ~Poly(); }; Poly& P(int); void test2() { (void)typeid(P(1 << 32)); } // expected-warning {{shift count >= width of type}} void test3() { 1 ? (void)0 : (void)typeid(P(1 << 32)); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/increment-decrement.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s volatile int i; const int &inc = i++; const int &dec = i--; const int &incfail = ++i; // expected-error {{drops 'volatile' qualifier}} const int &decfail = --i; // expected-error {{drops 'volatile' qualifier}} // PR7794 void f0(int e) { ++(int&)e; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/builtins-arm.cpp
// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s // va_list on ARM AAPCS is struct { void* __ap }. int test1(const __builtin_va_list &ap) { return __builtin_va_arg(ap, int); // expected-error {{binding value of type 'const __builtin_va_list' to reference to type '__builtin_va_list' drops 'const' qualifier}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/value-dependent-exprs.cpp
// RUN: %clang_cc1 -verify %s // expected-no-diagnostics template <unsigned I> class C0 { static const int iv0 = 1 << I; enum { A = I, B = I + 1 }; struct s0 { int a : I; int b[I]; }; // FIXME: I'm unclear where the right place to handle this is. #if 0 void f0(int *p) { if (p == I) { } } #endif #if 0 // FIXME: Not sure whether we care about these. void f1(int *a) __attribute__((nonnull(1 + I))) __attribute__((constructor(1 + I))) __attribute__((destructor(1 + I))) __attribute__((sentinel(1 + I, 2 + I))), __attribute__((reqd_work_group_size(1 + I, 2 + I, 3 + I))), __attribute__((format_arg(1 + I))), __attribute__((aligned(1 + I))), __attribute__((regparm(1 + I))); typedef int int_a0 __attribute__((address_space(1 + B))); #endif #if 0 // FIXME: This doesn't work. PR4996. int f2() { return __builtin_choose_expr(I, 1, 2); } #endif };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/blocks.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fblocks void tovoid(void*); void tovoid_test(int (^f)(int, int)) { tovoid(f); } void reference_lvalue_test(int& (^f)()) { f() = 10; } // PR 7165 namespace test1 { void g(void (^)()); struct Foo { void foo(); void test() { (void) ^{ foo(); }; } }; } namespace test2 { int repeat(int value, int (^block)(int), unsigned n) { while (n--) value = block(value); return value; } class Power { int base; public: Power(int base) : base(base) {} int calculate(unsigned n) { return repeat(1, ^(int v) { return v * base; }, n); } }; int test() { return Power(2).calculate(10); } } // rdar: // 8382559 namespace radar8382559 { void func(bool& outHasProperty); int test3() { __attribute__((__blocks__(byref))) bool hasProperty = false; bool has = true; bool (^b)() = ^ { func(hasProperty); if (hasProperty) hasProperty = 0; if (has) hasProperty = 1; return hasProperty; }; func(hasProperty); func(has); b(); if (hasProperty) hasProperty = 1; if (has) has = 2; return hasProperty = 1; } } // Move __block variables to the heap when possible. class MoveOnly { public: MoveOnly(); MoveOnly(const MoveOnly&) = delete; MoveOnly(MoveOnly&&); }; void move_block() { __block MoveOnly mo; } // Don't crash after failing to build a block due to a capture of an // invalid declaration. namespace test5 { struct B { // expected-note 2 {{candidate constructor}} void *p; B(int); // expected-note {{candidate constructor}} }; void use_block(void (^)()); void use_block_2(void (^)(), const B &a); void test() { B x; // expected-error {{no matching constructor for initialization}} use_block(^{ int y; use_block_2(^{ (void) y; }, x); }); } } // rdar://16356628 // // Ensure that we can end function bodies while parsing an // expression that requires an explicitly-tracked cleanup object // (i.e. a block literal). // The nested function body in this test case is a template // instantiation. The template function has to be constexpr because // we'll otherwise delay its instantiation to the end of the // translation unit. namespace test6a { template <class T> constexpr int func() { return 0; } void run(void (^)(), int); void test() { int aCapturedVar = 0; run(^{ (void) aCapturedVar; }, func<int>()); } } // The nested function body in this test case is a method of a local // class. namespace test6b { void run(void (^)(), void (^)()); void test() { int aCapturedVar = 0; run(^{ (void) aCapturedVar; }, ^{ struct A { static void foo() {} }; A::foo(); }); } } // The nested function body in this test case is a lambda invocation // function. namespace test6c { void run(void (^)(), void (^)()); void test() { int aCapturedVar = 0; run(^{ (void) aCapturedVar; }, ^{ struct A { static void foo() {} }; A::foo(); }); } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx11-user-defined-literals.cpp
// RUN: %clang_cc1 -std=c++11 -verify %s -fms-extensions -triple x86_64-apple-darwin9.0.0 using size_t = decltype(sizeof(int)); enum class LitKind { Char, WideChar, Char16, Char32, CharStr, WideStr, Char16Str, Char32Str, Integer, Floating, Raw, Template }; constexpr LitKind operator"" _kind(char p) { return LitKind::Char; } constexpr LitKind operator"" _kind(wchar_t p) { return LitKind::WideChar; } constexpr LitKind operator"" _kind(char16_t p) { return LitKind::Char16; } constexpr LitKind operator"" _kind(char32_t p) { return LitKind::Char32; } constexpr LitKind operator"" _kind(const char *p, size_t n) { return LitKind::CharStr; } constexpr LitKind operator"" _kind(const wchar_t *p, size_t n) { return LitKind::WideStr; } constexpr LitKind operator"" _kind(const char16_t *p, size_t n) { return LitKind::Char16Str; } constexpr LitKind operator"" _kind(const char32_t *p, size_t n) { return LitKind::Char32Str; } constexpr LitKind operator"" _kind(unsigned long long n) { return LitKind::Integer; } constexpr LitKind operator"" _kind(long double n) { return LitKind::Floating; } constexpr LitKind operator"" _kind2(const char *p) { return LitKind::Raw; } template<char ...Cs> constexpr LitKind operator"" _kind3() { return LitKind::Template; } static_assert('x'_kind == LitKind::Char, ""); static_assert(L'x'_kind == LitKind::WideChar, ""); static_assert(u'x'_kind == LitKind::Char16, ""); static_assert(U'x'_kind == LitKind::Char32, ""); static_assert("foo"_kind == LitKind::CharStr, ""); static_assert(u8"foo"_kind == LitKind::CharStr, ""); static_assert(L"foo"_kind == LitKind::WideStr, ""); static_assert(u"foo"_kind == LitKind::Char16Str, ""); static_assert(U"foo"_kind == LitKind::Char32Str, ""); static_assert(194_kind == LitKind::Integer, ""); static_assert(0377_kind == LitKind::Integer, ""); static_assert(0x5ffc_kind == LitKind::Integer, ""); static_assert(.5954_kind == LitKind::Floating, ""); static_assert(1._kind == LitKind::Floating, ""); static_assert(1.e-2_kind == LitKind::Floating, ""); static_assert(4e6_kind == LitKind::Floating, ""); static_assert(4e6_kind2 == LitKind::Raw, ""); static_assert(4e6_kind3 == LitKind::Template, ""); constexpr const char *fractional_digits_impl(const char *p) { return *p == '.' ? p + 1 : *p ? fractional_digits_impl(p + 1) : 0; } constexpr const char *operator"" _fractional_digits(const char *p) { return fractional_digits_impl(p) ?: p; } constexpr bool streq(const char *p, const char *q) { return *p == *q && (!*p || streq(p+1, q+1)); } static_assert(streq(143.97_fractional_digits, "97"), ""); static_assert(streq(0x786_fractional_digits, "0x786"), ""); static_assert(streq(.4_fractional_digits, "4"), ""); static_assert(streq(4._fractional_digits, ""), ""); static_assert(streq(1e+97_fractional_digits, "1e+97"), ""); static_assert(streq(0377_fractional_digits, "0377"), ""); static_assert(streq(0377.5_fractional_digits, "5"), ""); int operator"" _ambiguous(char); // expected-note {{candidate}} namespace N { void *operator"" _ambiguous(char); // expected-note {{candidate}} } using namespace N; int k = 'x'_ambiguous; // expected-error {{ambiguous}} int operator"" _deleted(unsigned long long) = delete; // expected-note {{here}} int m = 42_deleted; // expected-error {{attempt to use a deleted}} namespace Using { namespace M { int operator"" _using(char); } int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator "" _using'}} using M::operator "" _using; int k2 = 'x'_using; } namespace AmbiguousRawTemplate { int operator"" _ambig1(const char *); // expected-note {{candidate}} template<char...> int operator"" _ambig1(); // expected-note {{candidate}} int k1 = 123_ambig1; // expected-error {{call to 'operator "" _ambig1' is ambiguous}} namespace Inner { template<char...> int operator"" _ambig2(); // expected-note 3{{candidate}} } int operator"" _ambig2(const char *); // expected-note 3{{candidate}} using Inner::operator"" _ambig2; int k2 = 123_ambig2; // expected-error {{call to 'operator "" _ambig2' is ambiguous}} namespace N { using Inner::operator"" _ambig2; int k3 = 123_ambig2; // ok using AmbiguousRawTemplate::operator"" _ambig2; int k4 = 123_ambig2; // expected-error {{ambiguous}} namespace M { template<char...> int operator"" _ambig2(); int k5 = 123_ambig2; // ok } int operator"" _ambig2(unsigned long long); int k6 = 123_ambig2; // ok int k7 = 123._ambig2; // expected-error {{ambiguous}} } } constexpr unsigned mash(unsigned a) { return 0x93ae27b5 * ((a >> 13) | a << 19); } template<typename=void> constexpr unsigned hash(unsigned a) { return a; } template<char C, char...Cs> constexpr unsigned hash(unsigned a) { return hash<Cs...>(mash(a ^ mash(C))); } template<typename T, T v> struct constant { constexpr static T value = v; }; template<char...Cs> constexpr unsigned operator"" _hash() { return constant<unsigned, hash<Cs...>(0)>::value; } static_assert(0x1234_hash == 0x103eff5e, ""); static_assert(hash<'0', 'x', '1', '2', '3', '4'>(0) == 0x103eff5e, ""); // Functions and literal suffixes go in separate namespaces. namespace Namespace { template<char...> int operator"" _x(); int k = _x(); // expected-error {{undeclared identifier '_x'}} int _y(unsigned long long); int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator "" _y'}} } namespace PR14950 { template<...> // expected-error {{expected template parameter}} int operator"" _b(); // expected-error {{no function template matches function template specialization}} int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator "" _b'}} } namespace bad_names { template<char...> int operator""_x(); template<typename T> void f() { class T:: // expected-error {{anonymous class}} expected-warning {{does not declare anything}} operator // expected-error {{expected identifier}} ""_q<'a'>; T::template operator""_q<'a'>(); // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} T::template operator""_q<'a'>::X; // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} T::operator""_q<'a'>(); // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} typename T::template operator""_q<'a'> a; // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} typename T::operator""_q(""); // expected-error +{{}} expected-note {{to match}} T::operator""_q(""); // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} bad_names::operator""_x<'a', 'b', 'c'>(); }; struct S {}; void g() { S::operator""_q(); // expected-error {{non-namespace scope 'S::' cannot have a literal operator member}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/return.cpp
// RUN: %clang_cc1 %s -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify int test1() { throw; } // PR5071 template<typename T> T f() { } template<typename T> void g(T t) { return t * 2; // okay } template<typename T> T h() { return 17; } // Don't warn on cv-qualified class return types, only scalar return types. namespace ignored_quals { struct S {}; const S class_c(); const volatile S class_cv(); const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}} int const scalar_c2(); // expected-warning{{'const' type qualifier on return type has no effect}} const char* const // expected-warning{{'const' type qualifier on return type has no effect}} f(); char const* const // expected-warning{{'const' type qualifier on return type has no effect}} g(); char* const h(); // expected-warning{{'const' type qualifier on return type has no effect}} char* volatile i(); // expected-warning{{'volatile' type qualifier on return type has no effect}} char* volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}} const j(); const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} // FIXME: Maintain enough information that we can point the diagnostic at the 'volatile' keyword. const int S::* volatile mixed_ret(); // expected-warning {{'volatile' type qualifier on return type has no effect}} const int volatile // expected-warning {{'const volatile' type qualifiers on return type have no effect}} (((parens()))); _Atomic(int) atomic(); _Atomic // expected-warning {{'_Atomic' type qualifier on return type has no effect}} int atomic(); auto trailing_return_type() -> // expected-warning {{'const' type qualifier on return type has no effect}} const int; const int ret_array()[4]; // expected-error {{cannot return array}} } namespace PR9328 { typedef char *PCHAR; class Test { const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}} }; } class foo { operator const int (); operator int * const (); }; namespace PR10057 { struct S { ~S(); }; template <class VarType> void Test(const VarType& value) { return S() = value; } } namespace return_has_expr { struct S { S() { return 42; // expected-error {{constructor 'S' should not return a value}} } ~S() { return 42; // expected-error {{destructor '~S' should not return a value}} } }; } // rdar://15366494 // pr17759 namespace ctor_returns_void { void f() {} struct S { S() { return f(); }; // expected-error {{constructor 'S' must not return void expression}} ~S() { return f(); } // expected-error {{destructor '~S' must not return void expression}} }; } void cxx_unresolved_expr() { // The use of an undeclared variable tricks clang into building a // CXXUnresolvedConstructExpr, and the missing ')' gives it an invalid source // location for its rparen. Check that emitting a diag on the range of the // expr doesn't assert. return int(undeclared, 4; // expected-error {{expected ')'}} expected-note{{to match this '('}} expected-error {{void function 'cxx_unresolved_expr' should not return a value}} expected-error {{use of undeclared identifier 'undeclared'}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11 // RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s #define CONST const #ifdef PRECXX11 #define static_assert(expr, msg) typedef int static_assert[(expr) ? 1 : -1]; #endif class A { template<typename T> CONST T wrong; // expected-error {{member 'wrong' declared as a template}} template<typename T> CONST T wrong_init = 5; // expected-error {{member 'wrong_init' declared as a template}} template<typename T, typename T0> static CONST T right = T(100); template<typename T> static CONST T right<T,int> = 5; template<typename T> CONST int right<int,T>; // expected-error {{member 'right' declared as a template}} template<typename T> CONST float right<float,T> = 5; // expected-error {{member 'right' declared as a template}} template<> static CONST int right<int,int> = 7; // expected-error {{explicit specialization of 'right' in class scope}} template<> static CONST float right<float,int>; // expected-error {{explicit specialization of 'right' in class scope}} template static CONST int right<int,int>; // expected-error {{template specialization requires 'template<>'}} \ // expected-error {{explicit specialization of 'right' in class scope}} }; namespace out_of_line { class B0 { template<typename T, typename T0> static CONST T right = T(100); template<typename T> static CONST T right<T,int> = T(5); }; template<> CONST int B0::right<int,int> = 7; template CONST int B0::right<int,int>; template<> CONST int B0::right<int,float>; template CONST int B0::right<int,float>; class B1 { template<typename T, typename T0> static CONST T right; template<typename T> static CONST T right<T,int>; }; template<typename T, typename T0> CONST T B1::right = T(100); template<typename T> CONST T B1::right<T,int> = T(5); class B2 { template<typename T, typename T0> static CONST T right = T(100); // expected-note {{previous initialization is here}} template<typename T> static CONST T right<T,int> = T(5); // expected-note {{previous initialization is here}} }; template<typename T, typename T0> CONST T B2::right = T(100); // expected-error {{static data member 'right' already has an initializer}} template<typename T> CONST T B2::right<T,int> = T(5); // expected-error {{static data member 'right' already has an initializer}} class B3 { template<typename T, typename T0> static CONST T right = T(100); template<typename T> static CONST T right<T,int> = T(5); }; template<typename T, typename T0> CONST T B3::right; template<typename T> CONST T B3::right<T,int>; class B4 { template<typename T, typename T0> static CONST T a; template<typename T> static CONST T a<T,int> = T(100); template<typename T, typename T0> static CONST T b = T(100); template<typename T> static CONST T b<T,int>; }; template<typename T, typename T0> CONST T B4::a; // expected-error {{default initialization of an object of const type 'const int'}} template<typename T> CONST T B4::a<T,int>; template CONST int B4::a<int,char>; // expected-note {{in instantiation of}} template CONST int B4::a<int,int>; template<typename T, typename T0> CONST T B4::b; template<typename T> CONST T B4::b<T,int>; // expected-error {{default initialization of an object of const type 'const int'}} template CONST int B4::b<int,char>; template CONST int B4::b<int,int>; // expected-note {{in instantiation of}} } namespace non_const_init { class A { template<typename T> static T wrong_inst_undefined = T(10); // expected-note {{refers here}} template<typename T> static T wrong_inst_defined = T(10); // expected-error {{non-const static data member must be initialized out of line}} template<typename T> static T wrong_inst_out_of_line; }; template const int A::wrong_inst_undefined<const int>; // expected-error {{undefined}} template<typename T> T A::wrong_inst_defined; template const int A::wrong_inst_defined<const int>; template int A::wrong_inst_defined<int>; // expected-note {{in instantiation of static data member 'non_const_init::A::wrong_inst_defined<int>' requested here}} template<typename T> T A::wrong_inst_out_of_line = T(10); template int A::wrong_inst_out_of_line<int>; class B { template<typename T> static T wrong_inst; // expected-note {{refers here}} template<typename T> static T wrong_inst<T*> = T(100); // expected-error {{non-const static data member must be initialized out of line}} expected-note {{refers here}} template<typename T> static T wrong_inst_fixed; template<typename T> static T wrong_inst_fixed<T*>; }; template int B::wrong_inst<int>; // expected-error {{undefined}} // FIXME: It'd be better to produce the 'explicit instantiation of undefined // template' diagnostic here, not the 'must be initialized out of line' // diagnostic. template int B::wrong_inst<int*>; // expected-note {{in instantiation of static data member 'non_const_init::B::wrong_inst<int *>' requested here}} template const int B::wrong_inst<const int*>; // expected-error {{undefined}} template<typename T> T B::wrong_inst_fixed = T(100); template int B::wrong_inst_fixed<int>; class C { template<typename T> static CONST T right_inst = T(10); // expected-note {{here}} template<typename T> static CONST T right_inst<T*> = T(100); // expected-note {{here}} }; template CONST int C::right_inst<int>; // expected-error {{undefined variable template}} template CONST int C::right_inst<int*>; // expected-error {{undefined variable template}} namespace pointers { struct C0 { template<typename U> static U Data; template<typename U> static CONST U Data<U*> = U(); // expected-note {{here}} template<typename U> static U Data2; template<typename U> static CONST U Data2<U*> = U(); }; const int c0_test = C0::Data<int*>; static_assert(c0_test == 0, ""); template const int C0::Data<int*>; // expected-error {{undefined}} template<typename U> const U C0::Data2<U*>; template const int C0::Data2<int*>; struct C1a { template<typename U> static U Data; template<typename U> static U* Data<U*>; // Okay, with out-of-line definition }; template<typename T> T* C1a::Data<T*> = new T(); template int* C1a::Data<int*>; struct C1b { template<typename U> static U Data; template<typename U> static CONST U* Data<U*>; // Okay, with out-of-line definition }; template<typename T> CONST T* C1b::Data<T*> = (T*)(0); template CONST int* C1b::Data<int*>; struct C2a { template<typename U> static int Data; template<typename U> static U* Data<U*> = new U(); // expected-error {{non-const static data member must be initialized out of line}} }; template int* C2a::Data<int*>; // expected-note {{in instantiation of static data member 'non_const_init::pointers::C2a::Data<int *>' requested here}} struct C2b { template<typename U> static int Data; template<typename U> static U *const Data<U*> = (U*)(0); // expected-error {{static data member of type 'int *const'}} }; template<typename U> U *const C2b::Data<U*>; template int *const C2b::Data<int*>; // expected-note {{in instantiation of static data member 'non_const_init::pointers::C2b::Data<int *>' requested here}} } } #ifndef PRECXX11 namespace constexpred { class A { template<typename T> constexpr T wrong; // expected-error {{member 'wrong' declared as a template}} \ // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}} template<typename T> constexpr T wrong_init = 5; // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}} template<typename T, typename T0> static constexpr T right = T(100); template<typename T> static constexpr T right<T,int> = 5; template<typename T> constexpr int right<int,T>; // expected-error {{member 'right' declared as a template}} \ // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}} template<typename T> constexpr float right<float,T> = 5; // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}} template<> static constexpr int right<int,int> = 7; // expected-error {{explicit specialization of 'right' in class scope}} template<> static constexpr float right<float,int>; // expected-error {{explicit specialization of 'right' in class scope}} template static constexpr int right<int,int>; // expected-error {{template specialization requires 'template<>'}} \ // expected-error {{explicit specialization of 'right' in class scope}} }; } #endif namespace in_class_template { template<typename T> class D0 { template<typename U> static U Data; // expected-note {{here}} template<typename U> static CONST U Data<U*> = U(); }; template CONST int D0<float>::Data<int*>; template int D0<float>::Data<int>; // expected-error {{undefined}} template<typename T> template<typename U> const U D0<T>::Data<U*>; template<typename T> class D1 { template<typename U> static U Data; template<typename U> static U* Data<U*>; }; template<typename T> template<typename U> U* D1<T>::Data<U*> = (U*)(0); template int* D1<float>::Data<int*>; // expected-note {{previous}} template int* D1<float>::Data<int*>; // expected-error {{duplicate explicit instantiation}} template<typename T> class D2 { template<typename U> static U Data; template<typename U> static U* Data<U*>; }; template<> template<typename U> U* D2<float>::Data<U*> = (U*)(0) + 1; template int* D2<float>::Data<int*>; // expected-note {{previous}} template int* D2<float>::Data<int*>; // expected-error {{duplicate explicit instantiation}} template<typename T> struct D3 { template<typename U> static CONST U Data = U(100); // expected-note {{here}} }; static_assert(D3<float>::Data<int> == 100, ""); template const char D3<float>::Data<char>; // expected-error {{undefined}} namespace bug_files { template<typename T> class D0a { template<typename U> static U Data; template<typename U> static CONST U Data<U*> = U(10); // expected-note {{previous declaration is here}} }; template<> template<typename U> U D0a<float>::Data<U*> = U(100); // expected-error {{redefinition of 'Data'}} // FIXME: We should accept this, and the corresponding case for class // templates. // // [temp.class.spec.mfunc]/2: If the primary member template is explicitly // specialized for a given specialization of the enclosing class template, // the partial specializations of the member template are ignored template<typename T> class D1 { template<typename U> static U Data; template<typename U> static CONST U Data<U*> = U(10); // expected-note {{previous declaration is here}} }; template<> template<typename U> U D1<float>::Data = U(10); template<> template<typename U> U D1<float>::Data<U*> = U(100); // expected-error{{redefinition of 'Data'}} } namespace definition_after_outer_instantiation { template<typename A> struct S { template<typename B> static const int V1; template<typename B> static const int V2; }; template struct S<int>; template<typename A> template<typename B> const int S<A>::V1 = 123; template<typename A> template<typename B> const int S<A>::V2<B*> = 456; static_assert(S<int>::V1<int> == 123, ""); // FIXME: The first and third case below possibly should be accepted. We're // not picking up partial specializations added after the primary template // is instantiated. This is kind of implied by [temp.class.spec.mfunc]/2, // and matches our behavior for member class templates, but it's not clear // that this is intentional. See PR17294 and core-24030. static_assert(S<int>::V2<int*> == 456, ""); // FIXME expected-error {{}} static_assert(S<int>::V2<int&> == 789, ""); // expected-error {{}} template<typename A> template<typename B> const int S<A>::V2<B&> = 789; static_assert(S<int>::V2<int&> == 789, ""); // FIXME expected-error {{}} // All is OK if the partial specialization is declared before the implicit // instantiation of the class template specialization. static_assert(S<char>::V1<int> == 123, ""); static_assert(S<char>::V2<int*> == 456, ""); static_assert(S<char>::V2<int&> == 789, ""); } namespace incomplete_array { template<typename T> extern T var[]; template<typename T> T var[] = { 1, 2, 3 }; template<> char var<char>[] = "hello"; template<typename T> char var<T*>[] = "pointer"; static_assert(sizeof(var<int>) == 12, ""); static_assert(sizeof(var<char>) == 6, ""); static_assert(sizeof(var<void*>) == 8, ""); template<typename...> struct tuple; template<typename T> struct A { template<typename U> static T x[]; template<typename U> static T y[]; template<typename...U> static T y<tuple<U...> >[]; }; int *use_before_definition = A<int>::x<char>; template<typename T> template<typename U> T A<T>::x[sizeof(U)]; static_assert(sizeof(A<int>::x<char>) == 4, ""); template<typename T> template<typename...U> T A<T>::y<tuple<U...> >[] = { U()... }; static_assert(sizeof(A<int>::y<tuple<char, char, char> >) == 12, ""); } namespace bad_reference { struct S { template<typename T> static int A; // expected-note 4{{here}} }; template<typename T> void f() { typename T::template A<int> a; // expected-error {{template name refers to non-type template 'S::A'}} } template<typename T> void g() { T::template A<int>::B = 0; // expected-error {{template name refers to non-type template 'S::A'}} } template<typename T> void h() { class T::template A<int> c; // expected-error {{template name refers to non-type template 'S::A'}} } template<typename T> struct X : T::template A<int> {}; // expected-error {{template name refers to non-type template 'S::A'}} template void f<S>(); // expected-note {{in instantiation of}} template void g<S>(); // expected-note {{in instantiation of}} template void h<S>(); // expected-note {{in instantiation of}} template struct X<S>; // expected-note {{in instantiation of}} } } namespace in_nested_classes { // TODO: } namespace bitfield { struct S { template <int I> static int f : I; // expected-error {{static member 'f' cannot be a bit-field}} }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/microsoft-varargs-diagnostics.cpp
// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify extern "C" { typedef char * va_list; } void test_no_arguments(int i, ...) { __va_start(); // expected-error{{too few arguments to function call, expected at least 3, have 0}} } void test_one_argument(int i, ...) { va_list ap; __va_start(&ap); // expected-error{{too few arguments to function call, expected at least 3, have 1}} } void test_two_arguments(int i, ...) { va_list ap; __va_start(&ap, &i); // expected-error{{too few arguments to function call, expected at least 3, have 2}} } void test_non_last_argument(int i, int j, ...) { va_list ap; __va_start(&ap, &i, 4); // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}} // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}} } void test_stack_allocated(int i, ...) { va_list ap; int j; __va_start(&ap, &j, 4); // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}} // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}} } void test_non_pointer_addressof(int i, ...) { va_list ap; __va_start(&ap, 1, 4); // expected-error@-1{{passing 'int' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int' vs 'const char *')}} // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/exceptions.cpp
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s struct A; // expected-note 4 {{forward declaration of 'A'}} struct Abstract { virtual void f() = 0; }; // expected-note {{unimplemented pure virtual method 'f'}} void trys() { try { } catch(int i) { // expected-note {{previous definition}} int j = i; int i; // expected-error {{redefinition of 'i'}} } catch(float i) { } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}} } catch(A a) { // expected-error {{cannot catch incomplete type 'A'}} } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'A'}} } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'A'}} } catch(Abstract) { // expected-error {{variable type 'Abstract' is an abstract class}} } catch(...) { int j = i; // expected-error {{use of undeclared identifier 'i'}} } try { } catch(...) { // expected-error {{catch-all handler must come last}} } catch(int) { } } void throws() { throw; throw 0; throw throw; // expected-error {{cannot throw object of incomplete type 'void'}} throw (A*)0; // expected-error {{cannot throw pointer to object of incomplete type 'A'}} } void jumps() { l1: goto l5; goto l4; // expected-error {{cannot jump}} goto l3; // expected-error {{cannot jump}} goto l2; // expected-error {{cannot jump}} goto l1; try { // expected-note 4 {{jump bypasses initialization of try block}} l2: goto l5; goto l4; // expected-error {{cannot jump}} goto l3; // expected-error {{cannot jump}} goto l2; goto l1; } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}} l3: goto l5; goto l4; // expected-error {{cannot jump}} goto l3; goto l2; // expected-error {{cannot jump}} goto l1; } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}} l4: goto l5; goto l4; goto l3; // expected-error {{cannot jump}} goto l2; // expected-error {{cannot jump}} goto l1; } l5: goto l5; goto l4; // expected-error {{cannot jump}} goto l3; // expected-error {{cannot jump}} goto l2; // expected-error {{cannot jump}} goto l1; } struct BadReturn { BadReturn() try { } catch(...) { // Try to hide try { } catch(...) { { if (0) return; // expected-error {{return in the catch of a function try block of a constructor is illegal}} } } } BadReturn(int); }; BadReturn::BadReturn(int) try { } catch(...) { // Try to hide try { } catch(int) { return; // expected-error {{return in the catch of a function try block of a constructor is illegal}} } catch(...) { { if (0) return; // expected-error {{return in the catch of a function try block of a constructor is illegal}} } } } // Cannot throw an abstract type. class foo { public: foo() {} void bar () { throw *this; // expected-error{{cannot throw an object of abstract type 'foo'}} } virtual void test () = 0; // expected-note{{unimplemented pure virtual method 'test'}} }; namespace PR6831 { namespace NA { struct S; } namespace NB { struct S; } void f() { using namespace NA; using namespace NB; try { } catch (int S) { } } } namespace Decay { struct A { void f() throw (A[10]); }; template<typename T> struct B { void f() throw (B[10]); }; template struct B<int>; void f() throw (int[10], int(*)()); void f() throw (int*, int()); template<typename T> struct C { void f() throw (T); // expected-error {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}} }; struct D { C<D[10]> c; }; struct E; // expected-note {{forward declaration}} C<E[10]> e; // expected-note {{in instantiation of}} } void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}} namespace HandlerInversion { struct B {}; struct D : B {}; struct D2 : D {}; void f1() { try { } catch (B &b) { // expected-note {{for type 'HandlerInversion::B &'}} } catch (D &d) { // expected-warning {{exception of type 'HandlerInversion::D &' will be caught by earlier handler}} } } void f2() { try { } catch (B *b) { // expected-note {{for type 'HandlerInversion::B *'}} } catch (D *d) { // expected-warning {{exception of type 'HandlerInversion::D *' will be caught by earlier handler}} } } void f3() { try { } catch (D &d) { // Ok } catch (B &b) { } } void f4() { try { } catch (B &b) { // Ok } } void f5() { try { } catch (int) { } catch (float) { } } void f6() { try { } catch (B &b) { // expected-note {{for type 'HandlerInversion::B &'}} } catch (D2 &d) { // expected-warning {{exception of type 'HandlerInversion::D2 &' will be caught by earlier handler}} } } void f7() { try { } catch (B *b) { // Ok } catch (D &d) { // Ok } try { } catch (B b) { // Ok } catch (D *d) { // Ok } } void f8() { try { } catch (const B &b) { // expected-note {{for type 'const HandlerInversion::B &'}} } catch (D2 &d) { // expected-warning {{exception of type 'HandlerInversion::D2 &' will be caught by earlier handler}} } try { } catch (B &b) { // expected-note {{for type 'HandlerInversion::B &'}} } catch (const D2 &d) { // expected-warning {{exception of type 'const HandlerInversion::D2 &' will be caught by earlier handler}} } try { } catch (B b) { // expected-note {{for type 'HandlerInversion::B'}} } catch (D &d) { // expected-warning {{exception of type 'HandlerInversion::D &' will be caught by earlier handler}} } } } namespace ConstVolatileThrow { struct S { S() {} // expected-note{{candidate constructor not viable}} S(const S &s); // expected-note{{candidate constructor not viable}} }; typedef const volatile S CVS; void f() { throw CVS(); // expected-error{{no matching constructor for initialization}} } } namespace ConstVolatileCatch { struct S { S() {} S(const volatile S &s); private: S(const S &s); // expected-note {{declared private here}} }; void f(); void g() { try { f(); } catch (volatile S s) { // expected-error {{calling a private constructor}} } } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/decl-expr-ambiguity.cpp
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s void f() { int a; struct S { int m; }; typedef S *T; // Expressions. T(a)->m = 7; int(a)++; // expected-error {{assignment to cast is illegal}} __extension__ int(a)++; // expected-error {{assignment to cast is illegal}} __typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}} void(a), ++a; if (int(a)+1) {} for (int(a)+1;;) {} // expected-warning {{expression result unused}} a = sizeof(int()+1); a = sizeof(int(1)); typeof(int()+1) a2; // expected-error {{extension used}} (int(1)); // expected-warning {{expression result unused}} // type-id (int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}} // Declarations. int fd(T(a)); // expected-warning {{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} T(*d)(int(p)); // expected-note {{previous}} typedef T td(int(p)); extern T tp(int(p)); T d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}} T d3v(void); typedef T d3t(); extern T f3(); __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}} typedef void *V; __typeof(*V()) f5(); // expected-error {{ISO C++ does not allow indirection on operand of type 'V' (aka 'void *')}} T multi1, multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}} T(d)[5]; // expected-error {{redefinition of 'd'}} typeof(int[])(f) = { 1, 2 }; // expected-error {{extension used}} void(b)(int); int(d2) __attribute__(()); if (int(a)=1) {} int(d3(int())); } struct RAII { RAII(); ~RAII(); }; void func(); void func2(short); namespace N { struct S; void emptyParens() { RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}} int a, b, c, d, e, // expected-note {{change this ',' to a ';' to call 'func'}} func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} S s(); // expected-warning {{function declaration}} } void nonEmptyParens() { int f = 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}} func2(short(f)); // expected-warning {{function declaration}} expected-note {{add a pair of parentheses}} } } class C { }; void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}} // not: void fn(int C); int g(C); void foo() { fn(1); // expected-error {{no matching function}} fn(g); // OK } namespace PR11874 { void foo(); // expected-note 3 {{class 'foo' is hidden by a non-type declaration of 'foo' here}} class foo {}; class bar { bar() { const foo* f1 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}} foo* f2 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}} foo f3; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}} } }; int baz; // expected-note 2 {{class 'baz' is hidden by a non-type declaration of 'baz' here}} class baz {}; void fizbin() { const baz* b1 = 0; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}} baz* b2; // expected-error {{use of undeclared identifier 'b2'}} baz b3; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}} } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/issue547.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s // expected-no-diagnostics template<typename T> struct classify_function { static const unsigned value = 0; }; template<typename R, typename ...Args> struct classify_function<R(Args...)> { static const unsigned value = 1; }; template<typename R, typename ...Args> struct classify_function<R(Args...) const> { static const unsigned value = 2; }; template<typename R, typename ...Args> struct classify_function<R(Args...) volatile> { static const unsigned value = 3; }; template<typename R, typename ...Args> struct classify_function<R(Args...) const volatile> { static const unsigned value = 4; }; template<typename R, typename ...Args> struct classify_function<R(Args..., ...)> { static const unsigned value = 5; }; template<typename R, typename ...Args> struct classify_function<R(Args..., ...) const> { static const unsigned value = 6; }; template<typename R, typename ...Args> struct classify_function<R(Args..., ...) volatile> { static const unsigned value = 7; }; template<typename R, typename ...Args> struct classify_function<R(Args..., ...) const volatile> { static const unsigned value = 8; }; template<typename R, typename ...Args> struct classify_function<R(Args..., ...) &&> { static const unsigned value = 9; }; template<typename R, typename ...Args> struct classify_function<R(Args..., ...) const &> { static const unsigned value = 10; }; typedef void f0(int) const; typedef void f1(int, float...) const volatile; typedef void f2(int, double, ...) &&; typedef void f3(int, double, ...) const &; int check0[classify_function<f0>::value == 2? 1 : -1]; int check1[classify_function<f1>::value == 8? 1 : -1]; int check2[classify_function<f2>::value == 9? 1 : -1]; int check3[classify_function<f3>::value == 10? 1 : -1];
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-char-subscripts.cpp
// RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s template<typename T> void t1() { int array[1] = { 0 }; T subscript = 0; int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}} } template<typename T> void t2() { int array[1] = { 0 }; T subscript = 0; int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}} } void test() { t1<char>(); // expected-note {{in instantiation of function template specialization 't1<char>' requested here}} t2<char>(); // expected-note {{in instantiation of function template specialization 't2<char>' requested here}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/indirect-goto.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics namespace test1 { // Make sure this doesn't crash. struct A { ~A(); }; void a() { goto *(A(), &&L); L: return; } }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/do-while-scope.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics void test() { int x; do int x; while (1); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/pr13353.cpp
// RUN: %clang_cc1 -fsyntax-only %s struct foo { virtual void bar() ; }; template<typename T> class zed : public foo { }; template<typename T> class bah : public zed<T> { void f() { const_cast<foo *>(this->g())->bar(); } };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
// XFAIL: hexagon // RUN: %clang -x c++-header -c -Wunused-local-typedef %s -o %t.gch -Werror // RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s // RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s #ifndef BE_THE_SOURCE inline void myfun() { // The warning should fire every time the pch file is used, not when it's built. // CHECK: warning: unused typedef typedef int a; } #endif
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/pragma-init_seg.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0 #ifndef __APPLE__ #pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}} #pragma init_seg( // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}} #pragma init_seg asdf // expected-warning {{missing '('}} #pragma init_seg) // expected-warning {{missing '('}} #pragma init_seg("a" "b") // no warning #pragma init_seg("a", "b") // expected-warning {{missing ')'}} #pragma init_seg("a") asdf // expected-warning {{extra tokens at end of '#pragma init_seg'}} #pragma init_seg("\x") // expected-error {{\x used with no following hex digits}} #pragma init_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma init_seg'}} #pragma init_seg(compiler) #else #pragma init_seg(compiler) // expected-warning {{'#pragma init_seg' is only supported when targeting a Microsoft environment}} #endif int f(); int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/attr-flatten.cpp
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s int i __attribute__((flatten)); // expected-error {{'flatten' attribute only applies to functions}} void f1() __attribute__((flatten)); void f2() __attribute__((flatten(1))); // expected-error {{'flatten' attribute takes no arguments}} template <typename T> void tf1() __attribute__((flatten)); int f3(int __attribute__((flatten)), int); // expected-error{{'flatten' attribute only applies to functions}} struct A { int f __attribute__((flatten)); // expected-error{{'flatten' attribute only applies to functions}} void mf1() __attribute__((flatten)); static void mf2() __attribute__((flatten)); }; int ci [[gnu::flatten]]; // expected-error {{'flatten' attribute only applies to functions}} [[gnu::flatten]] void cf1(); [[gnu::flatten(1)]] void cf2(); // expected-error {{'flatten' attribute takes no arguments}} template <typename T> [[gnu::flatten]] void ctf1(); int cf3(int c[[gnu::flatten]], int); // expected-error{{'flatten' attribute only applies to functions}} struct CA { int f [[gnu::flatten]]; // expected-error{{'flatten' attribute only applies to functions}} [[gnu::flatten]] void mf1(); [[gnu::flatten]] static void mf2(); };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/array-bounds.cpp
// RUN: %clang_cc1 -verify %s int foo() { int x[2]; // expected-note 4 {{array 'x' declared here}} int y[2]; // expected-note 2 {{array 'y' declared here}} int z[1]; // expected-note {{array 'z' declared here}} int w[1][1]; // expected-note {{array 'w' declared here}} int v[1][1][1]; // expected-note {{array 'v' declared here}} int *p = &y[2]; // no-warning (void) sizeof(x[2]); // no-warning y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 element)}} w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}} v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}} return x[2] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} y[-1] + // expected-warning {{array index -1 is before the beginning of the array}} x[sizeof(x)] + // expected-warning {{array index 8 is past the end of the array (which contains 2 elements)}} x[sizeof(x) / sizeof(x[0])] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains 2 elements)}} } // This code example tests that -Warray-bounds works with arrays that // are template parameters. template <char *sz> class Qux { bool test() { return sz[0] == 'a'; } }; void f1(int a[1]) { int val = a[3]; // no warning for function argumnet } void f2(const int (&a)[2]) { // expected-note {{declared here}} int val = a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}} } void test() { struct { int a[0]; } s2; s2.a[3] = 0; // no warning for 0-sized array union { short a[2]; // expected-note 4 {{declared here}} char c[4]; } u; u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}} u.c[3] = 1; // no warning short *p = &u.a[2]; // no warning p = &u.a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}} *(&u.a[2]) = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} *(&u.a[3]) = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}} *(&u.c[3]) = 1; // no warning const int const_subscript = 3; int array[2]; // expected-note {{declared here}} array[const_subscript] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}} int *ptr; ptr[3] = 0; // no warning for pointer references int array2[] = { 0, 1, 2 }; // expected-note 2 {{declared here}} array2[3] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 3 elements)}} array2[2+2] = 0; // expected-warning {{array index 4 is past the end of the array (which contains 3 elements)}} const char *str1 = "foo"; char c1 = str1[5]; // no warning for pointers const char str2[] = "foo"; // expected-note {{declared here}} char c2 = str2[5]; // expected-warning {{array index 5 is past the end of the array (which contains 4 elements)}} int (*array_ptr)[2]; (*array_ptr)[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}} } template <int I> struct S { char arr[I]; // expected-note 3 {{declared here}} }; template <int I> void f() { S<3> s; s.arr[4] = 0; // expected-warning 2 {{array index 4 is past the end of the array (which contains 3 elements)}} s.arr[I] = 0; // expected-warning {{array index 5 is past the end of the array (which contains 3 elements)}} } void test_templates() { f<5>(); // expected-note {{in instantiation}} } #define SIZE 10 #define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1 int test_no_warn_macro_unreachable() { int arr[SIZE]; // expected-note {{array 'arr' declared here}} return ARR_IN_MACRO(0, arr, SIZE) + // no-warning ARR_IN_MACRO(1, arr, SIZE); // expected-warning{{array index 10 is past the end of the array (which contains 10 elements)}} } // This exhibited an assertion failure for a 32-bit build of Clang. int test_pr9240() { short array[100]; // expected-note {{array 'array' declared here}} return array[(unsigned long long) 100]; // expected-warning {{array index 100 is past the end of the array (which contains 100 elements)}} } // PR 9284 - a template parameter can cause an array bounds access to be // infeasible. template <bool extendArray> void pr9284() { int arr[3 + (extendArray ? 1 : 0)]; if (extendArray) arr[3] = 42; // no-warning } template <bool extendArray> void pr9284b() { int arr[3 + (extendArray ? 1 : 0)]; // expected-note {{array 'arr' declared here}} if (!extendArray) arr[3] = 42; // expected-warning{{array index 3 is past the end of the array (which contains 3 elements)}} } void test_pr9284() { pr9284<true>(); pr9284<false>(); pr9284b<true>(); pr9284b<false>(); // expected-note{{in instantiation of function template specialization 'pr9284b<false>' requested here}} } int test_pr9296() { int array[2]; return array[true]; // no-warning } int test_sizeof_as_condition(int flag) { int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}} if (flag) return sizeof(char) != sizeof(char) ? arr[2] : arr[1]; return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} } void test_switch() { switch (4) { case 1: { int arr[2]; arr[2] = 1; // no-warning break; } case 4: { int arr[2]; // expected-note {{array 'arr' declared here}} arr[2] = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} break; } default: { int arr[2]; arr[2] = 1; // no-warning break; } } } // Test nested switch statements. enum enumA { enumA_A, enumA_B, enumA_C, enumA_D, enumA_E }; enum enumB { enumB_X, enumB_Y, enumB_Z }; static enum enumB myVal = enumB_X; void test_nested_switch() { switch (enumA_E) { // expected-warning {{no case matching constant}} switch (myVal) { // expected-warning {{enumeration values 'enumB_X' and 'enumB_Z' not handled in switch}} case enumB_Y: ; } } } // Test that if all the values of an enum covered, that the 'default' branch // is unreachable. enum Values { A, B, C, D }; void test_all_enums_covered(enum Values v) { int x[2]; switch (v) { case A: return; case B: return; case C: return; case D: return; } x[2] = 0; // no-warning } namespace tailpad { struct foo { char c1[1]; // expected-note {{declared here}} int x; char c2[1]; }; class baz { public: char c1[1]; // expected-note {{declared here}} int x; char c2[1]; }; char bar(struct foo *F, baz *B) { return F->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}} F->c2[3] + // no warning, foo could have tail padding allocated. B->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}} B->c2[3]; // no warning, baz could have tail padding allocated. } } namespace metaprogramming { #define ONE 1 struct foo { char c[ONE]; }; // expected-note {{declared here}} template <int N> struct bar { char c[N]; }; // expected-note {{declared here}} char test(foo *F, bar<1> *B) { return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}} B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}} } } void bar(int x) {} int test_more() { int foo[5]; // expected-note 5 {{array 'foo' declared here}} bar(foo[5]); // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}} ++foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}} if (foo[6]) // expected-warning {{array index 6 is past the end of the array (which contains 5 elements)}} return --foo[6]; // expected-warning {{array index 6 is past the end of the array (which contains 5 elements)}} else return foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}} } void test_pr10771() { double foo[4096]; // expected-note {{array 'foo' declared here}} ((char*)foo)[sizeof(foo) - 1] = '\0'; // no-warning *(((char*)foo) + sizeof(foo) - 1) = '\0'; // no-warning ((char*)foo)[sizeof(foo)] = '\0'; // expected-warning {{array index 32768 is past the end of the array (which contains 32768 elements)}} // TODO: This should probably warn, too. *(((char*)foo) + sizeof(foo)) = '\0'; // no-warning } int test_pr11007_aux(const char * restrict, ...); // Test checking with varargs. void test_pr11007() { double a[5]; // expected-note {{array 'a' declared here}} test_pr11007_aux("foo", a[1000]); // expected-warning {{array index 1000 is past the end of the array}} } void test_rdar10916006(void) { int a[128]; // expected-note {{array 'a' declared here}} a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/format-strings-0x-nopedantic.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -std=c++11 %s // expected-no-diagnostics extern "C" { extern int scanf(const char *restrict, ...); extern int printf(const char *restrict, ...); } void f(char *c) { printf("%p", c); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/underlying_type.cpp
// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c++11 %s #include "limits.h" template<typename T, typename U> struct is_same_type { static const bool value = false; }; template <typename T> struct is_same_type<T, T> { static const bool value = true; }; __underlying_type(int) a; // expected-error {{only enumeration types}} __underlying_type(struct b) c; // expected-error {{only enumeration types}} enum class f : char; static_assert(is_same_type<char, __underlying_type(f)>::value, "f has the wrong underlying type"); enum g {d = INT_MIN }; static_assert(is_same_type<int, __underlying_type(g)>::value, "g has the wrong underlying type"); __underlying_type(f) h; static_assert(is_same_type<char, decltype(h)>::value, "h has the wrong type"); template <typename T> struct underlying_type { typedef __underlying_type(T) type; // expected-error {{only enumeration types}} }; static_assert(is_same_type<underlying_type<f>::type, char>::value, "f has the wrong underlying type in the template"); underlying_type<int>::type e; // expected-note {{requested here}} using uint = unsigned; enum class foo : uint { bar }; static_assert(is_same_type<underlying_type<foo>::type, unsigned>::value, "foo has the wrong underlying type"); namespace PR19966 { void PR19966(enum Invalid) { // expected-note 2{{forward declaration of}} // expected-error@-1 {{ISO C++ forbids forward references to 'enum'}} // expected-error@-2 {{variable has incomplete type}} __underlying_type(Invalid) dont_crash; // expected-error@-1 {{cannot determine underlying type of incomplete enumeration type 'PR19966::Invalid'}} } enum E { // expected-note {{forward declaration of 'E'}} a = (__underlying_type(E)){} // expected-error@-1 {{cannot determine underlying type of incomplete enumeration type 'PR19966::E'}} // expected-error@-2 {{constant expression}} }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-absolute-value.cpp
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value -std=c++11 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits -std=c++11 2>&1 | FileCheck %s extern "C" { int abs(int); long int labs(long int); long long int llabs(long long int); float fabsf(float); double fabs(double); long double fabsl(long double); float cabsf(float _Complex); double cabs(double _Complex); long double cabsl(long double _Complex); } namespace std { inline namespace __1 { int abs(int); long int abs(long int); long long int abs(long long int); } float abs(float); double abs(double); long double abs(long double); template <typename T> double abs(T); } void test_int(int x) { (void)std::abs(x); (void)abs(x); (void)labs(x); (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); (void)__builtin_labs(x); (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" } void test_long(long x) { (void)std::abs(x); (void)abs(x); // no warning - int and long are same length for this target (void)labs(x); (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); // no warning - int and long are same length for // this target (void)__builtin_labs(x); (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" } void test_long_long(long long x) { (void)std::abs(x); (void)abs(x); // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs" (void)labs(x); // expected-warning@-1{{absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); // expected-warning@-1{{absolute value function '__builtin_abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs" (void)__builtin_labs(x); // expected-warning@-1{{absolute value function '__builtin_labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" } void test_float(float x) { (void)std::abs(x); (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabsf(x); (void)fabs(x); (void)fabsl(x); (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabsf(x); (void)__builtin_fabs(x); (void)__builtin_fabsl(x); (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" } void test_double(double x) { (void)std::abs(x); (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabsf(x); // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); (void)fabsl(x); (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabsf(x); // expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); (void)__builtin_fabsl(x); (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" } void test_long_double(long double x) { (void)std::abs(x); (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabsf(x); // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); // expected-warning@-1{{absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)fabsl(x); (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabsf(x); // expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); // expected-warning@-1{{absolute value function '__builtin_fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}} // expected-note@-2{{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_fabsl(x); (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" } void test_complex_float(_Complex float x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)cabsf(x); (void)cabs(x); (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_cabsf(x); (void)__builtin_cabs(x); (void)__builtin_cabsl(x); } void test_complex_double(_Complex double x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" (void)cabsf(x); // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}} // expected-note@-2 {{use function 'cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" (void)cabs(x); (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabs" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" (void)__builtin_cabsf(x); // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}} // expected-note@-2 {{use function '__builtin_cabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" (void)__builtin_cabs(x); (void)__builtin_cabsl(x); } void test_complex_long_double(_Complex long double x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)cabsf(x); // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)cabs(x); // expected-warning@-1 {{absolute value function 'cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_cabsf(x); // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_cabs(x); // expected-warning@-1 {{absolute value function '__builtin_cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_cabsl(x); } void test_unsigned_int(unsigned int x) { (void)std::abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'std::abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:17}:"" (void)abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"" (void)labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)__builtin_abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"" (void)__builtin_labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" } void test_unsigned_long(unsigned long x) { (void)std::abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'std::abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:17}:"" (void)abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"" (void)labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)__builtin_abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"" (void)__builtin_labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
// RUN: %clang_cc1 -fsyntax-only -Wreorder -verify %s struct BB {}; struct BB1 {}; class complex : public BB, BB1 { public: complex() : s2(1), // expected-warning {{field 's2' will be initialized after field 's1'}} s1(1), s3(3), // expected-warning {{field 's3' will be initialized after base 'BB1'}} BB1(), // expected-warning {{base class 'BB1' will be initialized after base 'BB'}} BB() {} int s1; int s2; int s3; }; // testing virtual bases. struct V { V(); }; struct A : public virtual V { A(); }; struct B : public virtual V { B(); }; struct Diamond : public A, public B { Diamond() : A(), B() {} }; struct C : public A, public B, private virtual V { C() { } }; struct D : public A, public B { D() : A(), V() { } // expected-warning {{base class 'A' will be initialized after base 'V'}} }; struct E : public A, public B, private virtual V { E() : A(), V() { } // expected-warning {{base class 'A' will be initialized after base 'V'}} }; struct A1 { A1(); }; struct B1 { B1(); }; struct F : public A1, public B1, private virtual V { F() : A1(), V() { } // expected-warning {{base class 'A1' will be initialized after base 'V'}} }; struct X : public virtual A, virtual V, public virtual B { X(): A(), V(), B() {} // expected-warning {{base class 'A' will be initialized after base 'V'}} }; class Anon { int c; union {int a,b;}; int d; Anon() : c(10), b(1), d(2) {} }; class Anon2 { int c; union {int a,b;}; int d; Anon2() : c(2), d(10), // expected-warning {{field 'd' will be initialized after field 'b'}} b(1) {} }; class Anon3 { union {int a,b;}; Anon3() : b(1) {} }; namespace T1 { struct S1 { }; struct S2: virtual S1 { }; struct S3 { }; struct S4: virtual S3, S2 { S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after base 'T1::S3'}} S3() { }; }; } namespace test2 { struct Foo { Foo(); }; class A { template <class T> A(T *t) : y(), // expected-warning {{field 'y' will be initialized after field 'x'}} x() {} Foo x; Foo y; }; } // PR6575: this should not crash namespace test3 { struct MyClass { MyClass() : m_int(0) {} union { struct { int m_int; }; }; }; } namespace PR7179 { struct X { struct Y { template <class T> Y(T x) : X(x) { } }; }; } namespace test3 { struct foo { struct { int a; int b; }; foo() : b(), a() { // expected-warning {{field 'b' will be initialized after field 'a'}} } }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR8385.cpp
// RUN: not %clang_cc1 -fsyntax-only %s // don't crash on this, but don't constrain our diagnostics here as they're // currently rather poor (we even accept things like "template struct {}"). // Other, explicit tests, should verify the relevant behavior of template // instantiation. struct{template struct{
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/access-control-check.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s class M { int iM; }; class P { int iP; // expected-note {{declared private here}} int PPR(); // expected-note {{declared private here}} }; class N : M,P { N() {} int PR() { return iP + PPR(); } // expected-error 2 {{private member of 'P'}} };
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx11-thread-unsupported.cpp
// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.6 -verify %s void f() { thread_local int x; // expected-error {{thread-local storage is not supported for the current target}} }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/member-expr-static.cpp
// RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics typedef void (*thread_continue_t)(); extern "C" { extern void kernel_thread_start(thread_continue_t continuation); extern void pure_c(void); } class _IOConfigThread { public: static void main( void ); }; void foo( void ) { kernel_thread_start(&_IOConfigThread::main); kernel_thread_start((thread_continue_t)&_IOConfigThread::main); kernel_thread_start(&pure_c); }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx-deprecated.cpp
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s namespace [[deprecated]] {} // expected-warning {{'deprecated' attribute on anonymous namespace ignored}} namespace [[deprecated]] N { // expected-note 4{{'N' has been explicitly marked deprecated here}} int X; int Y = X; // Ok int f(); } int N::f() { // Ok return Y; // Ok } void f() { int Y = N::f(); // expected-warning {{'N' is deprecated}} using N::X; // expected-warning {{'N' is deprecated}} int Z = X; //Ok } void g() { using namespace N; // expected-warning {{'N' is deprecated}} int Z = Y; // Ok } namespace M = N; // expected-warning {{'N' is deprecated}}
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/exceptions-seh.cpp
// RUN: %clang_cc1 -std=c++03 -fblocks -triple x86_64-windows-msvc -fms-extensions -fsyntax-only -fexceptions -fcxx-exceptions -verify %s // RUN: %clang_cc1 -std=c++11 -fblocks -triple x86_64-windows-msvc -fms-extensions -fsyntax-only -fexceptions -fcxx-exceptions -verify %s // Basic usage should work. int safe_div(int n, int d) { int r; __try { r = n / d; } __except(_exception_code() == 0xC0000094) { r = 0; } return r; } void might_crash(); // Diagnose obvious builtin mis-usage. void bad_builtin_scope() { __try { might_crash(); } __except(1) { } _exception_code(); // expected-error {{'_exception_code' only allowed in __except block or filter expression}} _exception_info(); // expected-error {{'_exception_info' only allowed in __except filter expression}} } // Diagnose obvious builtin misusage in a template. template <void FN()> void bad_builtin_scope_template() { __try { FN(); } __except(1) { } _exception_code(); // expected-error {{'_exception_code' only allowed in __except block or filter expression}} _exception_info(); // expected-error {{'_exception_info' only allowed in __except filter expression}} } void instantiate_bad_scope_tmpl() { bad_builtin_scope_template<might_crash>(); } #if __cplusplus < 201103L // FIXME: Diagnose this case. For now we produce undef in codegen. template <typename T, T FN()> T func_template() { return FN(); } void inject_builtins() { func_template<void *, __exception_info>(); func_template<unsigned long, __exception_code>(); } #endif void use_seh_after_cxx() { try { // expected-note {{conflicting 'try' here}} might_crash(); } catch (int) { } __try { // expected-error {{cannot use C++ 'try' in the same function as SEH '__try'}} might_crash(); } __except(1) { } } void use_cxx_after_seh() { __try { // expected-note {{conflicting '__try' here}} might_crash(); } __except(1) { } try { // expected-error {{cannot use C++ 'try' in the same function as SEH '__try'}} might_crash(); } catch (int) { } } #if __cplusplus >= 201103L void use_seh_in_lambda() { ([]() { __try { might_crash(); } __except(1) { } })(); try { might_crash(); } catch (int) { } } #endif void use_seh_in_block() { void (^b)() = ^{ __try { // expected-error {{cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls}} might_crash(); } __except(1) { } }; try { b(); } catch (int) { } } void (^use_seh_in_global_block)() = ^{ __try { // expected-error {{cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls}} might_crash(); } __except(1) { } }; void (^use_cxx_in_global_block)() = ^{ try { might_crash(); } catch(int) { } };
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/array-bounds-system-header.h
// "System header" for testing that -Warray-bounds is properly suppressed in // certain cases. #define BAD_MACRO_1 \ int i[3]; \ i[3] = 5 #define BAD_MACRO_2(_b, _i) \ (_b)[(_i)] = 5 #define QUESTIONABLE_MACRO(_a) \ sizeof(_a) > 3 ? (_a)[3] = 5 : 5 #define NOP(x) (x)
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/malloc.h
extern "C" { extern void *malloc (__SIZE_TYPE__ __size) throw () __attribute__ ((__malloc__)) ; }
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/override-system-header.h
// override-system-header.h to test out 'override' warning. // rdar://18295240 #define END_COM_MAP virtual unsigned AddRef(void) = 0; #define STDMETHOD(method) virtual void method #define IFACEMETHOD(method) STDMETHOD(method)
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/header-with-pragma-optimize-off.h
// Open an "off" region in this header. #pragma clang optimize off // Let the "off" region fall through to anything including this header.
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/register.h
#pragma GCC system_header #pragma once inline void f() { register int k; } #define to_int(x) ({ register int n = (x); n; })
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h
#pragma GCC system_header // This header file pretends to be <new> from the system library, for the // purpose of the over-aligned warnings test. void* operator new(unsigned long) { return 0; } void* operator new[](unsigned long) { return 0; } void* operator new(unsigned long, void *) { return 0; } void* operator new[](unsigned long, void *) { return 0; }
0
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/Inputs/warn-unused-variables.h
// Verify that we don't warn about variables of internal-linkage type in // headers, as the use may be in another TU. namespace PR15558 { namespace { class A {}; } class B { static A a; static A b; static const int x = sizeof(b); }; }
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/CodeGenHLSL/Readme.md
Files in this directory are used by tests implemented in CompilerTest.cpp
0
repos/DirectXShaderCompiler/tools/clang/test
repos/DirectXShaderCompiler/tools/clang/test/CodeGenHLSL/lib_no_alloca.h
float2 test(float2 a) { float2 b = a; b.y = sin(a.y); return b; }