brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.9 KiB · 4db0d2a Raw
230 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -x objective-c++ -fobjc-arc -fenable-matrix -triple i686-pc-win322 3enum class N {};4 5using B1 = int;6using X1 = B1;7using Y1 = B1;8 9using B2 = void;10using X2 = B2;11using Y2 = B2;12 13using A3 = char __attribute__((vector_size(4)));14using B3 = A3;15using X3 = B3;16using Y3 = B3;17 18using A4 = float;19using B4 = A4 __attribute__((matrix_type(4, 4)));20using X4 = B4;21using Y4 = B4;22 23using X5 = A4 __attribute__((matrix_type(3, 4)));24using Y5 = A4 __attribute__((matrix_type(4, 3)));25 26N t1 = 0 ? X1() : Y1(); // expected-error {{rvalue of type 'B1'}}27N t2 = 0 ? X2() : Y2(); // expected-error {{rvalue of type 'B2'}}28 29const X1 &xt3 = 0;30const Y1 &yt3 = 0;31N t3 = 0 ? xt3 : yt3; // expected-error {{lvalue of type 'const B1'}}32 33N t4 = X3() + Y3();   // expected-error {{rvalue of type 'B3'}}34 35N t5 = A3() ? X3() : Y3(); // expected-error {{rvalue of type 'B3'}}36N t6 = A3() ? X1() : Y1(); // expected-error {{vector condition type 'A3' (vector of 4 'char' values) and result type '__attribute__((__vector_size__(4 * sizeof(B1)))) B1' (vector of 4 'B1' values) do not have elements of the same size}}37 38N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}39N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}40N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}41 42template <class T> struct S1 {43  template <class U> struct S2 {};44};45 46N t10 = 0 ? S1<X1>() : S1<Y1>(); // expected-error {{from 'S1<B1>' (aka 'S1<int>')}}47// FIXME: needs to compute common sugar for qualified template names48N t11 = 0 ? S1<X1>::S2<X2>() : S1<Y1>::S2<Y2>(); // expected-error {{from 'S1<int>::S2<B2>' (aka 'S1<int>::S2<void>')}}49 50template <class T> using Al = S1<T>;51 52N t12 = 0 ? Al<X1>() : Al<Y1>(); // expected-error {{from 'Al<B1>' (aka 'S1<int>')}}53 54#define AS1 __attribute__((address_space(1)))55#define AS2 __attribute__((address_space(1)))56using AS1X1 = AS1 B1;57using AS1Y1 = AS1 B1;58using AS2Y1 = AS2 B1;59N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}60N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}61 62using FX1 = X1 ();63using FY1 = Y1 ();64N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}65 66struct SS1 {};67using SB1 = SS1;68using SX1 = SB1;69using SY1 = SB1;70 71using MFX1 = X1 SX1::*();72using MFY1 = Y1 SY1::*();73 74N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}75 76N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}77 78N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}79 80struct Enums {81  enum X : B1;82  enum Y : ::B1;83};84using EnumsB = Enums;85using EnumsX = EnumsB;86using EnumsY = EnumsB;87 88N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};89// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}90 91N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};92// expected-error@-1 {{rvalue of type '__underlying_type(EnumsB::X)' (aka 'int')}}93 94using QX = const SB1 *;95using QY = const ::SB1 *;96N t23 = 0 ? (QX){} : (QY){}; // expected-error {{rvalue of type 'const SB1 *' (aka 'const SS1 *')}}97 98template <class T> using Alias = short;99N t24 = 0 ? (Alias<X1>){} : (Alias<Y1>){}; // expected-error {{rvalue of type 'Alias<B1>' (aka 'short')}}100N t25 = 0 ? (Alias<X1>){} : (Alias<X2>){}; // expected-error {{rvalue of type 'short'}}101 102template <class T, class U> concept C1 = true;103template <class T, class U> concept C2 = true;104C1<X1> auto t26_1 = (SB1){};105C1<X2> auto t26_2 = (::SB1){};106C2<X2> auto t26_3 = (::SB1){};107N t26 = 0 ? t26_1 : t26_2; // expected-error {{from 'SB1' (aka 'SS1')}}108N t27 = 0 ? t26_1 : t26_3; // expected-error {{from 'SB1' (aka 'SS1')}}109 110using RPB1 = X1*;111using RPX1 = RPB1;112using RPB1 = Y1*; // redeclared113using RPY1 = RPB1;114N t28 = *(RPB1){}; // expected-error {{lvalue of type 'Y1' (aka 'int')}}115auto t29 = 0 ? (RPX1){} : (RPY1){};116N t30 = t29;  // expected-error {{lvalue of type 'RPB1' (aka 'int *')}}117N t31 = *t29; // expected-error {{lvalue of type 'B1' (aka 'int')}}118 119namespace A { using type1 = X1*; };120namespace C { using A::type1; };121using UPX1 = C::type1;122namespace A { using type1 = Y1*; };  // redeclared123namespace C { using A::type1; };     // redeclared124using UPY1 = C::type1;125auto t32 = 0 ? (UPX1){} : (UPY1){};126N t33 = t32;  // expected-error {{lvalue of type 'C::type1' (aka 'int *')}}127N t34 = *t32; // expected-error {{lvalue of type 'B1' (aka 'int')}}128 129// See https://github.com/llvm/llvm-project/issues/61419130namespace PR61419 {131  template <class T0, class T1> struct pair {132    T0 first;133    T1 second;134  };135 136  extern const pair<id, id> p;137  id t = false ? p.first : p.second;138} // namespace PR61419139 140namespace GH67603 {141  template <class> using A = long;142  template <class B> void h() {143    using C = B;144    using D = B;145    N t = 0 ? A<decltype(C())>() : A<decltype(D())>();146    // expected-error@-1 {{rvalue of type 'A<decltype(C())>' (aka 'long')}}147  }148  template void h<int>();149} // namespace GH67603150 151namespace arrays {152  namespace same_canonical {153    using ConstB1I = const B1[];154    using ConstB1C = const B1[1];155    const ConstB1I a = {0};156    const ConstB1C b = {0};157    N ta = a;158    // expected-error@-1 {{lvalue of type 'const B1[1]' (aka 'const int[1]')}}159    N tb = b;160    // expected-error@-1 {{lvalue of type 'const ConstB1C' (aka 'const const int[1]')}}161    N tc = 0 ? a : b;162    // expected-error@-1 {{lvalue of type 'const B1[1]' (aka 'const int[1]')}}163  } // namespace same_canonical164  namespace same_element {165    using ConstB1 = const B1;166    using ConstB1I = ConstB1[];167    using ConstB1C = ConstB1[1];168    const ConstB1I a = {0};169    const ConstB1C b = {0};170    N ta = a;171    // expected-error@-1 {{lvalue of type 'const ConstB1[1]' (aka 'const int[1]')}}172    N tb = b;173    // expected-error@-1 {{lvalue of type 'const ConstB1C' (aka 'const const int[1]')}}174    N tc = 0 ? a : b;175    // expected-error@-1 {{lvalue of type 'ConstB1[1]' (aka 'const int[1]')}}176  } // namespace same_element177  namespace balanced_qualifiers {178    using ConstX1C = const volatile X1[1];179    using Y1C = volatile Y1[1];180    extern volatile ConstX1C a;181    extern const volatile Y1C b;182    N ta = a;183    // expected-error@-1 {{lvalue of type 'volatile ConstX1C' (aka 'volatile const volatile int[1]')}}184    N tb = b;185    // expected-error@-1 {{lvalue of type 'const volatile Y1C' (aka 'const volatile volatile int[1]')}}186    N tc = 0 ? a : b;187    // expected-error@-1 {{lvalue of type 'const volatile volatile B1[1]' (aka 'const volatile volatile int[1]')}}188  } // namespace balanced_qualifiers189} // namespace arrays190 191namespace member_pointers {192  template <class T> struct W {193    X1 a;194    Y1 b;195  };196  struct W1 : W<X2> {};197  struct W2 : W<Y2> {};198 199  N t1 = 0 ? &W<X2>::a : &W<Y2>::b;200  // expected-error@-1 {{rvalue of type 'B1 W<B2>::*'}}201 202  // FIXME: adjusted MemberPointer does not preserve qualifier203  N t3 = 0 ? &W1::a : &W2::b;204  // expected-error@-1 {{rvalue of type 'B1 member_pointers::W<void>::*'}}205} // namespace member_pointers206 207namespace FunctionTypeExtInfo {208  namespace RecordType {209    class A;210    void (*x)(__attribute__((swift_async_context)) A *);211 212    class A;213    void (*y)(__attribute__((swift_async_context)) A *);214 215    N t1 = 0 ? x : y;216    // expected-error@-1 {{lvalue of type 'void (*)(__attribute__((swift_async_context)) A *)'}}217  } // namespace RecordType218  namespace TypedefType {219    class A;220    using B = A;221    void (*x)(__attribute__((swift_async_context)) B *);222 223    using B = A;224    void (*y)(__attribute__((swift_async_context)) B *);225 226    N t1 = 0 ? x : y;227    // expected-error@-1 {{lvalue of type 'void (*)(__attribute__((swift_async_context)) B *)'}}228  } // namespace TypedefType229} // namespace FunctionTypeExtInfo230