diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 17:59:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 17:59:23 +0000 |
commit | 9a83721404652cea39e9f02ae3e3b5c964602a5c (patch) | |
tree | 23e9541ce27049a103f6ed046be61592123e02c9 /test/CXX/expr | |
parent | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (diff) |
Notes
Diffstat (limited to 'test/CXX/expr')
81 files changed, 0 insertions, 4221 deletions
diff --git a/test/CXX/expr/expr.ass/p9-cxx11.cpp b/test/CXX/expr/expr.ass/p9-cxx11.cpp deleted file mode 100644 index ecc6d2c3d5bfa..0000000000000 --- a/test/CXX/expr/expr.ass/p9-cxx11.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -template<typename T> struct complex { - complex(T = T(), T = T()); - void operator+=(complex); - T a, b; -}; - -void std_example() { - complex<double> z; - z = { 1, 2 }; - z += { 1, 2 }; - - int a, b; - a = b = { 1 }; - a = { 1 } = b; // expected-error {{initializer list cannot be used on the left hand side of operator '='}} - a = a + { 4 }; // expected-error {{initializer list cannot be used on the right hand side of operator '+'}} - a = { 3 } * { 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '*'}} \ - expected-error {{initializer list cannot be used on the right hand side of operator '*'}} -} - -struct S { - constexpr S(int a, int b) : a(a), b(b) {} - int a, b; -}; -struct T { - constexpr int operator=(S s) const { return s.a; } - constexpr int operator+=(S s) const { return s.b; } -}; -static_assert((T() = {4, 9}) == 4, ""); -static_assert((T() += {4, 9}) == 9, ""); - -int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '='}} -int k2 = T() = { 1, 2 } + 1; // expected-error {{initializer list cannot be used on the left hand side of operator '+'}} diff --git a/test/CXX/expr/expr.cast/p4-0x.cpp b/test/CXX/expr/expr.cast/p4-0x.cpp deleted file mode 100644 index 76ac318017302..0000000000000 --- a/test/CXX/expr/expr.cast/p4-0x.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct X { }; -struct Y : X { }; - -void test_lvalue_to_rvalue_drop_cvquals(const X &x, const Y &y, const int &i) { - (void)(X&&)x; - (void)(int&&)i; - (void)(X&&)y; - (void)(Y&&)x; -} diff --git a/test/CXX/expr/expr.cast/p4.cpp b/test/CXX/expr/expr.cast/p4.cpp deleted file mode 100644 index 907e008724420..0000000000000 --- a/test/CXX/expr/expr.cast/p4.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -ast-dump %s | FileCheck %s - -struct A { int x; }; -struct B { int y; }; -struct C : A, B { }; - -// CHECK: casting_away_constness -void casting_away_constness(const B &b, const C &c, const B *bp, const C *cp) { - // CHECK: DerivedToBase (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'c' - (void)(B&)c; - // CHECK: BaseToDerived (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'b' - (void)(C&)b; - // CHECK: DerivedToBase (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'cp' - (void)(B*)cp; - // CHECK: BaseToDerived (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'bp' - (void)(C*)bp; - // CHECK: ReturnStmt - return; -} diff --git a/test/CXX/expr/expr.cond/p4.cpp b/test/CXX/expr/expr.cond/p4.cpp deleted file mode 100644 index 4d0cf3538cf05..0000000000000 --- a/test/CXX/expr/expr.cond/p4.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -verify %s -// RUN: %clang_cc1 -std=c++1z -verify %s - -// expected-no-diagnostics - -struct A { A(); A(int); }; -void f() { - const A a; - true ? a : 0; -} diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp deleted file mode 100644 index 4daed23bf9c68..0000000000000 --- a/test/CXX/expr/expr.const/p2-0x.cpp +++ /dev/null @@ -1,611 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu - -// A conditional-expression is a core constant expression unless it involves one -// of the following as a potentially evaluated subexpression [...]: - -// - this (5.1.1 [expr.prim.general]) [Note: when evaluating a constant -// expression, function invocation substitution (7.1.5 [dcl.constexpr]) -// replaces each occurrence of this in a constexpr member function with a -// pointer to the class object. -end note]; -struct This { - int this1 : this1; // expected-error {{undeclared}} - int this2 : this->this1; // expected-error {{invalid}} - void this3() { - int n1[this->this1]; // expected-warning {{variable length array}} - int n2[this1]; // expected-warning {{variable length array}} - (void)n1, (void)n2; - } -}; - -// - an invocation of a function other than a constexpr constructor for a -// literal class or a constexpr function [ Note: Overload resolution (13.3) -// is applied as usual - end note ]; -struct NonConstexpr1 { - static int f() { return 1; } // expected-note {{here}} - int n : f(); // expected-error {{constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}} -}; -struct NonConstexpr2 { - constexpr NonConstexpr2(); // expected-note {{here}} - int n; -}; -struct NonConstexpr3 { - NonConstexpr3(); - int m : NonConstexpr2().n; // expected-error {{constant expression}} expected-note {{undefined constructor 'NonConstexpr2'}} -}; -struct NonConstexpr4 { - NonConstexpr4(); - int n; -}; -struct NonConstexpr5 { - int n : NonConstexpr4().n; // expected-error {{constant expression}} expected-note {{non-literal type 'NonConstexpr4' cannot be used in a constant expression}} -}; - -// - an invocation of an undefined constexpr function or an undefined -// constexpr constructor; -struct UndefinedConstexpr { - constexpr UndefinedConstexpr(); - static constexpr int undefinedConstexpr1(); // expected-note {{here}} - int undefinedConstexpr2 : undefinedConstexpr1(); // expected-error {{constant expression}} expected-note {{undefined function 'undefinedConstexpr1' cannot be used in a constant expression}} -}; - -// - an invocation of a constexpr function with arguments that, when substituted -// by function invocation substitution (7.1.5), do not produce a core constant -// expression; -namespace NonConstExprReturn { - static constexpr const int &id_ref(const int &n) { - return n; - } - struct NonConstExprFunction { - int n : id_ref(16); // ok - }; - constexpr const int *address_of(const int &a) { - return &a; - } - constexpr const int *return_param(int n) { // expected-note {{declared here}} - return address_of(n); - } - struct S { - int n : *return_param(0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}} - }; -} - -// - an invocation of a constexpr constructor with arguments that, when -// substituted by function invocation substitution (7.1.5), do not produce all -// constant expressions for the constructor calls and full-expressions in the -// mem-initializers (including conversions); -namespace NonConstExprCtor { - struct T { - constexpr T(const int &r) : - r(r) { - } - const int &r; - }; - constexpr int n = 0; - constexpr T t1(n); // ok - constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} expected-note {{temporary created here}} expected-note {{reference to temporary is not a constant expression}} - - struct S { - int n : T(4).r; // ok - }; -} - -// - an invocation of a constexpr function or a constexpr constructor that would -// exceed the implementation-defined recursion limits (see Annex B); -namespace RecursionLimits { - constexpr int RecurseForever(int n) { - return n + RecurseForever(n+1); // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'RecurseForever(}} expected-note {{skipping 118 calls}} - } - struct AlsoRecurseForever { - constexpr AlsoRecurseForever(int n) : - n(AlsoRecurseForever(n+1).n) // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'AlsoRecurseForever(}} expected-note {{skipping 118 calls}} - {} - int n; - }; - struct S { - int k : RecurseForever(0); // expected-error {{constant expression}} expected-note {{in call to}} - int l : AlsoRecurseForever(0).n; // expected-error {{constant expression}} expected-note {{in call to}} - }; -} - -// DR1458: taking the address of an object of incomplete class type -namespace IncompleteClassTypeAddr { - struct S; - extern S s; - constexpr S *p = &s; // ok - static_assert(p, ""); - - extern S sArr[]; - constexpr S (*p2)[] = &sArr; // ok - - struct S { - constexpr S *operator&() const { return nullptr; } - }; - constexpr S *q = &s; // ok - static_assert(!q, ""); -} - -// - an operation that would have undefined behavior [Note: including, for -// example, signed integer overflow (Clause 5 [expr]), certain pointer -// arithmetic (5.7 [expr.add]), division by zero (5.6 [expr.mul]), or certain -// shift operations (5.8 [expr.shift]) -end note]; -namespace UndefinedBehavior { - void f(int n) { - switch (n) { - case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} - case (int)0x80000000u: // ok - case (int)10000000000ll: // expected-note {{here}} - case (unsigned int)10000000000ll: // expected-error {{duplicate case value}} - case (int)(unsigned)(long long)4.4e9: // ok - case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} - case (int)((float)1e37 / 1e30): // ok - case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type '__fp16'}} - break; - } - } - - constexpr int int_min = ~0x7fffffff; - constexpr int minus_int_min = -int_min; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}} - constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by zero}} - constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by zero}} - constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}} - constexpr int int_min_mod_minus_1 = int_min % -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}} - - constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} - constexpr int shl_0 = 0 << 0; // ok - constexpr int shl_31 = 0 << 31; // ok - constexpr int shl_32 = 0 << 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type 'int' (32}} - constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok - constexpr int shl_unsigned_into_sign = 1u << 31; // ok - constexpr int shl_unsigned_overflow = 1024u << 31; // ok - constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}} - constexpr int shl_signed_ok = 1 << 30; // ok - constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457) - constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457) - constexpr int shl_signed_off_end = 2 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits}} - constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x1FFFFFFFC) requires 34 bits to represent, but 'int' only has 32 bits}} - constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{requires 43 bits to represent}} - constexpr int shl_signed_ok2 = 1024 << 20; // ok - - constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} - constexpr int shr_0 = 0 >> 0; // ok - constexpr int shr_31 = 0 >> 31; // ok - constexpr int shr_32 = 0 >> 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type}} - - struct S { - int m; - }; - constexpr S s = { 5 }; - constexpr const int *p = &s.m + 1; - constexpr const int &f(const int *q) { - return q[0]; - } - constexpr int n = (f(p), 0); // ok - struct T { - int n : f(p); // expected-error {{not an integral constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}} - }; - - namespace Ptr { - struct A {}; - struct B : A { int n; }; - B a[3][3]; - constexpr B *p = a[0] + 4; // expected-error {{constant expression}} expected-note {{element 4 of array of 3 elements}} - B b = {}; - constexpr A *pa = &b + 1; // expected-error {{constant expression}} expected-note {{base class of pointer past the end}} - constexpr B *pb = (B*)((A*)&b + 1); // expected-error {{constant expression}} expected-note {{derived class of pointer past the end}} - constexpr const int *pn = &(&b + 1)->n; // expected-error {{constant expression}} expected-note {{field of pointer past the end}} - constexpr B *parr = &a[3][0]; // expected-error {{constant expression}} expected-note {{array element of pointer past the end}} - - constexpr A *na = nullptr; - constexpr B *nb = nullptr; - constexpr A &ra = *nb; // expected-error {{constant expression}} expected-note {{cannot access base class of null pointer}} - constexpr B &rb = (B&)*na; // expected-error {{constant expression}} expected-note {{cannot access derived class of null pointer}} - static_assert((A*)nb == 0, ""); - static_assert((B*)na == 0, ""); - constexpr const int &nf = nb->n; // expected-error {{constant expression}} expected-note {{cannot access field of null pointer}} - constexpr const int *np1 = (int*)nullptr + 0; // ok - constexpr const int *np2 = &(*(int(*)[4])nullptr)[0]; // ok - constexpr const int *np3 = &(*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} expected-note {{cannot perform pointer arithmetic on null pointer}} - - struct C { - constexpr int f() const { return 0; } - } constexpr c = C(); - constexpr int k1 = c.f(); // ok - constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{cannot call member function on null pointer}} - constexpr int k3 = (&c)[1].f(); // expected-error {{constant expression}} expected-note {{cannot call member function on pointer past the end of object}} - C c2; - constexpr int k4 = c2.f(); // ok! - - constexpr int diff1 = &a[2] - &a[0]; - constexpr int diff2 = &a[1][3] - &a[1][0]; - constexpr int diff3 = &a[2][0] - &a[1][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}} - static_assert(&a[2][0] == &a[1][3], ""); - constexpr int diff4 = (&b + 1) - &b; - constexpr int diff5 = &a[1][2].n - &a[1][0].n; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}} - constexpr int diff6 = &a[1][2].n - &a[1][2].n; - constexpr int diff7 = (A*)&a[0][1] - (A*)&a[0][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}} - } - - namespace Overflow { - // Signed int overflow. - constexpr int n1 = 2 * 3 * 3 * 7 * 11 * 31 * 151 * 331; // ok - constexpr int n2 = 65536 * 32768; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }} - constexpr int n3 = n1 + 1; // ok - constexpr int n4 = n3 + 1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }} - constexpr int n5 = -65536 * 32768; // ok - constexpr int n6 = 3 * -715827883; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }} - constexpr int n7 = -n3 + -1; // ok - constexpr int n8 = -1 + n7; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }} - constexpr int n9 = n3 - 0; // ok - constexpr int n10 = n3 - -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }} - constexpr int n11 = -1 - n3; // ok - constexpr int n12 = -2 - n3; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }} - constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }} - constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note {{value 4294967295 is outside the range of }} - constexpr int n15 = n5 * n5; // expected-error {{constant expression}} expected-note {{value 4611686018427387904 is outside the range of }} - constexpr signed char c1 = 100 * 2; // ok expected-warning{{changes value}} - constexpr signed char c2 = '\x64' * '\2'; // also ok expected-warning{{changes value}} - constexpr long long ll1 = 0x7fffffffffffffff; // ok - constexpr long long ll2 = ll1 + 1; // expected-error {{constant}} expected-note {{ 9223372036854775808 }} - constexpr long long ll3 = -ll1 - 1; // ok - constexpr long long ll4 = ll3 - 1; // expected-error {{constant}} expected-note {{ -9223372036854775809 }} - constexpr long long ll5 = ll3 * ll3; // expected-error {{constant}} expected-note {{ 85070591730234615865843651857942052864 }} - - // Yikes. - char melchizedek[2200000000]; - typedef decltype(melchizedek[1] - melchizedek[0]) ptrdiff_t; - constexpr ptrdiff_t d1 = &melchizedek[0x7fffffff] - &melchizedek[0]; // ok - constexpr ptrdiff_t d2 = &melchizedek[0x80000000u] - &melchizedek[0]; // expected-error {{constant expression}} expected-note {{ 2147483648 }} - constexpr ptrdiff_t d3 = &melchizedek[0] - &melchizedek[0x80000000u]; // ok - constexpr ptrdiff_t d4 = &melchizedek[0] - &melchizedek[0x80000001u]; // expected-error {{constant expression}} expected-note {{ -2147483649 }} - - // Unsigned int overflow. - static_assert(65536u * 65536u == 0u, ""); // ok - static_assert(4294967295u + 1u == 0u, ""); // ok - static_assert(0u - 1u == 4294967295u, ""); // ok - static_assert(~0u * ~0u == 1u, ""); // ok - - // Floating-point overflow and NaN. - constexpr float f1 = 1e38f * 3.4028f; // ok - constexpr float f2 = 1e38f * 3.4029f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f3 = 1e38f / -.2939f; // ok - constexpr float f4 = 1e38f / -.2938f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f5 = 2e38f + 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f6 = -2e38f - 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f7 = 0.f / 0.f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces a NaN}} - } -} - -// - a lambda-expression (5.1.2); -struct Lambda { - int n : []{ return 1; }(); // expected-error {{constant expression}} expected-error {{integral constant expression}} expected-note {{non-literal type}} -}; - -// - an lvalue-to-rvalue conversion (4.1) unless it is applied to -namespace LValueToRValue { - // - a non-volatile glvalue of integral or enumeration type that refers to a - // non-volatile const object with a preceding initialization, initialized - // with a constant expression [Note: a string literal (2.14.5 [lex.string]) - // corresponds to an array of such objects. -end note], or - volatile const int vi = 1; // expected-note 2{{here}} - const int ci = 1; - volatile const int &vrci = ci; - static_assert(vi, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(const_cast<int&>(vi), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}} - static_assert(vrci, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - - // - a non-volatile glvalue of literal type that refers to a non-volatile - // object defined with constexpr, or that refers to a sub-object of such an - // object, or - struct V { - constexpr V() : v(1) {} - volatile int v; // expected-note {{not literal because}} - }; - constexpr V v; // expected-error {{non-literal type}} - struct S { - constexpr S(int=0) : i(1), v(const_cast<volatile int&>(vi)) {} - constexpr S(const S &s) : i(2), v(const_cast<volatile int&>(vi)) {} - int i; - volatile int &v; - }; - constexpr S s; // ok - constexpr volatile S vs; // expected-note {{here}} - constexpr const volatile S &vrs = s; // ok - static_assert(s.i, ""); - static_assert(s.v, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(const_cast<int&>(s.v), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}} - static_assert(vs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(const_cast<int&>(vs.i), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vs'}} - static_assert(vrs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - - // - a non-volatile glvalue of literal type that refers to a non-volatile - // temporary object whose lifetime has not ended, initialized with a - // constant expression; - constexpr volatile S f() { return S(); } - static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} -} - -// DR1312: The proposed wording for this defect has issues, so we ignore this -// bullet and instead prohibit casts from pointers to cv void (see core-20842 -// and core-20845). -// -// - an lvalue-to-rvalue conversion (4.1 [conv.lval]) that is applied to a -// glvalue of type cv1 T that refers to an object of type cv2 U, where T and U -// are neither the same type nor similar types (4.4 [conv.qual]); - -// - an lvalue-to-rvalue conversion (4.1) that is applied to a glvalue that -// refers to a non-active member of a union or a subobject thereof; -namespace LValueToRValueUnion { - // test/SemaCXX/constant-expression-cxx11.cpp contains more thorough testing - // of this. - union U { int a, b; } constexpr u = U(); - static_assert(u.a == 0, ""); - constexpr const int *bp = &u.b; - constexpr int b = *bp; // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}} - - extern const U pu; - constexpr const int *pua = &pu.a; - constexpr const int *pub = &pu.b; - constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}} - constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}} - constexpr const int b2 = *pub; // ok -} - -// - an id-expression that refers to a variable or data member of reference type -// unless the reference has a preceding initialization, initialized with a -// constant expression; -namespace References { - const int a = 2; - int &b = *const_cast<int*>(&a); - int c = 10; // expected-note 2 {{here}} - int &d = c; - constexpr int e = 42; - int &f = const_cast<int&>(e); - extern int &g; - constexpr int &h(); // expected-note {{here}} - int &i = h(); // expected-note {{here}} - constexpr int &j() { return b; } - int &k = j(); - - struct S { - int A : a; - int B : b; - int C : c; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}} - int D : d; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}} - int D2 : &d - &c + 1; - int E : e / 2; - int F : f - 11; - int G : g; // expected-error {{constant expression}} - int H : h(); // expected-error {{constant expression}} expected-note {{undefined function 'h'}} - int I : i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}} - int J : j(); - int K : k; - }; -} - -// - a dynamic_cast (5.2.7); -namespace DynamicCast { - struct S { int n; }; - constexpr S s { 16 }; - struct T { - int n : dynamic_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{dynamic_cast}} - }; -} - -// - a reinterpret_cast (5.2.10); -namespace ReinterpretCast { - struct S { int n; }; - constexpr S s { 16 }; - struct T { - int n : reinterpret_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}} - }; - struct U { - int m : (long)(S*)6; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}} - }; -} - -// - a pseudo-destructor call (5.2.4); -namespace PseudoDtor { - int k; - typedef int I; - struct T { - int n : (k.~I(), 0); // expected-error {{constant expression}} - }; -} - -// - increment or decrement operations (5.2.6, 5.3.2); -namespace IncDec { - int k = 2; - struct T { - int n : ++k; // expected-error {{constant expression}} - int m : --k; // expected-error {{constant expression}} - }; -} - -// - a typeid expression (5.2.8) whose operand is of a polymorphic class type; -namespace std { - struct type_info { - virtual ~type_info(); - const char *name; - }; -} -namespace TypeId { - struct S { virtual void f(); }; - constexpr S *p = 0; - constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a constant expression}} expected-note {{typeid applied to expression of polymorphic type 'TypeId::S'}} - - struct T {} t; - constexpr const std::type_info &ti2 = typeid(t); -} - -// - a new-expression (5.3.4); -// - a delete-expression (5.3.5); -namespace NewDelete { - int *p = 0; - struct T { - int n : *new int(4); // expected-error {{constant expression}} - int m : (delete p, 2); // expected-error {{constant expression}} - }; -} - -// - a relational (5.9) or equality (5.10) operator where the result is -// unspecified; -namespace UnspecifiedRelations { - int a, b; - constexpr int *p = &a, *q = &b; - // C++11 [expr.rel]p2: If two pointers p and q of the same type point to - // different objects that are not members of the same array or to different - // functions, or if only one of them is null, the results of p<q, p>q, p<=q, - // and p>=q are unspecified. - constexpr bool u1 = p < q; // expected-error {{constant expression}} - constexpr bool u2 = p > q; // expected-error {{constant expression}} - constexpr bool u3 = p <= q; // expected-error {{constant expression}} - constexpr bool u4 = p >= q; // expected-error {{constant expression}} - constexpr bool u5 = p < (int*)0; // expected-error {{constant expression}} - constexpr bool u6 = p <= (int*)0; // expected-error {{constant expression}} - constexpr bool u7 = p > (int*)0; // expected-error {{constant expression}} - constexpr bool u8 = p >= (int*)0; // expected-error {{constant expression}} - constexpr bool u9 = (int*)0 < q; // expected-error {{constant expression}} - constexpr bool u10 = (int*)0 <= q; // expected-error {{constant expression}} - constexpr bool u11 = (int*)0 > q; // expected-error {{constant expression}} - constexpr bool u12 = (int*)0 >= q; // expected-error {{constant expression}} - void f(), g(); - - constexpr void (*pf)() = &f, (*pg)() = &g; - constexpr bool u13 = pf < pg; // expected-error {{constant expression}} - constexpr bool u14 = pf == pg; - - // If two pointers point to non-static data members of the same object with - // different access control, the result is unspecified. - struct A { - public: - constexpr A() : a(0), b(0) {} - int a; - constexpr bool cmp() const { return &a < &b; } // expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}} - private: - int b; - }; - static_assert(A().cmp(), ""); // expected-error {{constant expression}} expected-note {{in call}} - class B { - public: - A a; - constexpr bool cmp() const { return &a.a < &b.a; } // expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}} - protected: - A b; - }; - static_assert(B().cmp(), ""); // expected-error {{constant expression}} expected-note {{in call}} - - // If two pointers point to different base sub-objects of the same object, or - // one points to a base subobject and the other points to a member, the result - // of the comparison is unspecified. This is not explicitly called out by - // [expr.rel]p2, but is covered by 'Other pointer comparisons are - // unspecified'. - struct C { - int c[2]; - }; - struct D { - int d; - }; - struct E : C, D { - struct Inner { - int f; - } e; - } e; - constexpr bool base1 = &e.c[0] < &e.d; // expected-error {{constant expression}} expected-note {{comparison of addresses of subobjects of different base classes has unspecified value}} - constexpr bool base2 = &e.c[1] < &e.e.f; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'C' of class 'E' to field 'e' has unspecified value}} - constexpr bool base3 = &e.e.f < &e.d; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'D' of class 'E' to field 'e' has unspecified value}} - - // [expr.rel]p3: Pointers to void can be compared [...] if both pointers - // represent the same address or are both the null pointer [...]; otherwise - // the result is unspecified. - struct S { int a, b; } s; - constexpr void *null = 0; - constexpr void *pv = (void*)&s.a; - constexpr void *qv = (void*)&s.b; - constexpr bool v1 = null < (int*)0; - constexpr bool v2 = null < pv; // expected-error {{constant expression}} - constexpr bool v3 = null == pv; // ok - constexpr bool v4 = qv == pv; // ok - constexpr bool v5 = qv >= pv; // expected-error {{constant expression}} expected-note {{unequal pointers to void}} - constexpr bool v6 = qv > null; // expected-error {{constant expression}} - constexpr bool v7 = qv <= (void*)&s.b; // ok - constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{unequal pointers to void}} -} - -// - an assignment or a compound assignment (5.17); or -namespace Assignment { - int k; - struct T { - int n : (k = 9); // expected-error {{constant expression}} - int m : (k *= 2); // expected-error {{constant expression}} - }; - - struct Literal { - constexpr Literal(const char *name) : name(name) {} - const char *name; - }; - struct Expr { - constexpr Expr(Literal l) : IsLiteral(true), l(l) {} - bool IsLiteral; - union { - Literal l; - // ... - }; - }; - struct MulEq { - constexpr MulEq(Expr a, Expr b) : LHS(a), RHS(b) {} - Expr LHS; - Expr RHS; - }; - constexpr MulEq operator*=(Expr a, Expr b) { return MulEq(a, b); } - Literal a("a"); - Literal b("b"); - MulEq c = a *= b; // ok -} - -// - a throw-expression (15.1) -namespace Throw { - struct S { - int n : (throw "hello", 10); // expected-error {{constant expression}} - }; -} - -// PR9999 -template<unsigned int v> -class bitWidthHolding { -public: - static const - unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1); -}; - -static const int width=bitWidthHolding<255>::width; - -template<bool b> -struct always_false { - static const bool value = false; -}; - -template<bool b> -struct and_or { - static const bool and_value = b && and_or<always_false<b>::value>::and_value; - static const bool or_value = !b || and_or<always_false<b>::value>::or_value; -}; - -static const bool and_value = and_or<true>::and_value; -static const bool or_value = and_or<true>::or_value; - -static_assert(and_value == false, ""); -static_assert(or_value == true, ""); - -namespace rdar13090123 { - typedef __INTPTR_TYPE__ intptr_t; - - constexpr intptr_t f(intptr_t x) { - return (((x) >> 21) * 8); - } - - extern "C" int foo; - - constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be initialized by a constant expression}} \ - // expected-note{{reinterpret_cast}} -} diff --git a/test/CXX/expr/expr.const/p3-0x-nowarn.cpp b/test/CXX/expr/expr.const/p3-0x-nowarn.cpp deleted file mode 100644 index 7d12cedeacf05..0000000000000 --- a/test/CXX/expr/expr.const/p3-0x-nowarn.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-c++11-narrowing -verify %s -// expected-no-diagnostics - -// <rdar://problem/11121178> -void f(int x) { - switch (x) { - case 0x80000001: break; - } -} diff --git a/test/CXX/expr/expr.const/p3-0x.cpp b/test/CXX/expr/expr.const/p3-0x.cpp deleted file mode 100644 index 731e0c312fa13..0000000000000 --- a/test/CXX/expr/expr.const/p3-0x.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s - -// A converted constant expression of type T is a core constant expression, -int nonconst = 8; // expected-note 3 {{here}} -enum NonConstE : unsigned char { NCE = nonconst }; // expected-error {{enumerator value is not a constant expression}} expected-note {{read of non-const}} -template<int = nonconst> struct NonConstT {}; // expected-error {{non-type template argument is not a constant expression}} expected-note {{read of non-const}} -void NonConstF() { - switch (nonconst) { - case nonconst: // expected-error {{case value is not a constant expression}} expected-note {{read of non-const}} - break; - } - return; -} - -// implicitly converted to a prvalue of type T, where the converted expression -// is a literal constant expression - -bool a(int n) { - constexpr char vowels[] = "aeiou"; - switch (n) { - case vowels[0]: - case vowels[1]: - case vowels[2]: - case vowels[3]: - case vowels[4]: - static_assert(!vowels[5], "unexpected number of vowels"); - return true; - } - return false; -} - -// and the implicit conversion sequence contains only -// -// user-defined conversions, -struct S { constexpr operator int() const { return 5; } }; -enum E : unsigned char { E5 = S(), E6, E10 = S() * 2, E1 = E5 / 5 }; - -// lvalue-to-rvalue conversions, -const E e10 = E10; -template<E> struct T {}; -T<e10> s10; - -// integral promotions, -enum class EE { EE32 = ' ', EE65 = 'A', EE1 = (short)1, EE5 = E5 }; - -// integral conversions other than narrowing conversions, -int b(unsigned n) { - switch (n) { - case E6: - case EE::EE32: // expected-error {{not implicitly convertible}} - case (int)EE::EE32: - case 1000: - case (long long)1e10: // expected-error {{case value evaluates to 10000000000, which cannot be narrowed to type 'unsigned int'}} - case -3: // expected-error {{case value evaluates to -3, which cannot be narrowed to type 'unsigned int'}} - return n; - } - return 0; -} -enum class EEE : unsigned short { - a = E6, - b = EE::EE32, // expected-error {{not implicitly convertible}} - c = (int)EE::EE32, - d = 1000, - e = 123456, // expected-error {{enumerator value evaluates to 123456, which cannot be narrowed to type 'unsigned short'}} - f = -3 // expected-error {{enumerator value evaluates to -3, which cannot be narrowed to type 'unsigned short'}} -}; -template<unsigned char> using A = int; -using Int = A<E6>; -using Int = A<EE::EE32>; // expected-error {{not implicitly convertible}} -using Int = A<(int)EE::EE32>; -using Int = A<200>; -using Int = A<1000>; // expected-error {{template argument evaluates to 1000, which cannot be narrowed to type 'unsigned char'}} -using Int = A<-3>; // expected-error {{template argument evaluates to -3, which cannot be narrowed to type 'unsigned char'}} - -// Note, conversions from integral or unscoped enumeration types to bool are -// integral conversions as well as boolean conversions. -// FIXME: Per core issue 1407, this is not correct. -template<typename T, T v> struct Val { static constexpr T value = v; }; -static_assert(Val<bool, E1>::value == 1, ""); // ok -static_assert(Val<bool, '\0'>::value == 0, ""); // ok -static_assert(Val<bool, U'\1'>::value == 1, ""); // ok -static_assert(Val<bool, E5>::value == 1, ""); // expected-error {{5, which cannot be narrowed to type 'bool'}} - -// function pointer conversions [C++17] -void noexcept_false() noexcept(false); -void noexcept_true() noexcept(true); -Val<decltype(&noexcept_false), &noexcept_true> remove_noexcept; -Val<decltype(&noexcept_true), &noexcept_false> add_noexcept; -#if __cplusplus > 201402L -// expected-error@-2 {{value of type 'void (*)() noexcept(false)' is not implicitly convertible to 'void (*)() noexcept'}} -#endif - -// (no other conversions are permitted) -using Int = A<1.0>; // expected-error {{conversion from 'double' to 'unsigned char' is not allowed in a converted constant expression}} -enum B : bool { - True = &a, // expected-error {{conversion from 'bool (*)(int)' to 'bool' is not allowed in a converted constant expression}} - False = nullptr // expected-error {{conversion from 'nullptr_t' to 'bool' is not allowed in a converted constant expression}} -}; -void c() { - // Note, promoted type of switch is 'int'. - switch (bool b = a(5)) { // expected-warning {{boolean value}} - case 0.0f: // expected-error {{conversion from 'float' to 'int' is not allowed in a converted constant expression}} - break; - } -} -template <bool B> int f() { return B; } // expected-note {{candidate template ignored: invalid explicitly-specified argument for template parameter 'B'}} -template int f<&S::operator int>(); // expected-error {{does not refer to a function template}} -template int f<(bool)&S::operator int>(); - -int n = Val<bool, &S::operator int>::value; // expected-error-re {{conversion from 'int (S::*)(){{( __attribute__\(\(thiscall\)\))?}} const' to 'bool' is not allowed in a converted constant expression}} - -namespace NonConstLValue { - struct S { - constexpr operator int() const { return 10; } - }; - S s; // not constexpr - // Under the FDIS, this is not a converted constant expression. - // Under the new proposed wording, it is. - enum E : char { e = s }; -} diff --git a/test/CXX/expr/expr.const/p5-0x.cpp b/test/CXX/expr/expr.const/p5-0x.cpp deleted file mode 100644 index 079870947db09..0000000000000 --- a/test/CXX/expr/expr.const/p5-0x.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -std=c++11 -verify %s - -// If an expression of literal class type is used in a context where an integral -// constant expression is required, then that class type shall have a single -// non-explicit conversion function to an integral or unscoped enumeration type -namespace std_example { - -struct A { - constexpr A(int i) : val(i) { } - constexpr operator int() const { return val; } - constexpr operator long() const { return 43; } -private: - int val; -}; -template<int> struct X { }; -constexpr A a = 42; -X<a> x; // ok, unique conversion to int -int ary[a]; // expected-error {{size of array has non-integer type 'const std_example::A'}} - -} - -struct OK { - constexpr OK() {} - constexpr operator int() const { return 8; } -} constexpr ok; -extern struct Incomplete incomplete; // expected-note 4{{forward decl}} -struct Explicit { - constexpr Explicit() {} - constexpr explicit operator int() const { return 4; } // expected-note 4{{here}} -} constexpr expl; -struct Ambiguous { - constexpr Ambiguous() {} - constexpr operator int() const { return 2; } // expected-note 4{{here}} - constexpr operator long() const { return 1; } // expected-note 4{{here}} -} constexpr ambig; - -constexpr int test_ok = ok; // ok -constexpr int test_explicit(expl); // ok -constexpr int test_ambiguous = ambig; // ok - -static_assert(test_ok == 8, ""); -static_assert(test_explicit == 4, ""); -static_assert(test_ambiguous == 2, ""); - -// [expr.new]p6: Every constant-expression in a noptr-new-declarator shall be -// an integral constant expression -auto new1 = new int[1][ok]; -auto new2 = new int[1][incomplete]; // expected-error {{incomplete}} -auto new3 = new int[1][expl]; // expected-error {{explicit conversion}} -auto new4 = new int[1][ambig]; // expected-error {{ambiguous conversion}} - -// [dcl.enum]p5: If the underlying type is not fixed [...] the initializing -// value [...] shall be an integral constant expression. -enum NotFixed { - enum1 = ok, - enum2 = incomplete, // expected-error {{incomplete}} - enum3 = expl, // expected-error {{explicit conversion}} - enum4 = ambig // expected-error {{ambiguous conversion}} -}; - -// [dcl.align]p2: When the alignment-specifier is of the form -// alignas(assignment-expression), the assignment-expression shall be an -// integral constant expression -alignas(ok) int alignas1; -alignas(incomplete) int alignas2; // expected-error {{incomplete}} -alignas(expl) int alignas3; // expected-error {{explicit conversion}} -alignas(ambig) int alignas4; // expected-error {{ambiguous conversion}} - -// [dcl.array]p1: If the constant-expression is present, it shall be an integral -// constant expression -// FIXME: The VLA recovery results in us giving diagnostics which aren't great -// here. -int array1[ok]; -int array2[incomplete]; // expected-error {{non-integer type}} -int array3[expl]; // expected-error {{non-integer type}} -int array4[ambig]; // expected-error {{non-integer type}} - -// [class.bit]p1: The constasnt-expression shall be an integral constant -// expression -struct Bitfields { - int bitfield1 : ok; - int bitfield2 : incomplete; // expected-error {{incomplete}} - int bitfield3 : expl; // expected-error {{explicit conversion}} - int bitfield4 : ambig; // expected-error {{ambiguous conversion}} -}; diff --git a/test/CXX/expr/expr.const/p6.cpp b/test/CXX/expr/expr.const/p6.cpp deleted file mode 100644 index a8fc7754e7db1..0000000000000 --- a/test/CXX/expr/expr.const/p6.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 -verify %s - -template<typename T> int not_constexpr() { return T::error; } -template<typename T> constexpr int is_constexpr() { return T::error; } // expected-error {{'::'}} - -template<typename T> int not_constexpr_var = T::error; -template<typename T> constexpr int is_constexpr_var = T::error; // expected-error {{'::'}} -template<typename T> const int is_const_var = T::error; // expected-error {{'::'}} -template<typename T> const volatile int is_const_volatile_var = T::error; -template<typename T> T is_dependent_var = T::error; // expected-error {{'::'}} -template<typename T> int &is_reference_var = T::error; // expected-error {{'::'}} -template<typename T> float is_float_var = T::error; - -void test() { - // Do not instantiate functions referenced in unevaluated operands... - (void)sizeof(not_constexpr<long>()); - (void)sizeof(is_constexpr<long>()); - (void)sizeof(not_constexpr_var<long>); - (void)sizeof(is_constexpr_var<long>); - (void)sizeof(is_const_var<long>); - (void)sizeof(is_const_volatile_var<long>); - (void)sizeof(is_dependent_var<long>); - (void)sizeof(is_dependent_var<const long>); - (void)sizeof(is_reference_var<long>); - (void)sizeof(is_float_var<long>); - - // ... but do if they are potentially constant evaluated, and refer to - // constexpr functions or to variables usable in constant expressions. - (void)sizeof(int{not_constexpr<int>()}); - (void)sizeof(int{is_constexpr<int>()}); // expected-note {{instantiation of}} - (void)sizeof(int{not_constexpr_var<int>}); - (void)sizeof(int{is_constexpr_var<int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_const_var<int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_const_volatile_var<int>}); - (void)sizeof(int{is_dependent_var<int>}); - (void)sizeof(int{is_dependent_var<const int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_reference_var<int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_float_var<int>}); // expected-error {{cannot be narrowed}} expected-note {{cast}} -} diff --git a/test/CXX/expr/expr.mptr.oper/p5.cpp b/test/CXX/expr/expr.mptr.oper/p5.cpp deleted file mode 100644 index c26b30d43da19..0000000000000 --- a/test/CXX/expr/expr.mptr.oper/p5.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct X0 { - void f0(); - void f1() const; - void f2() volatile; - void f3() const volatile; -}; - -void test_object_cvquals(void (X0::*pm)(), - void (X0::*pmc)() const, - void (X0::*pmv)() volatile, - void (X0::*pmcv)() const volatile, - X0 *p, - const X0 *pc, - volatile X0 *pv, - const volatile X0 *pcv, - X0 &o, - const X0 &oc, - volatile X0 &ov, - const volatile X0 &ocv) { - (p->*pm)(); - (p->*pmc)(); - (p->*pmv)(); - (p->*pmcv)(); - - (pc->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}} - (pc->*pmc)(); - (pc->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (pc->*pmcv)(); - - (pv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}} - (pv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (pv->*pmv)(); - (pv->*pmcv)(); - - (pcv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}} - (pcv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (pcv->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (pcv->*pmcv)(); - - (o.*pm)(); - (o.*pmc)(); - (o.*pmv)(); - (o.*pmcv)(); - - (oc.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}} - (oc.*pmc)(); - (oc.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (oc.*pmcv)(); - - (ov.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}} - (ov.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (ov.*pmv)(); - (ov.*pmcv)(); - - (ocv.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}} - (ocv.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (ocv.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (ocv.*pmcv)(); -} diff --git a/test/CXX/expr/expr.mptr.oper/p6-0x.cpp b/test/CXX/expr/expr.mptr.oper/p6-0x.cpp deleted file mode 100644 index b1823e59fff28..0000000000000 --- a/test/CXX/expr/expr.mptr.oper/p6-0x.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct X { }; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); -template<typename T> T prvalue(); - -// In a .* expression whose object expression is an rvalue, the -// program is ill-formed if the second operand is a pointer to member -// function with ref-qualifier &. In a ->* expression or in a .* -// expression whose object expression is an lvalue, the program is -// ill-formed if the second operand is a pointer to member function -// with ref-qualifier &&. -void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &, - int (X::*r_pmf)(int) &&) { - // No ref-qualifier. - (lvalue<X>().*pmf)(17); - (xvalue<X>().*pmf)(17); - (prvalue<X>().*pmf)(17); - (xp->*pmf)(17); - - // Lvalue ref-qualifier. - (lvalue<X>().*l_pmf)(17); - (xvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}} - (prvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}} - (xp->*l_pmf)(17); - - // Rvalue ref-qualifier. - (lvalue<X>().*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}} - (xvalue<X>().*r_pmf)(17); - (prvalue<X>().*r_pmf)(17); - (xp->*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}} -} diff --git a/test/CXX/expr/expr.post/expr.call/p7-0x.cpp b/test/CXX/expr/expr.post/expr.call/p7-0x.cpp deleted file mode 100644 index fbb685c5a4488..0000000000000 --- a/test/CXX/expr/expr.post/expr.call/p7-0x.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct X1 { - X1(); -}; - -struct X2 { - X2(); - ~X2(); -}; - -struct X3 { - X3(const X3&) = default; -}; - -struct X4 { - X4(const X4&) = default; - X4(X4&); -}; - -void vararg(...); - -void g(); - -void f(X1 x1, X2 x2, X3 x3, X4 x4) { - vararg(x1); // OK - vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}} - vararg(x3); // OK - vararg(x4); // expected-error{{cannot pass object of non-trivial type 'X4' through variadic function; call will abort at runtime}} - - vararg(g()); // expected-error{{cannot pass expression of type 'void' to variadic function}} - vararg({1, 2, 3}); // expected-error{{cannot pass initializer list to variadic function}} -} - - -namespace PR11131 { - struct S; - - S &getS(); - - int f(...); - - void g() { - (void)sizeof(f(getS())); - } -} diff --git a/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp deleted file mode 100644 index f4c0f1ae1229c..0000000000000 --- a/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// The result of the expression const_cast<T>(v) is of type T. If T is -// an lvalue reference to object type, the result is an lvalue; if T -// is an rvalue reference to object type, the result is an xvalue;. - -unsigned int f(int); - -struct X {}; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); -template<typename T> T prvalue(); - -void test_classification(const int *ptr, X x) { - int *&&ptr0 = const_cast<int *&&>(ptr); - int *&&ptr1 = const_cast<int *&&>(xvalue<const int*>()); - int *&&ptr2 = const_cast<int *&&>(prvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&&'}} - X &&ptr3 = const_cast<X&&>(x); - X &&ptr4 = const_cast<X&&>(xvalue<X>()); - X &&ptr5 = const_cast<X&&>(prvalue<X>()); - - int *&ptr6 = const_cast<int *&>(ptr); - int *&ptr7 = const_cast<int *&>(xvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&'}} - int *&ptr8 = const_cast<int *&>(prvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&'}} - X &ptr9 = const_cast<X&>(x); - X &ptrA = const_cast<X&>(xvalue<X>()); // expected-error {{const_cast from rvalue to reference type 'X &'}} - X &ptrB = const_cast<X&>(prvalue<X>()); // expected-error {{const_cast from rvalue to reference type 'X &'}} -} - -struct A { - volatile unsigned ubf : 4; - volatile unsigned uv; - volatile int sv; - void foo(); - bool pred(); -}; - -void test(A &a) { - unsigned &t0 = const_cast<unsigned&>(a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t1 = const_cast<unsigned&>(a.foo(), a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t2 = const_cast<unsigned&>(a.pred() ? a.ubf : a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t3 = const_cast<unsigned&>(a.pred() ? a.ubf : a.uv); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t4 = const_cast<unsigned&>(a.pred() ? a.ubf : a.sv); // expected-error {{const_cast from rvalue to reference type}} -} diff --git a/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp b/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp deleted file mode 100644 index cddd5cf25e3bc..0000000000000 --- a/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct X { virtual ~X(); }; -struct Y : public X { }; -struct Z; // expected-note{{forward declaration of 'Z'}} - -void test(X &x, Y &y, Z &z) { - // If T is an rvalue reference type, v shall be an expression having - // a complete class type, and the result is an xvalue of the type - // referred to by T. - Y &&yr0 = dynamic_cast<Y&&>(x); - Y &&yr1 = dynamic_cast<Y&&>(static_cast<X&&>(x)); - Y &&yr2 = dynamic_cast<Y&&>(z); // expected-error{{'Z' is an incomplete type}} -} diff --git a/test/CXX/expr/expr.post/expr.ref/p3.cpp b/test/CXX/expr/expr.post/expr.ref/p3.cpp deleted file mode 100644 index db33c014eeb73..0000000000000 --- a/test/CXX/expr/expr.post/expr.ref/p3.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -verify -fsyntax-only %s -// expected-no-diagnostics - -template<typename T> struct Node { - int lhs; - void splay( ) - { - Node<T> n[1]; - (void)n->lhs; - } -}; - -void f() { - Node<int> n; - return n.splay(); -} diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp deleted file mode 100644 index 212adc8c2bd43..0000000000000 --- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// If T is an lvalue reference type or an rvalue reference to function -// type, the result is an lvalue; if T is an rvalue reference to -// object type, the result is an xvalue; - -unsigned int f(int); - -template<typename T> T&& xvalue(); -void test_classification(char *ptr) { - int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f); - int &&ir0 = reinterpret_cast<int &&>(*ptr); - int &&ir1 = reinterpret_cast<int &&>(0); // expected-error {{rvalue to reference type}} - int &&ir2 = reinterpret_cast<int &&>('a'); // expected-error {{rvalue to reference type}} - int &&ir3 = reinterpret_cast<int &&>(xvalue<char>()); - // Per DR1268, reinterpret_cast can convert between lvalues and xvalues. - int &ir4 = reinterpret_cast<int &>(xvalue<char>()); - int &&ir5 = reinterpret_cast<int &&>(*ptr); -} diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp deleted file mode 100644 index b03db27ee1d06..0000000000000 --- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 %s -verify - -// The reinterpret_cast operator shall not cast away constness. -struct X {}; -struct Y {}; -void f(const int * X::* Y::* *p) { - // This applies for similar types... - (void)reinterpret_cast<int * X::* Y::* *>(p); // expected-error {{casts away qualifiers}} - // ... and for cases where the base type is different ... - (void)reinterpret_cast<float * X::* Y::* *>(p); // expected-error {{casts away qualifiers}} - // ... and for cases where pointers to members point to members of different classes ... - (void)reinterpret_cast<int * Y::* X::* *>(p); // expected-error {{casts away qualifiers}} - // ... and even for cases where the path is wholly different! - // (Though we accept such cases as an extension.) - (void)reinterpret_cast<double Y::* X::* * *>(p); // expected-warning {{casts away qualifiers}} - - // If qualifiers are added, we need a 'const' at every level above. - (void)reinterpret_cast<const volatile double Y::* X::* * *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*const X::*const **>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*const X::**const *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*X::*const *const *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*const X::*const *const *>(p); // ok - - (void)reinterpret_cast<const double Y::*volatile X::**const *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const double Y::*volatile X::*const *const *>(p); // ok -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp deleted file mode 100644 index 830ccda245baa..0000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to -// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). -struct A { }; -struct B : A { }; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); - -void test(A &a, B &b) { - A &&ar0 = static_cast<A&&>(a); - A &&ar1 = static_cast<A&&>(b); - A &&ar2 = static_cast<A&&>(lvalue<A>()); - A &&ar3 = static_cast<A&&>(lvalue<B>()); - A &&ar4 = static_cast<A&&>(xvalue<A>()); - A &&ar5 = static_cast<A&&>(xvalue<B>()); - const A &&ar6 = static_cast<const A&&>(a); - const A &&ar7 = static_cast<const A&&>(b); - const A &&ar8 = static_cast<const A&&>(lvalue<A>()); - const A &&ar9 = static_cast<const A&&>(lvalue<B>()); - const A &&ar10 = static_cast<const A&&>(xvalue<A>()); - const A &&ar11 = static_cast<const A&&>(xvalue<B>()); -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp deleted file mode 100644 index 8701a00d5cf01..0000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - - -// p3 -// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to -// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). -// p4 -// Otherwise, an expression e can be explicitly converted to a type T using a -// static_cast of the form static_cast<T>(e) if the declaration T t(e); is -// well-formed, for some invented temporary variable t (8.5). [...] -struct A { }; -struct B : A { }; - -struct C { explicit operator A&&(); }; -struct D { operator B(); }; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); -template <typename T> T prvalue(); - -void test(A &a, B &b) { - A &&ar0 = static_cast<A&&>(prvalue<A>()); - A &&ar1 = static_cast<A&&>(prvalue<B>()); - A &&ar2 = static_cast<A&&>(lvalue<C>()); - A &&ar3 = static_cast<A&&>(xvalue<C>()); - A &&ar4 = static_cast<A&&>(prvalue<C>()); - A &&ar5 = static_cast<A&&>(lvalue<D>()); - A &&ar6 = static_cast<A&&>(xvalue<D>()); - A &&ar7 = static_cast<A&&>(prvalue<D>()); - - A &&ar8 = static_cast<A&&>(prvalue<const A>()); // expected-error {{binding value of type 'const A' to reference to type 'A' drops 'const' qualifier}} - A &&ar9 = static_cast<A&&>(lvalue<const A>()); // expected-error {{cannot cast from lvalue of type 'const A'}} - A &&ar10 = static_cast<A&&>(xvalue<const A>()); // expected-error {{cannot cast from rvalue of type 'const A'}} - - const A &&ar11 = static_cast<const A&&>(prvalue<A>()); - const A &&ar12 = static_cast<const A&&>(prvalue<B>()); - const A &&ar13 = static_cast<const A&&>(lvalue<C>()); - const A &&ar14 = static_cast<const A&&>(xvalue<C>()); - const A &&ar15 = static_cast<const A&&>(prvalue<C>()); - const A &&ar16 = static_cast<const A&&>(lvalue<D>()); - - const A &&ar17 = static_cast<const A&&>(prvalue<A const volatile>()); // expected-error {{binding value of type 'const volatile A' to reference to type 'const A' drops 'volatile' qualifier}} -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p7.cpp b/test/CXX/expr/expr.post/expr.static.cast/p7.cpp deleted file mode 100644 index fd8e478b5193b..0000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p7.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -fcxx-exceptions - -void (*p)() noexcept; -void (*q)(); - -void f() { - // FIXME: This seems like a bad rule. - p = static_cast<decltype(p)>(q); // expected-error {{not allowed}} - q = static_cast<decltype(q)>(p); -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp deleted file mode 100644 index c624c7e3f2f98..0000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -enum class EC { ec1 }; - -void test0(EC ec) { - (void)static_cast<bool>(ec); - (void)static_cast<bool>(EC::ec1); - (void)static_cast<char>(ec); - (void)static_cast<char>(EC::ec1); - (void)static_cast<int>(ec); - (void)static_cast<int>(EC::ec1); - (void)static_cast<unsigned long>(ec); - (void)static_cast<unsigned long>(EC::ec1); - (void)static_cast<float>(ec); - (void)static_cast<float>(EC::ec1); - (void)static_cast<double>(ec); - (void)static_cast<double>(EC::ec1); -} - -namespace PR9107 { - enum E {}; - template <class _Tp> inline _Tp* addressof(_Tp& __x) { - return (_Tp*)&(char&)__x; - } - void test() { - E a; - addressof(a); - } -} diff --git a/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp b/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp deleted file mode 100644 index 568c61b95fb99..0000000000000 --- a/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -struct foo { - foo(); - foo(int); -}; - -int func(foo& f) { - decltype(foo())(); - f = (decltype(foo()))5; - return decltype(3)(5); -} diff --git a/test/CXX/expr/expr.post/expr.type.conv/p1.cpp b/test/CXX/expr/expr.post/expr.type.conv/p1.cpp deleted file mode 100644 index f3608bc378bc7..0000000000000 --- a/test/CXX/expr/expr.post/expr.type.conv/p1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -template<typename T> struct A { // expected-note 2{{candidate}} - T t, u; -}; -template<typename T> A(T, T) -> A<T>; // expected-note {{deduced conflicting types for parameter 'T'}} -template<typename T> A(A<T>) -> A<T>; // expected-note {{requires 1 argument, but 2 were provided}} - -A a = A{1, 2}; -A b = A{3, 4.0}; // expected-error {{no viable constructor or deduction guide}} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp deleted file mode 100644 index 249c976460897..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct S { - int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}} - int *m = &n; // ok - - int n = f(); // ok - int f(); -}; - -int i = sizeof(S::m); // ok -int j = sizeof(S::m + 42); // ok - - -struct T { - int n; - static void f() { - int a[n]; // expected-error {{invalid use of member 'n' in static member function}} - int b[sizeof n]; // ok - } -}; - -// Make sure the rule for unevaluated operands works correctly with typeid. -namespace std { - class type_info; -} -class Poly { virtual ~Poly(); }; -const std::type_info& k = typeid(S::m); -const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}} -const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m)); - -namespace PR11956 { - struct X { char a; }; - struct Y { int f() { return sizeof(X::a); } }; // ok - - struct A { enum E {} E; }; - struct B { int f() { return sizeof(A::E); } }; // ok -} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp deleted file mode 100644 index 0e948ce00031e..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -struct A { - int &f(int*); - float &f(int*) const noexcept; - - int *ptr; - auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(this->ptr)); - auto g2() const noexcept(noexcept(f((*this).ptr))) -> decltype(f(ptr)); -}; - -void testA(A &a) { - int &ir = a.g1(); - float &fr = a.g2(); - static_assert(!noexcept(a.g1()), "exception-specification failure"); - static_assert(noexcept(a.g2()), "exception-specification failure"); -} - -struct B { - char g(); - template<class T> auto f(T t) -> decltype(t + g()) - { return t + g(); } -}; - -template auto B::f(int t) -> decltype(t + g()); - -template<typename T> -struct C { - int &f(T*); - float &f(T*) const noexcept; - - T* ptr; - auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(ptr)); - auto g2() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(ptr)); - auto g3() noexcept(noexcept(f(this->ptr))) -> decltype(f((*this).ptr)); - auto g4() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(this->ptr)); - auto g5() noexcept(noexcept(this->f(ptr))) -> decltype(this->f(ptr)); - auto g6() const noexcept(noexcept(this->f(((this))->ptr))) -> decltype(this->f(ptr)); - auto g7() noexcept(noexcept(this->f(this->ptr))) -> decltype(this->f((*this).ptr)); - auto g8() const noexcept(noexcept(this->f(((this))->ptr))) -> decltype(this->f(this->ptr)); -}; - -void test_C(C<int> ci) { - int &ir = ci.g1(); - float &fr = ci.g2(); - int &ir2 = ci.g3(); - float &fr2 = ci.g4(); - int &ir3 = ci.g5(); - float &fr3 = ci.g6(); - int &ir4 = ci.g7(); - float &fr4 = ci.g8(); - static_assert(!noexcept(ci.g1()), "exception-specification failure"); - static_assert(noexcept(ci.g2()), "exception-specification failure"); - static_assert(!noexcept(ci.g3()), "exception-specification failure"); - static_assert(noexcept(ci.g4()), "exception-specification failure"); - static_assert(!noexcept(ci.g5()), "exception-specification failure"); - static_assert(noexcept(ci.g6()), "exception-specification failure"); - static_assert(!noexcept(ci.g7()), "exception-specification failure"); - static_assert(noexcept(ci.g8()), "exception-specification failure"); -} - -namespace PR14263 { - template<typename T> struct X { - void f(); - T f() const; - - auto g() -> decltype(this->f()) { return f(); } - auto g() const -> decltype(this->f()) { return f(); } - }; - template struct X<int>; -} - -namespace PR10036 { - template <class I> - void - iter_swap(I x, I y) noexcept; - - template <class T> - class A - { - T t_; - public: - void swap(A& a) noexcept(noexcept(iter_swap(&t_, &a.t_))); - }; - - void test() { - A<int> i, j; - i.swap(j); - } -} - -namespace PR15290 { - template<typename T> - class A { - T v_; - friend int add_to_v(A &t) noexcept(noexcept(v_ + 42)) - { - return t.v_ + 42; - } - }; - void f() - { - A<int> t; - add_to_v(t); - } -} - -namespace Static { - struct X1 { - int m; - // FIXME: This should be accepted. - static auto f() -> decltype(m); // expected-error{{'this' cannot be implicitly used in a static member function declaration}} - static auto g() -> decltype(this->m); // expected-error{{'this' cannot be used in a static member function declaration}} - - static int h(); - - static int i() noexcept(noexcept(m + 2)); // expected-error{{'this' cannot be implicitly used in a static member function declaration}} - }; - - auto X1::h() -> decltype(m) { return 0; } // expected-error{{'this' cannot be implicitly used in a static member function declaration}} - - template<typename T> - struct X2 { - int m; - - T f(T*); - static T f(int); - - auto g(T x) -> decltype(f(x)) { return 0; } - }; - - void test_X2() { - X2<int>().g(0); - } -} - -namespace PR12564 { - struct Base { - void bar(Base&) {} - }; - - struct Derived : Base { - void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} - }; -} - -namespace rdar13473493 { - template <typename F> - class wrap - { - public: - template <typename... Args> - auto operator()(Args&&... args) const -> decltype(wrapped(args...)) // expected-note{{candidate template ignored: substitution failure [with Args = <int>]: use of undeclared identifier 'wrapped'}} - { - return wrapped(args...); - } - - private: - F wrapped; - }; - - void test(wrap<int (*)(int)> w) { - w(5); // expected-error{{no matching function for call to object of type 'wrap<int (*)(int)>'}} - } -} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp deleted file mode 100644 index 54b2ff52895a0..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct S { - S *p = this; // ok - decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}} - - int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}} - int sz = sizeof(this); // ok - - typedef auto f() -> decltype(this); // expected-error {{invalid use of 'this' outside of a non-static member function}} -}; - -namespace CaptureThis { - struct X { - int n = 10; - int m = [&]{return n + 1; }(); - int o = [&]{return this->m + 1; }(); - int p = [&]{return [&](int x) { return this->m + x;}(o); }(); - }; - - X x; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp deleted file mode 100644 index b5cd98828cc92..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct global { -}; - -namespace PR10127 { - struct outer { - struct middle { - struct inner { - int func(); - int i; - }; - struct inner2 { - }; - struct inner3 { - }; - int mfunc(); - }; - typedef int td_int; - }; - - struct str { - operator decltype(outer::middle::inner()) (); - operator decltype(outer::middle())::inner2 (); - operator decltype(outer())::middle::inner3 (); - str(int (decltype(outer::middle::inner())::*n)(), - int (decltype(outer::middle())::inner::*o)(), - int (decltype(outer())::middle::inner::*p)()); - }; - - decltype(outer::middle::inner()) a; - void scope() { - a.decltype(outer::middle())::mfunc(); // expected-error{{'PR10127::outer::middle::mfunc' is not a member of class 'decltype(outer::middle::inner())'}} - a.decltype(outer::middle::inner())::func(); - a.decltype(outer::middle())::inner::func(); - a.decltype(outer())::middle::inner::func(); - - a.decltype(outer())::middle::inner::~inner(); - - decltype(outer())::middle::inner().func(); - } - decltype(outer::middle())::inner b; - decltype(outer())::middle::inner c; - decltype(outer())::fail d; // expected-error{{no type named 'fail' in 'PR10127::outer'}} - decltype(outer())::fail::inner e; // expected-error{{no member named 'fail' in 'PR10127::outer'}} - decltype()::fail f; // expected-error{{expected expression}} - decltype()::middle::fail g; // expected-error{{expected expression}} - - decltype(int()) h; - decltype(int())::PR10127::outer i; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or enumeration}} - decltype(int())::global j; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or enumeration}} - - outer::middle k = decltype(outer())::middle(); - outer::middle::inner l = decltype(outer())::middle::inner(); - - template<typename T> - struct templ { - typename decltype(T())::middle::inner x; // expected-error{{type 'decltype(int())' (aka 'int') cannot be used prior to '::' because it has no members}} - }; - - template class templ<int>; // expected-note{{in instantiation of template class 'PR10127::templ<int>' requested here}} - template class templ<outer>; - - enum class foo { - bar, - baz - }; - - foo m = decltype(foo::bar)::baz; - - enum E { - }; - struct bar { - enum E : decltype(outer())::td_int(4); - enum F : decltype(outer())::td_int; - enum G : decltype; // expected-error{{expected '(' after 'decltype'}} - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm deleted file mode 100644 index 24ce2cd6c198d..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fblocks -emit-llvm -o - -triple x86_64-apple-darwin11.3 %s | FileCheck %s - -namespace PR12746 { - // CHECK: define zeroext i1 @_ZN7PR127462f1EPi - bool f1(int *x) { - // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*) - bool (^outer)() = ^ { - auto inner = [&]() -> bool { - return x == 0; - }; - return inner(); - }; - return outer(); - } - - // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke - // CHECK: call zeroext i1 @"_ZZZN7PR127462f1EPiEUb_ENK3$_0clEv" - - bool f2(int *x) { - auto outer = [&]() -> bool { - bool (^inner)() = ^ { - return x == 0; - }; - return inner(); - }; - return outer(); - } -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm deleted file mode 100644 index 96e8fcd8d3717..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm +++ /dev/null @@ -1,144 +0,0 @@ -// RUN: %clang_cc1 -triple i686-pc-linux -std=c++11 -fblocks %s -verify - -void block_capture_errors() { - __block int var; // expected-note 2{{'var' declared here}} - (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} - - (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} -} - -void conversion_to_block(int captured) { - int (^b1)(int) = [=](int x) { return x + captured; }; - - const auto lambda = [=](int x) { return x + captured; }; - int (^b2)(int) = lambda; -} - -template<typename T> -class ConstCopyConstructorBoom { -public: - ConstCopyConstructorBoom(ConstCopyConstructorBoom&); - - ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) { - T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} - } - - void foo() const; -}; - -void conversion_to_block_init(ConstCopyConstructorBoom<int> boom, - ConstCopyConstructorBoom<float> boom2) { - const auto& lambda1([=] { boom.foo(); }); // okay - - const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}} - void (^block)(void) = lambda2; -} - - -void nesting() { - int array[7]; // expected-note 2{{'array' declared here}} - [=] () mutable { - [&] { - ^ { - int i = array[2]; - i += array[3]; - }(); - }(); - }(); - - [&] { - [=] () mutable { - ^ { - int i = array[2]; // expected-error{{cannot refer to declaration with an array type inside block}} - i += array[3]; // expected-error{{cannot refer to declaration with an array type inside block}} - }(); - }(); - }(); -} - -namespace overloading { - void bool_conversion() { - if ([](){}) { - } - - bool b = []{}; - b = (bool)[]{}; - } - - void conversions() { - int (*fp)(int) = [](int x) { return x + 1; }; - fp = [](int x) { return x + 1; }; - - typedef int (*func_ptr)(int); - fp = (func_ptr)[](int x) { return x + 1; }; - - int (^bp)(int) = [](int x) { return x + 1; }; - bp = [](int x) { return x + 1; }; - - typedef int (^block_ptr)(int); - bp = (block_ptr)[](int x) { return x + 1; }; - } - - int &accept_lambda_conv(int (*fp)(int)); - float &accept_lambda_conv(int (^bp)(int)); - - void call_with_lambda() { - int &ir = accept_lambda_conv([](int x) { return x + 1; }); - } - - template<typename T> using id = T; - - auto a = [](){}; - struct C : decltype(a) { - using decltype(a)::operator id<void(*)()>; - private: - using decltype(a)::operator id<void(^)()>; - } extern c; - - struct D : decltype(a) { - using decltype(a)::operator id<void(^)()>; - private: - using decltype(a)::operator id<void(*)()>; // expected-note {{here}} - } extern d; - - bool r1 = c; - bool r2 = d; // expected-error {{private}} -} - -namespace PR13117 { - struct A { - template<typename ... Args> static void f(Args...); - - template<typename ... Args> static void f1() - { - (void)^(Args args) { // expected-error{{block contains unexpanded parameter pack 'Args'}} - }; - } - - template<typename ... Args> static void f2() - { - // FIXME: Allow this. - f( - ^(Args args) // expected-error{{block contains unexpanded parameter pack 'Args'}} - { } - ... // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - ); - } - - template<typename ... Args> static void f3() - { - (void)[](Args args) { // expected-error{{expression contains unexpanded parameter pack 'Args'}} - }; - } - - template<typename ... Args> static void f4() - { - f([](Args args) { } ...); - } - }; - - void g() { - A::f1<int, int>(); - A::f2<int, int>(); - } -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp deleted file mode 100644 index 9b0a9ad8c2573..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -void defargs() { - auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; }; - int i1 = l1(1); - int i2 = l1(1, 2); - int i3 = l1(1, 2, 3); -} - - -void defargs_errors() { - auto l1 = [](int i, - int j = 17, - int k) { }; // expected-error{{missing default argument on parameter 'k'}} - - auto l2 = [](int i, int j = i) {}; // expected-error{{default argument references parameter 'i'}} - - int foo; - auto l3 = [](int i = foo) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}} -} - -struct NonPOD { - NonPOD(); - NonPOD(const NonPOD&); - ~NonPOD(); -}; - -struct NoDefaultCtor { - NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}} \ - // expected-note{{candidate constructor not viable: requires 1 argument, but 0 were provided}} - ~NoDefaultCtor(); -}; - -template<typename T> -void defargs_in_template_unused(T t) { - auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} - l1(t); -} - -template void defargs_in_template_unused(NonPOD); -template void defargs_in_template_unused(NoDefaultCtor); // expected-note{{in instantiation of function template specialization 'defargs_in_template_unused<NoDefaultCtor>' requested here}} - -template<typename T> -void defargs_in_template_used() { - auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} \ - // expected-note{{candidate function not viable: requires single argument 'value', but no arguments were provided}} \ - // expected-note{{conversion candidate of type 'void (*)(const NoDefaultCtor &)'}} - l1(); // expected-error{{no matching function for call to object of type '(lambda at }} -} - -template void defargs_in_template_used<NonPOD>(); -template void defargs_in_template_used<NoDefaultCtor>(); // expected-note{{in instantiation of function template specialization}} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp deleted file mode 100644 index 245e27042be35..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -int GlobalVar; // expected-note {{declared here}} - -namespace N { - int AmbiguousVar; // expected-note {{candidate}} -} -int AmbiguousVar; // expected-note {{candidate}} -using namespace N; - -class X0 { - int Member; - - static void Overload(int); - void Overload(); - virtual X0& Overload(float); - - void explicit_capture() { - int variable; // expected-note {{declared here}} - (void)[&Overload] () {}; // expected-error {{does not name a variable}} - (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} - (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}} - (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} - } -}; - -void test_reaching_scope() { - int local; // expected-note{{declared here}} - static int local_static; // expected-note{{'local_static' declared here}} - (void)[=]() { - struct InnerLocal { - void member() { - (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} - local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}} - return 0; - }; - } - }; - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp deleted file mode 100644 index 63e51a7614490..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -std=c++1y %s -verify - -const char *has_no_member = [x("hello")] {}.x; // expected-error {{no member named 'x'}} - -double f; -auto with_float = [f(1.0f)] { - using T = decltype(f); - using T = float; -}; -auto with_float_2 = [&f(f)] { // ok, refers to outer f - using T = decltype(f); - using T = double&; -}; - -// Within the lambda-expression's compound-statement, -// the identifier in the init-capture hides any declaration -// of the same name in scopes enclosing the lambda-expression. -void hiding() { - char c; - (void) [c("foo")] { - static_assert(sizeof(c) == sizeof(const char*), ""); - }; - (void) [c("bar")] () -> decltype(c) { // outer c, not init-capture - return "baz"; // expected-error {{cannot initialize}} - }; -} - -struct ExplicitCopy { - ExplicitCopy(); // expected-note 2{{not viable}} - explicit ExplicitCopy(const ExplicitCopy&); -}; -auto init_kind_1 = [ec(ExplicitCopy())] {}; -auto init_kind_2 = [ec = ExplicitCopy()] {}; // expected-error {{no matching constructor}} - -template<typename T> void init_kind_template() { - auto init_kind_1 = [ec(T())] {}; - auto init_kind_2 = [ec = T()] {}; // expected-error {{no matching constructor}} -} -template void init_kind_template<int>(); -template void init_kind_template<ExplicitCopy>(); // expected-note {{instantiation of}} - -void void_fn(); -int overload_fn(); -int overload_fn(int); - -auto bad_init_1 = [a()] {}; // expected-error {{expected expression}} -auto bad_init_2 = [a(1, 2)] {}; // expected-error {{initializer for lambda capture 'a' contains multiple expressions}} -auto bad_init_3 = [&a(void_fn())] {}; // expected-error {{cannot form a reference to 'void'}} -auto bad_init_4 = [a(void_fn())] {}; // expected-error {{has incomplete type 'void'}} -auto bad_init_5 = [a(overload_fn)] {}; // expected-error {{cannot deduce type for lambda capture 'a' from initializer of type '<overloaded function}} -auto bad_init_6 = [a{overload_fn}] {}; // expected-error {{cannot deduce type for lambda capture 'a' from initializer list}} -auto bad_init_7 = [a{{1}}] {}; // expected-error {{cannot deduce type for lambda capture 'a' from nested initializer list}} - -template<typename...T> void pack_1(T...t) { (void)[a(t...)] {}; } // expected-error {{initializer missing for lambda capture 'a'}} -template void pack_1<>(); // expected-note {{instantiation of}} - -// FIXME: Might need lifetime extension for the temporary here. -// See DR1695. -auto a = [a(4), b = 5, &c = static_cast<const int&&>(0)] { - static_assert(sizeof(a) == sizeof(int), ""); - static_assert(sizeof(b) == sizeof(int), ""); - using T = decltype(c); - using T = const int &; -}; -auto b = [a{0}] {}; // OK, per N3922 - -struct S { S(); S(S&&); }; -template<typename T> struct remove_reference { typedef T type; }; -template<typename T> struct remove_reference<T&> { typedef T type; }; -template<typename T> decltype(auto) move(T &&t) { return static_cast<typename remove_reference<T>::type&&>(t); } -auto s = [s(move(S()))] {}; - -template<typename T> T instantiate_test(T t) { - [x(&t)]() { *x = 1; } (); // expected-error {{assigning to 'const char *'}} - return t; -} -int instantiate_test_1 = instantiate_test(0); -const char *instantiate_test_2 = instantiate_test("foo"); // expected-note {{here}} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp deleted file mode 100644 index d265dd757398e..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -void test_reaching_scope() { - int local; // expected-note{{declared here}} - static int local_static; - (void)[=]() { - struct InnerLocal { - void member() { - (void)[=]() { - return local + // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} - local_static; - }; - } - }; - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp deleted file mode 100644 index e7fce11abc5e3..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - -void odr_used() { - int i = 17; - [i]{}(); -} - -struct ReachingThis { - static void static_foo() { - (void)[this](){}; // expected-error{{'this' cannot be captured in this context}} - - struct Local { - int i; - - void bar() { - (void)[this](){}; - (void)[&](){i = 7; }; - } - }; - } - - void foo() { - (void)[this](){}; - - struct Local { - int i; - - static void static_bar() { - (void)[this](){}; // expected-error{{'this' cannot be captured in this context}} - (void)[&](){i = 7; }; // expected-error{{invalid use of member 'i' in static member function}} - } - }; - } -}; - -void immediately_enclosing(int i) { // expected-note{{'i' declared here}} - [i]() { - [i] {}(); - }(); - - [=]() { - [i] {}(); - }(); - - []() { // expected-note{{lambda expression begins here}} - [i] {}(); // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} - }(); -} - -void f1(int i) { // expected-note{{declared here}} - int const N = 20; - auto m1 = [=]{ - int const M = 30; - auto m2 = [i]{ - int x[N][M]; - x[0][0] = i; - }; - (void)N; - (void)M; - (void)m2; - }; - struct s1 { - int f; - void work(int n) { // expected-note{{declared here}} - int m = n*n; - int j = 40; // expected-note{{declared here}} - auto m3 = [this,m] { // expected-note 3{{lambda expression begins here}} - auto m4 = [&,j] { // expected-error{{variable 'j' cannot be implicitly captured in a lambda with no capture-default specified}} - int x = n; // expected-error{{variable 'n' cannot be implicitly captured in a lambda with no capture-default specified}} - x += m; - x += i; // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} - x += f; - }; - }; - } - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp deleted file mode 100644 index b55beb7d4ed78..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - -void f2() { - int i = 1; - void g1(int = ([i]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}} - void g2(int = ([i]{ return 0; })()); // expected-error{{lambda expression in default argument cannot capture any entity}} - void g3(int = ([=]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}} - void g4(int = ([=]{ return 0; })()); - void g5(int = ([]{ return sizeof i; })()); -} - -namespace lambda_in_default_args { - int f(int = [] () -> int { int n; return ++n; } ()); - template<typename T> T g(T = [] () -> T { T n; return ++n; } ()); - int k = f() + g<int>(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp deleted file mode 100644 index 7fc86e8109270..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -template<typename T> void capture(const T&); - -class NonCopyable { - NonCopyable(const NonCopyable&); // expected-note 2 {{implicitly declared private here}} -public: - void foo() const; -}; - -class NonConstCopy { -public: - NonConstCopy(NonConstCopy&); // expected-note{{would lose const}} -}; - -void capture_by_copy(NonCopyable nc, NonCopyable &ncr, const NonConstCopy nco) { - (void)[nc] { }; // expected-error{{capture of variable 'nc' as type 'NonCopyable' calls private copy constructor}} - (void)[=] { // expected-error{{capture of variable 'ncr' as type 'NonCopyable' calls private copy constructor}} - ncr.foo(); - }(); - - [nco] {}(); // expected-error{{no matching constructor for initialization of 'const NonConstCopy'}} -} - -struct NonTrivial { - NonTrivial(); - NonTrivial(const NonTrivial &); - ~NonTrivial(); -}; - -struct CopyCtorDefault { - CopyCtorDefault(); - CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial()); - - void foo() const; -}; - -void capture_with_default_args(CopyCtorDefault cct) { - (void)[=] () -> void { cct.foo(); }; -} - -struct ExpectedArrayLayout { - CopyCtorDefault array[3]; -}; - -void capture_array() { - CopyCtorDefault array[3]; - auto x = [=]() -> void { - capture(array[0]); - }; - static_assert(sizeof(x) == sizeof(ExpectedArrayLayout), "layout mismatch"); -} - -// Check for the expected non-static data members. - -struct ExpectedLayout { - char a; - short b; -}; - -void test_layout(char a, short b) { - auto x = [=] () -> void { - capture(a); - capture(b); - }; - static_assert(sizeof(x) == sizeof(ExpectedLayout), "Layout mismatch!"); -} - -struct ExpectedThisLayout { - ExpectedThisLayout* a; - void f() { - auto x = [this]() -> void {}; - static_assert(sizeof(x) == sizeof(ExpectedThisLayout), "Layout mismatch!"); - } -}; - -struct CaptureArrayAndThis { - int value; - - void f() { - int array[3]; - [=]() -> int { - int result = value; - for (unsigned i = 0; i < 3; ++i) - result += array[i]; - return result; - }(); - } -}; - -namespace rdar14468891 { - class X { - public: - virtual ~X() = 0; // expected-note{{unimplemented pure virtual method '~X' in 'X'}} - }; - - class Y : public X { }; - - void capture(X &x) { - [x]() {}(); // expected-error{{by-copy capture of value of abstract type 'rdar14468891::X'}} - } -} - -namespace rdar15560464 { - struct X; // expected-note{{forward declaration of 'rdar15560464::X'}} - void foo(const X& param) { - auto x = ([=]() { - auto& y = param; // expected-error{{by-copy capture of variable 'param' with incomplete type 'const rdar15560464::X'}} - }); - } -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp deleted file mode 100644 index bae1e25add352..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify
-
-class NonCopyable {
- NonCopyable(const NonCopyable&) = delete; //expected-note3{{explicitly marked deleted here}}
- int x = 10;
- void foo() {
- auto L = [this] { return x; };
- const auto &M = [*this] { return x; };//expected-error{{call to deleted}}
- const auto &M2 = [this] () -> auto&& {
- ++x;
- return [*this] { //expected-error{{call to deleted}} expected-warning{{reference to local}}
- return ++x; //expected-error{{read-only}}
- };
- };
- const auto &M3 = [*this] () mutable -> auto&& { //expected-error{{call to deleted}}
- ++x;
- return [this] { // expected-warning{{reference to local}}
- return x;
- };
- };
- }
-};
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp deleted file mode 100644 index b4b1605ab0025..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// expected-no-diagnostics - -class NonCopyable { - NonCopyable(const NonCopyable&); -}; - -void capture_by_ref(NonCopyable nc, NonCopyable &ncr) { - int array[3]; - (void)[&nc] () -> void {}; - (void)[&ncr] () -> void {}; - (void)[&array] () -> void {}; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp deleted file mode 100644 index 905192ff830b8..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - - -struct X { - X(const X&) = delete; // expected-note 2{{explicitly marked deleted}} - X(X&); -}; - -void test_capture(X x) { - [x] { }(); // okay: non-const copy ctor - - [x] { - [x] { // expected-error{{call to deleted constructor of 'X'}} - }(); - }(); - - [x] { - [&x] { - [x] { // expected-error{{call to deleted constructor of 'const X'}} - }(); - }(); - }(); - - int a; - [=]{ - [&] { - int &x = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - int &x2 = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - }(); - }(); - - [=]{ - [&a] { - [&] { - int &x = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - int &x2 = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - }(); - }(); - }(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp deleted file mode 100644 index 72cf93be5190f..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify -// expected-no-diagnostics - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -void f3() { - float x, &r = x; - int i; - int &ir = i; - const int &irc = i; - - [=,&irc,&ir] { - static_assert(is_same<decltype(((r))), float const&>::value, - "should be const float&"); - static_assert(is_same<decltype(x), float>::value, "should be float"); - static_assert(is_same<decltype((x)), const float&>::value, - "should be const float&"); - static_assert(is_same<decltype(r), float&>::value, "should be float&"); - static_assert(is_same<decltype(ir), int&>::value, "should be int&"); - static_assert(is_same<decltype((ir)), int&>::value, "should be int&"); - static_assert(is_same<decltype(irc), const int&>::value, - "should be const int&"); - static_assert(is_same<decltype((irc)), const int&>::value, - "should be const int&"); - }(); - - [=] { - [=] () mutable { - static_assert(is_same<decltype(x), float>::value, "should be float"); - static_assert(is_same<decltype((x)), float&>::value, - "should be float&"); - }(); - }(); - - [&i] { - static_assert(is_same<decltype((i)), int&>::value, "should be int&"); - }(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp deleted file mode 100644 index a8b40249f0f0f..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - -struct MoveOnly { - MoveOnly(MoveOnly&&); - MoveOnly(const MoveOnly&); -}; - -template<typename T> T &&move(T&); -void test_special_member_functions(MoveOnly mo, int i) { - auto lambda1 = [i]() { }; // expected-note 2{{lambda expression begins here}} expected-note 2{{candidate}} - - // Default constructor - decltype(lambda1) lambda2; // expected-error{{no matching constructor}} - - // Copy assignment operator - lambda1 = lambda1; // expected-error{{copy assignment operator is implicitly deleted}} - - // Move assignment operator - lambda1 = move(lambda1); // expected-error{{copy assignment operator is implicitly deleted}} - - // Copy constructor - decltype(lambda1) lambda3 = lambda1; - decltype(lambda1) lambda4(lambda1); - - // Move constructor - decltype(lambda1) lambda5 = move(lambda1); - decltype(lambda1) lambda6(move(lambda1)); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp deleted file mode 100644 index d791ed60cfca4..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y - -// prvalue -void prvalue() { - auto&& x = [](auto a)->void { }; - auto& y = [](auto *a)->void { }; // expected-error{{cannot bind to a temporary of type}} -} - -namespace std { - class type_info; -} - -struct P { - virtual ~P(); -}; - -void unevaluated_operand(P &p, int i) { //expected-note{{declared here}} - // FIXME: this should only emit one error. - int i2 = sizeof([](auto a, auto b)->void{}(3, '4')); // expected-error{{lambda expression in an unevaluated operand}} \ - // expected-error{{invalid application of 'sizeof'}} - const std::type_info &ti1 = typeid([](auto &a) -> P& { static P p; return p; }(i)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} - const std::type_info &ti2 = typeid([](auto) -> int { return i; }(i)); // expected-error{{lambda expression in an unevaluated operand}}\ - // expected-error{{cannot be implicitly captured}}\ - // expected-note{{begins here}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp deleted file mode 100644 index f120a63badcbe..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 %s -verify - -template<auto> struct Nothing {}; - -void pr33696() { - Nothing<[]() { return 0; }()> nothing; // expected-error{{a lambda expression cannot appear in this context}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp deleted file mode 100644 index 872248e77e6ae..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-unused-value %s -verify - -// prvalue -void prvalue() { - auto&& x = []()->void { }; - auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}} -} - -namespace std { - class type_info; -} - -struct P { - virtual ~P(); -}; - -void unevaluated_operand(P &p, int i) { - int i2 = sizeof([] ()->int { return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} - const std::type_info &ti1 = typeid([&]() -> P& { return p; }()); - const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}} -} - -template<typename T> -struct Boom { - Boom(const Boom&) { - T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \ - // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'int'}} - } - void tickle() const; -}; - -void odr_used(P &p, Boom<int> boom_int, Boom<float> boom_float, - Boom<double> boom_double) { - const std::type_info &ti1 - = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom<int>::Boom' requested here}} - // This does not cause the instantiation of the Boom copy constructor, - // because the copy-initialization of the capture of boom_float occurs in an - // unevaluated operand. - const std::type_info &ti2 - = typeid([=]() -> int { boom_float.tickle(); return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} - - auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom<double>::Boom' requested here}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp deleted file mode 100644 index 17eb841fc3fcf..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify -// expected-no-diagnostics - -template<typename T> -void destroy(T* ptr) { - ptr->~T(); - (*ptr).~T(); -} - -void destructor() { - auto lambda = []{}; - destroy(&lambda); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp deleted file mode 100644 index bc2c9997379a6..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// expected-no-diagnostics - -struct DirectInitOnly { - explicit DirectInitOnly(DirectInitOnly&); -}; - -void direct_init_capture(DirectInitOnly &dio) { - [dio] {}(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp deleted file mode 100644 index 4ae34dec3e34a..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wno-c++1y-extensions -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify - -void print(); - -template<typename T, typename... Ts> -void print(T first, Ts... rest) { - (void)first; - print(rest...); -} - -template<typename... Ts> -void unexpanded_capture(Ts ...values) { - auto unexp = [values] {}; // expected-error{{initializer contains unexpanded parameter pack 'values'}} -} - -template<typename... Ts> -void implicit_capture(Ts ...values) { - auto implicit = [&] { print(values...); }; - implicit(); -} - -template<typename... Ts> -void do_print(Ts... values) { - auto bycopy = [values...]() { print(values...); }; - bycopy(); - auto byref = [&values...]() { print(values...); }; - byref(); - - auto bycopy2 = [=]() { print(values...); }; - bycopy2(); - auto byref2 = [&]() { print(values...); }; - byref2(); -} - -template void do_print(int, float, double); - -template<typename T, int... Values> -void bogus_expansions(T x) { - auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}} -} - -void g(int*, float*, double*); - -template<class... Args> -void std_example(Args... args) { - auto lm = [&, args...] { return g(args...); }; -}; - -template void std_example(int*, float*, double*); - -template<typename ...Args> -void variadic_lambda(Args... args) { - auto lambda = [](Args... inner_args) { return g(inner_args...); }; - lambda(args...); -} - -template void variadic_lambda(int*, float*, double*); - -template<typename ...Args> -void init_capture_pack_err(Args ...args) { - [as(args)...] {} (); // expected-error {{expected ','}} - [as...(args)]{} (); // expected-error {{expected ','}} -} - -template<typename ...Args> -void init_capture_pack_multi(Args ...args) { - [as(args...)] {} (); // expected-error {{initializer missing for lambda capture 'as'}} expected-error {{multiple}} -} -template void init_capture_pack_multi(); // expected-note {{instantiation}} -template void init_capture_pack_multi(int); -template void init_capture_pack_multi(int, int); // expected-note {{instantiation}} - -template<typename ...Args> -void init_capture_pack_outer(Args ...args) { - print([as(args)] { return sizeof(as); } () ...); -} -template void init_capture_pack_outer(); -template void init_capture_pack_outer(int); -template void init_capture_pack_outer(int, int); diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp deleted file mode 100644 index db40bd5d1420e..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++14 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++17 %s -verify - -void test_nonaggregate(int i) { - auto lambda = [i]() -> void {}; // expected-note 2{{candidate constructor}} - decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}} - static_assert(__is_literal(decltype(lambda)) == (__cplusplus >= 201703L), ""); - - auto lambda2 = []{}; // expected-note 2{{candidate constructor}} - decltype(lambda2) bar = {}; // expected-error{{no matching constructor}} - static_assert(__is_literal(decltype(lambda2)) == (__cplusplus >= 201703L), ""); -} - -constexpr auto literal = []{}; -#if __cplusplus < 201703L -// expected-error@-2 {{constexpr variable cannot have non-literal type}} -// expected-note@-3 {{lambda closure types are non-literal types before C++17}} -#endif diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp deleted file mode 100644 index f8461335b7689..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify - -int a; -int &b = [] (int &r) -> decltype(auto) { return r; } (a); -int &c = [] (int &r) -> decltype(auto) { return (r); } (a); -int &d = [] (int &r) -> auto & { return r; } (a); -int &e = [] (int &r) -> auto { return r; } (a); // expected-error {{cannot bind to a temporary}} -int &f = [] (int r) -> decltype(auto) { return r; } (a); // expected-error {{cannot bind to a temporary}} -int &g = [] (int r) -> decltype(auto) { return (r); } (a); // expected-warning {{reference to stack}} - - -int test_explicit_auto_return() -{ - struct X {}; - auto L = [](auto F, auto a) { return F(a); }; - auto M = [](auto a) -> auto { return a; }; // OK - auto MRef = [](auto b) -> auto& { return b; }; //expected-warning{{reference to stack}} - auto MPtr = [](auto c) -> auto* { return &c; }; //expected-warning{{address of stack}} - auto MDeclType = [](auto&& d) -> decltype(auto) { return static_cast<decltype(d)>(d); }; //OK - M(3); - - auto &&x = MDeclType(X{}); - auto &&x1 = M(X{}); - auto &&x2 = MRef(X{});//expected-note{{in instantiation of}} - auto &&x3 = MPtr(X{}); //expected-note{{in instantiation of}} - return 0; -} - -int test_implicit_auto_return() -{ - { - auto M = [](auto a) { return a; }; - struct X {}; - X x = M(X{}); - - } -} - -int test_multiple_returns() { - auto M = [](auto a) { - bool k; - if (k) - return a; - else - return 5; //expected-error{{deduced as 'int' here}} - }; - M(3); // OK - M('a'); //expected-note{{in instantiation of}} - return 0; -} -int test_no_parameter_list() -{ - static int si = 0; - auto M = [] { return 5; }; // OK - auto M2 = [] -> auto&& { return si; }; // expected-error{{lambda requires '()'}} - M(); -} - -int test_conditional_in_return() { - auto Fac = [](auto f, auto n) { - return n <= 0 ? n : f(f, n - 1) * n; - }; - // FIXME: this test causes a recursive limit - need to error more gracefully. - //Fac(Fac, 3); - -}
\ No newline at end of file diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp deleted file mode 100644 index a36175af6fec5..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -DCPP1Y - -void missing_lambda_declarator() { - [](){}(); -} - -template<typename T> T get(); - -void infer_void_return_type(int i) { - if (i > 17) - return []() { }(); - - if (i > 11) - return []() { return; }(); - - return [](int x) { - switch (x) { - case 0: return get<void>(); - case 1: return; - case 2: return { 1, 2.0 }; //expected-error{{cannot deduce}} - } - }(7); -} - -struct X { }; - -X infer_X_return_type(X x) { - return [&x](int y) { - if (y > 0) - return X(); - else - return x; - }(5); -} - -X infer_X_return_type_2(X x) { - return [x](int y) { - if (y > 0) - return X(); - else - return x; // ok even in c++11, per dr1048. - }(5); -} - -struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}} -void test_result_type(int N) { - auto l1 = [] () -> Incomplete { }; // expected-error{{incomplete result type 'Incomplete' in lambda expression}} - - typedef int vla[N]; - auto l2 = [] () -> vla { }; // expected-error{{function cannot return array type 'vla' (aka 'int [N]')}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm deleted file mode 100644 index 92c62904d57b2..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -@interface A -@end - -void test_result_type() { - auto l1 = [] () -> A { }; // expected-error{{interface type 'A' cannot be returned by value; did you forget * in 'A'?}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp deleted file mode 100644 index 415c3d84560ef..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y - -namespace test_factorial { - -auto Fact = [](auto Self, unsigned n) -> unsigned { - return !n ? 1 : Self(Self, n - 1) * n; -}; - -auto six = Fact(Fact, 3); - -} - -namespace overload_generic_lambda { - template <class F1, class F2> struct overload : F1, F2 { - using F1::operator(); - using F2::operator(); - overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } - }; - - auto NumParams = [](auto Self, auto h, auto ... rest) -> unsigned { - return 1 + Self(Self, rest...); - }; - auto Base = [](auto Self, auto h) -> unsigned { - return 1; - }; - overload<decltype(Base), decltype(NumParams)> O(Base, NumParams); - int num_params = O(O, 5, 3, "abc", 3.14, 'a'); -} - - -namespace overload_generic_lambda_return_type_deduction { - template <class F1, class F2> struct overload : F1, F2 { - using F1::operator(); - using F2::operator(); - overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } - }; - - auto NumParams = [](auto Self, auto h, auto ... rest) { - return 1 + Self(Self, rest...); - }; - auto Base = [](auto Self, auto h) { - return 1; - }; - overload<decltype(Base), decltype(NumParams)> O(Base, NumParams); - int num_params = O(O, 5, 3, "abc", 3.14, 'a'); -} - -namespace test_standard_p5 { -// FIXME: This test should eventually compile without an explicit trailing return type -auto glambda = [](auto a, auto&& b) ->bool { return a < b; }; -bool b = glambda(3, 3.14); // OK - -} -namespace test_deduction_failure { - int test() { - auto g = [](auto *a) { //expected-note{{candidate template ignored}} - return a; - }; - struct X { }; - X *x; - g(x); - g(3); //expected-error{{no matching function}} - return 0; - } - -} - -namespace test_instantiation_or_sfinae_failure { -int test2() { - { - auto L = [](auto *a) { - return (*a)(a); }; //expected-error{{called object type 'double' is not a function}} - double d; - L(&d); //expected-note{{in instantiation of}} - auto M = [](auto b) { return b; }; - L(&M); // ok - } - { - auto L = [](auto *a) ->decltype (a->foo()) { //expected-note2{{candidate template ignored:}} - return (*a)(a); }; - double d; - L(&d); //expected-error{{no matching function for call}} - auto M = [](auto b) { return b; }; - L(&M); //expected-error{{no matching function for call}} - - } - return 0; -} - - -} - -namespace test_misc { -auto GL = [](auto a, decltype(a) b) //expected-note{{candidate function}} - -> int { return a + b; }; - -void test() { - struct X { }; - GL(3, X{}); //expected-error{{no matching function}} -} - -void test2() { - auto l = [](auto *a) -> int { - (*a)(a); return 0; }; //expected-error{{called object type 'double' is not a function}} - l(&l); - double d; - l(&d); //expected-note{{in instantiation of}} -} - -} - -namespace nested_lambdas { - int test() { - auto L = [](auto a) { - return [=](auto b) { - return a + b; - }; - }; - } - auto get_lambda() { - return [](auto a) { - return a; - }; - }; - - int test2() { - auto L = get_lambda(); - L(3); - } -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp deleted file mode 100644 index b8504d4906500..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Winvalid-noreturn -verify - -// An attribute-specifier-seq in a lambda-declarator appertains to the -// type of the corresponding function call operator. -void test_attributes() { - auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-warning{{control may reach end of non-void lambda}} - - // FIXME: GCC accepts the [[gnu::noreturn]] attribute here. - auto nrl2 = []() [[gnu::noreturn]] { return; }; // expected-warning{{attribute 'noreturn' ignored}} -} - -template<typename T> -struct bogus_override_if_virtual : public T { - bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding dereferenced null pointer to reference has undefined behavior}} - int operator()() const; -}; - -void test_quals() { - // This function call operator is declared const (9.3.1) if and only - // if the lambda- expression's parameter-declaration-clause is not - // followed by mutable. - auto l = [=](){}; // expected-note{{method is not marked volatile}} - const decltype(l) lc = l; - l(); - lc(); - - auto ml = [=]() mutable{}; // expected-note{{method is not marked const}} \ - // expected-note{{method is not marked volatile}} - const decltype(ml) mlc = ml; - ml(); - mlc(); // expected-error{{no matching function for call to object of type}} - - // It is neither virtual nor declared volatile. - volatile decltype(l) lv = l; - volatile decltype(ml) mlv = ml; - lv(); // expected-error{{no matching function for call to object of type}} - mlv(); // expected-error{{no matching function for call to object of type}} - - bogus_override_if_virtual<decltype(l)> bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}} -} - -// Core issue 974: default arguments (8.3.6) may be specified in the -// parameter-declaration-clause of a lambda-declarator. -int test_default_args() { - return [](int i = 5, int j = 17) { return i+j;}(5, 6); -} - -// Any exception-specification specified on a lambda-expression -// applies to the corresponding function call operator. -void test_exception_spec() { - auto tl1 = []() throw(int) {}; - auto tl2 = []() {}; - static_assert(!noexcept(tl1()), "lambda can throw"); - static_assert(!noexcept(tl2()), "lambda can throw"); - - auto ntl1 = []() throw() {}; - auto ntl2 = []() noexcept(true) {}; - auto ntl3 = []() noexcept {}; - static_assert(noexcept(ntl1()), "lambda cannot throw"); - static_assert(noexcept(ntl2()), "lambda cannot throw"); - static_assert(noexcept(ntl3()), "lambda cannot throw"); -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp deleted file mode 100644 index 90a3aec50cb38..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify - -void test_conversion() { - int (*fp1)(int) = [](int x) { return x + 1; }; - void (*fp2)(int) = [](int x) { }; - - const auto lambda = [](int x) { }; - void (*fp3)(int) = lambda; - - volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}} - void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}} - - void (*fp5)(int) noexcept = [](int x) { }; -#if __cplusplus > 201402L - // expected-error@-2 {{no viable}} expected-note@-2 {{candidate}} - void (*fp5a)(int) noexcept = [](auto x) { }; - // expected-error@-1 {{no viable}} expected-note@-1 {{candidate}} - void (*fp5b)(int) noexcept = [](auto x) noexcept { }; -#endif - void (*fp6)(int) noexcept = [](int x) noexcept { }; -} - -void test_no_conversion() { - int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}} - void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}} -} - -void test_wonky() { - const auto l = [](int x) mutable -> int { return + 1; }; - l(17); // okay: uses conversion function -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp deleted file mode 100644 index 9dbe2e189f4af..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -// Check that analysis-based warnings work in lambda bodies. -void analysis_based_warnings() { - (void)[]() -> int { }; // expected-warning{{control reaches end of non-void lambda}} -} - -// Check that we get the right types of captured variables (the -// semantic-analysis part of p7). -int &check_const_int(int&); -float &check_const_int(const int&); - -void test_capture_constness(int i, const int ic) { - (void)[i,ic] ()->void { - float &fr1 = check_const_int(i); - float &fr2 = check_const_int(ic); - }; - - (void)[=] ()->void { - float &fr1 = check_const_int(i); - float &fr2 = check_const_int(ic); - }; - - (void)[i,ic] () mutable ->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; - - (void)[=] () mutable ->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; - - (void)[&i,&ic] ()->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; - - (void)[&] ()->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; -} - - -struct S1 { - int x, y; - S1 &operator=(int*); - int operator()(int); - void f() { - [&]()->int { - S1 &s1 = operator=(&this->x); - return operator()(this->x + y); - }(); - } -}; diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp deleted file mode 100644 index 1cc1fd974ca5d..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -Wno-c++1y-extensions - -class X0 { - void explicit_capture() { - int foo; - - (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}} - (void)[this, this] () {}; // expected-error {{'this' can appear only once}} - (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}} - (void)[=, &foo] () {}; - (void)[=, this] () {}; // expected-warning {{C++2a extension}} - (void)[&, foo] () {}; - (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} - (void)[&, this] () {}; - } -}; - -struct S2 { - void f(int i); - void g(int i); -}; - -void S2::f(int i) { - (void)[&, i]{ }; - (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}} - (void)[=, this]{ }; // expected-warning{{C++2a extension}} - (void)[=]{ this->g(i); }; - (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}} - (void)[i(0), i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}} - (void)[i, i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}} - (void)[i(0), i]{ }; // expected-error{{'i' can appear only once in a capture list}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp deleted file mode 100644 index 2bb75df7ac6aa..0000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Winvalid-noreturn %s -verify - -template<typename T> -void test_attributes() { - // FIXME: GCC accepts [[gnu::noreturn]] here. - auto nrl = []() [[gnu::noreturn]] {}; // expected-warning{{attribute 'noreturn' ignored}} -} - -template void test_attributes<int>(); - -template<typename T> -void call_with_zero() { - [](T *ptr) -> T& { return *ptr; }(0); -} - -template void call_with_zero<int>(); - -template<typename T> -T captures(T x, T y) { - auto lambda = [=, &y] () -> T { - T i = x; - return i + y; - }; - - return lambda(); -} - -struct X { - X(const X&); -}; - -X operator+(X, X); -X operator-(X, X); - -template int captures(int, int); -template X captures(X, X); - -template<typename T> -int infer_result(T x, T y) { - auto lambda = [=](bool b) { return x + y; }; - return lambda(true); // expected-error{{no viable conversion from returned value of type 'X' to function return type 'int'}} -} - -template int infer_result(int, int); -template int infer_result(X, X); // expected-note{{in instantiation of function template specialization 'infer_result<X>' requested here}} - -// Make sure that lambda's operator() can be used from templates. -template<typename F> -void accept_lambda(F f) { - f(1); -} - -template<typename T> -void pass_lambda(T x) { - accept_lambda([&x](T y) { return x + y; }); -} - -template void pass_lambda(int); - -namespace std { - class type_info; -} - -namespace p2 { - struct P { - virtual ~P(); - }; - - template<typename T> - struct Boom { - Boom(const Boom&) { - T* x = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} - } - void tickle() const; - }; - - template<typename R, typename T> - void odr_used(R &r, Boom<T> boom) { - const std::type_info &ti - = typeid([=,&r] () -> R& { // expected-error{{lambda expression in an unevaluated operand}} - boom.tickle(); - return r; - }()); - } - - template void odr_used(int&, Boom<int>); // expected-note{{in instantiation of function template specialization}} - - template<typename R, typename T> - void odr_used2(R &r, Boom<T> boom) { - const std::type_info &ti - = typeid([=,&r] () -> R& { // expected-note{{in instantiation of member function 'p2::Boom<float>::Boom' requested here}} - boom.tickle(); - return r; - }()); - } - - template void odr_used2(P&, Boom<float>); -} - -namespace p5 { - struct NonConstCopy { - NonConstCopy(const NonConstCopy&) = delete; - NonConstCopy(NonConstCopy&); - }; - - template<typename T> - void double_capture(T &nc) { - [=] () mutable { - [=] () mutable { - T nc2(nc); - }(); - }(); - } - - template void double_capture(NonConstCopy&); -} - -namespace NonLocalLambdaInstantation { - template<typename T> - struct X { - static int value; - }; - - template<typename T> - int X<T>::value = []{ return T(); }(); // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'int *'}} - - template int X<int>::value; - template int X<float>::value; - template int X<int*>::value; // expected-note{{in instantiation of static data member }} - - template<typename T> - void defaults(int x = []{ return T(); }()) { }; // expected-error{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}} \ - // expected-note{{passing argument to parameter 'x' here}} - - void call_defaults() { - defaults<int>(); - defaults<float>(); - defaults<int*>(); // expected-note{{in instantiation of default function argument expression for 'defaults<int *>' required here}} - } - - template<typename T> - struct X2 { // expected-note{{in instantiation of default member initializer 'NonLocalLambdaInstantation::X2<int *>::x'}} - int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}} - }; - - X2<int> x2i; - X2<float> x2f; - X2<int*> x2ip; // expected-note {{in evaluation of exception spec}} -} diff --git a/test/CXX/expr/expr.unary/expr.delete/p10.cpp b/test/CXX/expr/expr.unary/expr.delete/p10.cpp deleted file mode 100644 index aad2747dd32f2..0000000000000 --- a/test/CXX/expr/expr.unary/expr.delete/p10.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -using size_t = decltype(sizeof(0)); -namespace std { enum class align_val_t : size_t {}; } - -// Aligned version is preferred over unaligned version, -// unsized version is preferred over sized version. -template<unsigned Align> -struct alignas(Align) A { - void operator delete(void*); - void operator delete(void*, std::align_val_t) = delete; // expected-note {{here}} - - void operator delete(void*, size_t) = delete; - void operator delete(void*, size_t, std::align_val_t) = delete; -}; -void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; } -void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}} - -template<unsigned Align> -struct alignas(Align) B { - void operator delete(void*, size_t); - void operator delete(void*, size_t, std::align_val_t) = delete; // expected-note {{here}} -}; -void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; } -void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}} diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp deleted file mode 100644 index ecb29189af60b..0000000000000 --- a/test/CXX/expr/expr.unary/expr.delete/p5.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -// If the object being deleted has incomplete class type at the point of -// deletion and the complete class has a non-trivial destructor or a -// deallocation function, the behavior is undefined. - -// The trivial case. -class T0; // expected-note {{forward declaration}} -void f0(T0 *a) { delete a; } // expected-warning {{deleting pointer to incomplete type}} -class T0 { ~T0(); }; - -// The trivial case, inside a template instantiation. -template<typename T> -struct T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} -class T1_B; // expected-note {{forward declaration}} -void f0() { T1_A<T1_B> x; } // expected-note {{in instantiation of member function}} - -// This case depends on when we check T2_C::f0. -class T2_A; -template<typename T> -struct T2_B { void f0(T *a) { delete a; } }; -struct T2_C { T2_B<T2_A> x; void f0(T2_A *a) { x.f0(a); } }; -void f0(T2_A *a) { T2_C x; x.f0(a); } -class T2_A { }; - -// An alternate version of the same. -class T3_A; -template<typename T> -struct T3_B { - void f0(T *a) { - delete a; // expected-error{{calling a private destructor of class 'T3_A'}} - } -}; - -struct T3_C { - T3_B<T3_A> x; - void f0(T3_A *a) { - x.f0(a); // expected-note{{in instantiation of member function 'T3_B<T3_A>::f0' requested here}} - } -}; - -void f0(T3_A *a) { T3_C x; x.f0(a); } -class T3_A { -private: - ~T3_A(); // expected-note{{declared private here}} -}; diff --git a/test/CXX/expr/expr.unary/expr.new/p14.cpp b/test/CXX/expr/expr.unary/expr.new/p14.cpp deleted file mode 100644 index 6537cdcfeafa0..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p14.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions %s -verify - -using size_t = decltype(sizeof(0)); -namespace std { enum class align_val_t : size_t {}; } - -struct Arg {} arg; - -// If the type is aligned, first try with an alignment argument and then -// without. If not, never consider supplying an alignment. - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Unaligned { - void *operator new(size_t, Ts...) = delete; // expected-note 4{{deleted}} -}; -auto *ua = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}} -auto *ub = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *uap = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}} -auto *ubp = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Aligned { - void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} expected-note 2{{not viable}} -}; -auto *aa = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{no matching}} -auto *ab = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *aap = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{no matching}} -auto *abp = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} - -// If both are available, we prefer the aligned version for an overaligned -// type, and only use the unaligned version for a non-overaligned type. - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Both1 { - void *operator new(size_t, Ts...); // expected-note 2{{not viable}} - void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} -}; -template<unsigned Align, typename ...Ts> -struct alignas(Align) Both2 { - void *operator new(size_t, Ts...) = delete; // expected-note 2{{deleted}} - void *operator new(size_t, std::align_val_t, Ts...); // expected-note 2{{not viable}} -}; -auto *b1a = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; -auto *b1b = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *b2a = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}} -auto *b2b = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; -auto *b1ap = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; -auto *b1bp = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} -auto *b2ap = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}} -auto *b2bp = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; - -// Note that the aligned form can select a function with a parameter different -// from std::align_val_t. - -struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc1 { - void *operator new(size_t, ...) = delete; // expected-note 2{{deleted}} -}; -auto *waa1 = new WeirdAlignedAlloc1; // expected-error {{deleted}} -auto *waa1p = new (arg) WeirdAlignedAlloc1; // expected-error {{deleted}} - -struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc2 { - template<typename ...T> - void *operator new(size_t, T...) { - using U = void(T...); // expected-note 2{{previous}} - using U = void; // expected-error {{different types ('void' vs 'void (std::align_val_t)')}} \ - expected-error {{different types ('void' vs 'void (std::align_val_t, Arg)')}} - } -}; -auto *waa2 = new WeirdAlignedAlloc2; // expected-note {{instantiation of}} -auto *waa2p = new (arg) WeirdAlignedAlloc2; // expected-note {{instantiation of}} diff --git a/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp b/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp deleted file mode 100644 index 27b915e95965d..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm-only %s - -// this used to crash due to templ<int>'s dtor not being marked as used by the -// new expression in func() -struct non_trivial { - non_trivial() {} - ~non_trivial() {} -}; -template < typename T > class templ { - non_trivial n; -}; -void func() { - new templ<int>[1][1]; -} diff --git a/test/CXX/expr/expr.unary/expr.new/p17.cpp b/test/CXX/expr/expr.unary/expr.new/p17.cpp deleted file mode 100644 index 0d108eb6a894d..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p17.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -class ctor { - ctor(); // expected-note{{implicitly declared private here}} -}; - -class dtor { - ~dtor(); // expected-note 3 {{implicitly declared private here}} -}; - -void test() { - new ctor[0]; // expected-error{{calling a private constructor of class 'ctor'}} - new dtor[0]; // expected-error{{calling a private destructor of class 'dtor'}} - new dtor[3]; // expected-error{{calling a private destructor of class 'dtor'}} - new dtor[3][3]; // expected-error{{calling a private destructor of class 'dtor'}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p19.cpp b/test/CXX/expr/expr.unary/expr.new/p19.cpp deleted file mode 100644 index bb69fd55fd803..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p19.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s -typedef __SIZE_TYPE__ size_t; - -// Operator delete template for placement new with global lookup -template<int I> -struct X0 { - X0(); - - static void* operator new(size_t) { - return I; // expected-error{{cannot initialize}} - } - - static void operator delete(void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X0() { - // Using the global operator new suppresses the search for a - // operator delete in the class. - ::new X0<2>; - - new X0<3>; // expected-note 2{{instantiation}} -} - -// Operator delete template for placement new[] with global lookup -template<int I> -struct X1 { - X1(); - - static void* operator new[](size_t) { - return I; // expected-error{{cannot initialize}} - } - - static void operator delete[](void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X1() { - // Using the global operator new suppresses the search for a - // operator delete in the class. - ::new X1<2> [17]; - - new X1<3> [17]; // expected-note 2{{instantiation}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp deleted file mode 100644 index a3a2f712c8009..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 - -template<typename T> -struct only { - only(T); - template<typename U> only(U) = delete; -}; - -void f() { - only<const int*> p = new const auto (0); - only<double*> q = new (auto) (0.0); - only<char*> r = new auto {'a'}; - - new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new (const auto)(); // expected-error{{new expression for type 'const auto' requires a constructor argument}} - new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new auto {1,2,3}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto ({1,2,3}); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} -} - -void p2example() { - only<int*> r = new auto(1); - auto x = new auto('a'); - - only<char*> testX = x; -} diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp deleted file mode 100644 index 70bbc4805c437..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -pedantic - -void f() { - new auto('a'); - new auto {2}; // expected-warning {{ISO C++ standards before C++17 do not allow new expression for type 'auto' to use list-initialization}} - new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new decltype(auto)({1}); // expected-warning {{ISO C++ standards before C++17 do not allow new expression for type 'decltype(auto)' to use list-initialization}} - new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp deleted file mode 100644 index 6e76075ab16f5..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -pedantic - -void f() { - new auto('a'); - new auto {2}; - new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new decltype(auto)({1}); - new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp deleted file mode 100644 index 13676a8a07cec..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fexceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -fexceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -fexceptions %s -typedef __SIZE_TYPE__ size_t; - -namespace std { enum class align_val_t : size_t {}; } - -struct S { - // Placement allocation function: - static void* operator new(size_t, size_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*, size_t); // expected-note{{declared here}} -}; - -void testS() { - S* p = new (0) S; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} - -struct T { - // Placement allocation function: - static void* operator new(size_t, size_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*); - // Placement deallocation function: - static void operator delete(void*, size_t); -}; - -void testT() { - T* p = new (0) T; // ok -} - -#if __cplusplus > 201402L -struct U { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Placement deallocation function: - static void operator delete(void*, size_t, std::align_val_t); // expected-note{{declared here}} -}; - -void testU() { - U* p = new (0, std::align_val_t(0)) U; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} - -struct V { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*, std::align_val_t); - // Placement deallocation function: - static void operator delete(void*, size_t, std::align_val_t); -}; - -void testV() { - V* p = new (0, std::align_val_t(0)) V; -} - -struct W { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Usual (non-placement) deallocation functions: - static void operator delete(void*); - static void operator delete(void*, size_t, std::align_val_t); // expected-note {{declared here}} -}; - -void testW() { - W* p = new (0, std::align_val_t(0)) W; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} -#endif diff --git a/test/CXX/expr/expr.unary/expr.new/p20.cpp b/test/CXX/expr/expr.unary/expr.new/p20.cpp deleted file mode 100644 index 8cbe2b9be3be7..0000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p20.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s -typedef __SIZE_TYPE__ size_t; - -// Overloaded operator delete with two arguments -template<int I> -struct X0 { - X0(); - static void* operator new(size_t); - static void operator delete(void*, size_t) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X0() { - new X0<1>; // expected-note{{instantiation}} -} - -// Overloaded operator delete with one argument -template<int I> -struct X1 { - X1(); - - static void* operator new(size_t); - static void operator delete(void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X1() { - new X1<1>; // expected-note{{instantiation}} -} - -// Overloaded operator delete for placement new -template<int I> -struct X2 { - X2(); - - static void* operator new(size_t, double, double); - static void* operator new(size_t, int, int); - - static void operator delete(void*, const int, int) { - int *ip = I; // expected-error{{cannot initialize}} - } - - static void operator delete(void*, double, double); -}; - -void test_X2() { - new (0, 0) X2<1>; // expected-note{{instantiation}} -} - -// Operator delete template for placement new -struct X3 { - X3(); - - static void* operator new(size_t, double, double); - - template<typename T> - static void operator delete(void*, T x, T) { - double *dp = &x; - int *ip = &x; // expected-error{{cannot initialize}} - } -}; - -void test_X3() { - new (0, 0) X3; // expected-note{{instantiation}} -} - -// Operator delete template for placement new in global scope. -struct X4 { - X4(); - static void* operator new(size_t, double, double); -}; - -template<typename T> -void operator delete(void*, T x, T) { - double *dp = &x; - int *ip = &x; // expected-error{{cannot initialize}} -} - -void test_X4() { - new (0, 0) X4; // expected-note{{instantiation}} -} - -// Useless operator delete hides global operator delete template. -struct X5 { - X5(); - static void* operator new(size_t, double, double); - void operator delete(void*, double*, double*); -}; - -void test_X5() { - new (0, 0) X5; // okay, we found X5::operator delete but didn't pick it -} - -// Operator delete template for placement new -template<int I> -struct X6 { - X6(); - - static void* operator new(size_t) { - return I; // expected-error{{cannot initialize}} - } - - static void operator delete(void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X6() { - new X6<3>; // expected-note 2{{instantiation}} -} - -void *operator new(size_t, double, double, double); - -template<typename T> -void operator delete(void*, T x, T, T) { - double *dp = &x; - int *ip = &x; // expected-error{{cannot initialize}} -} -void test_int_new() { - new (1.0, 1.0, 1.0) int; // expected-note{{instantiation}} -} - -// We don't need an operator delete if the type has a trivial -// constructor, since we know that constructor cannot throw. -// FIXME: Is this within the standard? Seems fishy, but both EDG+GCC do it. -#if 0 -template<int I> -struct X7 { - static void* operator new(size_t); - static void operator delete(void*, size_t) { - int *ip = I; // okay, since it isn't instantiated. - } -}; - -void test_X7() { - new X7<1>; -} -#endif - diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp deleted file mode 100644 index aa76b3a734624..0000000000000 --- a/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { - unsigned bitX : 4; - unsigned bitY : 4; - unsigned var; - - void foo(); -}; - -void test(A *a) { - int x; - x = sizeof(a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof((unsigned) a->bitX); - x = sizeof(a->foo(), a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->var ? a->bitX : a->bitY); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->var ? a->bitX : a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->bitX = 3); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->bitY += 3); // expected-error {{invalid application of 'sizeof' to bit-field}} -} - -void test2() { - int x; - x = sizeof(void); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} - x = sizeof(int()); // expected-error {{invalid application of 'sizeof' to a function type}} - x = sizeof(test2()); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} - x = sizeof(test2); // expected-error {{invalid application of 'sizeof' to a function type}} -} - -namespace pr16992 { - -template<typename T> struct ABC { - int func () { - return sizeof T; // expected-error {{expected parentheses around type name in sizeof expression}} - } -}; - -ABC<int> qq; - -template<typename T> struct ABC2 { - int func () { - return sizeof T::A; - } -}; - -struct QQ { int A; }; -ABC2<QQ> qq2; -} diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp deleted file mode 100644 index afd8ef05302fc..0000000000000 --- a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// Test parsing + semantic analysis -template<typename ...Types> struct count_types { - static const unsigned value = sizeof...(Types); -}; - -template<int ...Values> struct count_ints { - static const unsigned value = sizeof...(Values); -}; - -// Test instantiation -int check_types[count_types<short, int, long>::value == 3? 1 : -1]; -int check_ints[count_ints<1, 2, 3, 4, 5>::value == 5? 1 : -1]; - -// Test instantiation involving function parameter packs. -struct any { - template<typename T> any(T); -}; - -template<typename ...Inits> -void init_me(Inits ...inits) { - any array[sizeof...(inits)] = { inits... }; -} - -template void init_me<int, float, double*>(int, float, double*); - -// Test parser and semantic recovery. -template<int Value> struct count_ints_2 { - static const unsigned value = sizeof...(Value); // expected-error{{'Value' does not refer to the name of a parameter pack}} -}; - -template<typename ...Types> // expected-note{{parameter pack 'Types' declared here}} -struct count_types_2 { - static const unsigned value = sizeof... Type; // expected-error{{missing parentheses around the size of parameter pack 'Type'}} \ - // expected-error{{Type' does not refer to the name of a parameter pack; did you mean 'Types'?}} -}; - diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp deleted file mode 100644 index e299705a4c11e..0000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++11 -include %S/ser.h %s -o - | FileCheck %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-pch -o %t-ser.pch -std=c++11 -x c++ %S/ser.h -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++11 -include-pch %t-ser.pch %s -o - | FileCheck %s - -struct D { - ~D() throw(); -}; -struct E { - ~E() throw(); -}; - -void test() { - bool b; - // CHECK: store i8 1 - b = noexcept(0); - // CHECK: store i8 0 - b = noexcept(throw 0); - b = f1(); - b = f2(); - - // CHECK-NOT: call void @_ZN1ED1Ev - // CHECK: call void @_ZN1DD1Ev - D(), noexcept(E()); -} -// CHECK: ret i1 true -// CHECK: ret i1 false diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp deleted file mode 100644 index a2a57956df9bc..0000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -fms-extensions -Wno-delete-incomplete -Wno-unused-value %s -// expected-no-diagnostics - -#define P(e) static_assert(noexcept(e), "expected nothrow") -#define N(e) static_assert(!noexcept(e), "expected throw") -#define B(b, e) static_assert(b == noexcept(e), "expectation failed") - -void simple() { - P(0); - P(0 + 0); - int i; - P(i); - P(sizeof(0)); - P(static_cast<int>(0)); - N(throw 0); - N((throw 0, 0)); -} - -void nospec(); -void allspec() throw(...); -void intspec() throw(int); -void emptyspec() throw(); -void nothrowattr() __attribute__((nothrow)); -void noexcept_true() noexcept; -void noexcept_false() noexcept(false); - -void call() { - N(nospec()); - N(allspec()); - N(intspec()); - P(emptyspec()); - P(nothrowattr()); - P(noexcept_true()); - N(noexcept_false()); -} - -void (*pnospec)(); -void (*pallspec)() throw(...); -void (*pintspec)() throw(int); -void (*pemptyspec)() throw(); - -typedef void (*funcptr)(); -funcptr returnsptr() throw(); - -void callptr() { - N(pnospec()); - N((*pnospec)()); - N(pallspec()); - N((*pallspec)()); - N(pintspec()); - N((*pintspec)()); - P(pemptyspec()); - P((*pemptyspec)()); - N(returnsptr()()); -} - -struct S1 { - void nospec(); - void allspec() throw(...); - void intspec() throw(int); - void emptyspec() throw(); -}; - -void callmem() { - S1 s; - N(s.nospec()); - N(s.allspec()); - N(s.intspec()); - P(s.emptyspec()); -} - -void (S1::*mpnospec)(); -void (S1::*mpallspec)() throw(...); -void (S1::*mpintspec)() throw(int); -void (S1::*mpemptyspec)() throw(); - -void callmemptr() { - S1 s; - N((s.*mpnospec)()); - N((s.*mpallspec)()); - N((s.*mpintspec)()); - P((s.*mpemptyspec)()); -} - -struct S2 { - S2(); - S2(int, int) throw(); - void operator +(); - void operator -() throw(); - void operator +(int); - void operator -(int) throw(); - operator int(); - operator float() throw(); -}; - -void *operator new(__typeof__(sizeof(int)) sz, int) throw(); - -struct IncompleteStruct; - -struct Bad1 { - ~Bad1() throw(int); -}; -struct Bad2 { - void operator delete(void*) throw(int); -}; - -typedef int X; - -void implicits() { - N(new int); - P(new (0) int); - P(delete (int*)0); - P(delete (IncompleteStruct*)0); - N(delete (Bad1*)0); - N(delete (Bad2*)0); - N(S2()); - P(S2(0, 0)); - S2 s; - N(+s); - P(-s); - N(s + 0); - P(s - 0); - N(static_cast<int>(s)); - P(static_cast<float>(s)); - N(Bad1()); - P(X().~X()); -} - -struct V { - virtual ~V() throw(); -}; -struct D : V {}; - -void dyncast() { - V *pv = 0; - D *pd = 0; - P(dynamic_cast<V&>(*pd)); - P(dynamic_cast<V*>(pd)); - N(dynamic_cast<D&>(*pv)); - P(dynamic_cast<D*>(pv)); -} - -namespace std { - struct type_info {}; -} - -void idtype() { - P(typeid(V)); - P(typeid((V*)0)); - P(typeid(*(S1*)0)); - N(typeid(*(V*)0)); -} - -void uneval() { - P(sizeof(typeid(*(V*)0))); - P(typeid(typeid(*(V*)0))); -} - -struct G1 {}; -struct G2 { int i; }; -struct G3 { S2 s; }; - -void gencon() { - P(G1()); - P(G2()); - N(G3()); -} - -template <class T> void f(T&&) noexcept; -template <typename T, bool b> -void late() { - B(b, typeid(*(T*)0)); - B(b, T(1)); - B(b, static_cast<T>(S2(0, 0))); - B(b, S1() + T()); - P(f(T())); - P(new (0) T); - P(delete (T*)0); -} -struct S3 { - virtual ~S3() throw(); - S3() throw(); - explicit S3(int); - S3(const S2&); -}; -template <class T> T&& f2() noexcept; -template <typename T> -void late2() { - P(dynamic_cast<S3&>(f2<T&>())); -} -void operator +(const S1&, float) throw(); -void operator +(const S1&, const S3&); -void tlate() { - late<float, true>(); - late<S3, false>(); - late2<S3>(); -} diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h b/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h deleted file mode 100644 index e6e7b795d25af..0000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h +++ /dev/null @@ -1,8 +0,0 @@ -// Serialization testing helper for noexcept, included by cg.cpp. - -inline bool f1() { - return noexcept(0); -} -inline bool f2() { - return noexcept(throw 0); -} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp deleted file mode 100644 index 08ab0ca56fb63..0000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s -verify -// expected-no-diagnostics - -namespace rdar10544564 { - // Check that we don't attempt to use an overloaded operator& when - // naming a pointer-to-member. - struct X { - void** operator & (); - }; - - struct Y - { - public: - X member; - X memfunc1(); - X memfunc2(); - X memfunc2(int); - - void test() { - X Y::*data_mem_ptr = &Y::member; - X (Y::*func_mem_ptr1)() = &Y::memfunc1; - X (Y::*func_mem_ptr2)() = &Y::memfunc2; - } - }; - - X Y::*data_mem_ptr = &Y::member; - X (Y::*func_mem_ptr1)() = &Y::memfunc1; - X (Y::*func_mem_ptr2)() = &Y::memfunc2; -} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp deleted file mode 100644 index 48c47f74ac6c6..0000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// rdar://problem/8347416 -namespace test0 { - struct A { - void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}} - template<typename T> void g(T); - - void test() { - foo(&g<int>); // expected-error-re {{cannot form member pointer of type 'void (test0::A::*)(int){{( __attribute__\(\(thiscall\)\))?}}' without '&' and class name}} - } - }; -} - -// This should succeed. -namespace test1 { - struct A { - static void f(void (A::*)()); - static void f(void (*)(int)); - void g(); - static void g(int); - - void test() { - f(&g); - } - }; -} - -// Also rdar://problem/8347416 -namespace test2 { - struct A { - static int foo(short); - static int foo(float); - int foo(int); - int foo(double); - - void test(); - }; - - void A::test() { - // FIXME: The error message in this case is less than clear, we can do - // better. - int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot create a non-constant pointer to member function}} - } -} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp deleted file mode 100644 index 833a4014e8686..0000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// -- prvalue of arithmetic - -bool b = !0; - -bool b2 = !1.2; //expected-warning{{implicit conversion from 'double' to 'bool' changes value from 1.2 to true}} - -bool b3 = !4; - -// -- unscoped enumeration -enum { E, F }; - -bool b4 = !E; -bool b5 = !F; - -// -- pointer, -bool b6 = !&b4; // expected-warning{{address of 'b4' will always evaluate to 'true'}} -void f(); -bool b61 = !&f; - -// -- or pointer to member type can be converted to a prvalue of type bool. -struct S { void f() { } }; - -bool b7 = !&S::f; - - -bool b8 = !S(); //expected-error {{invalid argument type 'S'}} - -namespace PR8181 -{ - bool f() { } // expected-note{{possible target for call}} - void f(char) { } // expected-note{{possible target for call}} - bool b = !&f; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} -} diff --git a/test/CXX/expr/p10-0x.cpp b/test/CXX/expr/p10-0x.cpp deleted file mode 100644 index a42986c85fef2..0000000000000 --- a/test/CXX/expr/p10-0x.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-linux-gnu %s -o - -std=c++11 | FileCheck %s - -volatile int g1; -struct S { - volatile int a; -} g2; - -volatile int& refcall(); - -// CHECK: define void @_Z2f1PViPV1S -void f1(volatile int *x, volatile S* s) { - // We should perform the load in these cases. - // CHECK: load volatile i32, i32* - (*x); - // CHECK: load volatile i32, i32* - __extension__ g1; - // CHECK: load volatile i32, i32* - s->a; - // CHECK: load volatile i32, i32* - g2.a; - // CHECK: load volatile i32, i32* - s->*(&S::a); - // CHECK: load volatile i32, i32* - // CHECK: load volatile i32, i32* - x[0], 1 ? x[0] : *x; - - // CHECK: load volatile i32, i32* - // CHECK: load volatile i32, i32* - // CHECK: load volatile i32, i32* - *x ?: *x; - - // CHECK: load volatile i32, i32* - ({ *x; }); - - // CHECK-NOT: load volatile - // CHECK: ret -} - -// CHECK: define void @_Z2f2PVi -// CHECK-NOT: load volatile -// CHECK: ret -void f2(volatile int *x) { - // We shouldn't perform the load in these cases. - refcall(); - 1 ? refcall() : *x; -} diff --git a/test/CXX/expr/p13.cpp b/test/CXX/expr/p13.cpp deleted file mode 100644 index 0f22ce0b7cebc..0000000000000 --- a/test/CXX/expr/p13.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec - -struct X {}; -struct Y : X {}; - -using A = void (*)() noexcept; -using B = void (*)(); -using C = void (X::*)() noexcept; -using D = void (X::*)(); -using E = void (Y::*)() noexcept; -using F = void (Y::*)(); - -void f(A a, B b, C c, D d, E e, F f, bool k) { - a = k ? a : b; // expected-error {{different exception specifications}} - b = k ? a : b; - - c = k ? c : d; // expected-error {{different exception specifications}} - d = k ? c : d; - - e = k ? c : f; // expected-error {{different exception specifications}} - e = k ? d : e; // expected-error {{different exception specifications}} - f = k ? c : f; - f = k ? d : e; - - const A ak = a; - const B bk = b; - const A &ak2 = k ? ak : ak; - const A &ak3 = k ? ak : bk; // expected-error {{could not bind}} - const B &bk3 = k ? ak : bk; -} - -namespace dynamic_exception_spec { - // Prior to P0012, we had: - // "[...] the target entity shall allow at least the exceptions allowed - // by the source value in the assignment or initialization" - // - // There's really only one way we can coherently apply this to conditional - // expressions: this must hold no matter which branch was taken. - using X = void (*)() throw(int); - using Y = void (*)() throw(float); - using Z = void (*)() throw(int, float); - void g(X x, Y y, Z z, bool k) { - x = k ? X() : Y(); // expected-warning {{not superset}} - y = k ? X() : Y(); // expected-warning {{not superset}} - z = k ? X() : Y(); - - x = k ? x : y; // expected-warning {{not superset}} - y = k ? x : y; // expected-warning {{not superset}} - z = k ? x : y; - } -} diff --git a/test/CXX/expr/p3.cpp b/test/CXX/expr/p3.cpp deleted file mode 100644 index 6b243c26cc315..0000000000000 --- a/test/CXX/expr/p3.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -double operator +(double, double); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}} - -struct A -{ - operator int(); -}; - -int main() -{ - A a, b; - int i0 = a + 1; - int i1 = a + b; -} diff --git a/test/CXX/expr/p8.cpp b/test/CXX/expr/p8.cpp deleted file mode 100644 index 471d1c5a30206..0000000000000 --- a/test/CXX/expr/p8.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -int a0; -const volatile int a1 = 2; -int a2[16]; -int a3(); - -void f0(int); -void f1(int *); -void f2(int (*)()); - -int main() -{ - f0(a0); - f0(a1); - f1(a2); - f2(a3); -} diff --git a/test/CXX/expr/p9.cpp b/test/CXX/expr/p9.cpp deleted file mode 100644 index 4c60b8ba62e42..0000000000000 --- a/test/CXX/expr/p9.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// floating-point overloads - -__typeof__(0 + 0.0L) ld0; -long double &ldr = ld0; - -__typeof__(0 + 0.0) d0; -double &dr = d0; - -__typeof__(0 + 0.0f) f0; -float &fr = f0; - -// integral promotions - -signed char c0; -__typeof__(c0 + c0) c1; -int &cr = c1; - -unsigned char uc0; -__typeof__(uc0 + uc0) uc1; -int &ucr = uc1; - -short s0; -__typeof__(s0 + s0) s1; -int &sr = s1; - -unsigned short us0; -__typeof__(us0 + us0) us1; -int &usr = us1; - -// integral overloads - -__typeof__(0 + 0UL) ul0; -unsigned long &ulr = ul0; - -template<bool T> struct selector; -template<> struct selector<true> { typedef long type; }; -template<> struct selector<false> {typedef unsigned long type; }; -__typeof__(0U + 0L) ui_l0; -selector<(sizeof(long) > sizeof(unsigned int))>::type &ui_lr = ui_l0; - -__typeof__(0 + 0L) l0; -long &lr = l0; - -__typeof__(0 + 0U) u0; -unsigned &ur = u0; - -__typeof__(0 + 0) i0; -int &ir = i0; |