brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 61f8b1c Raw
91 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s2 3template<typename T>4struct A {5  template<typename U>6  struct B {7    static constexpr int y = 0;8  };9 10  template<typename U>11  struct B<U*> {12    static constexpr int y = 1;13  };14 15  template<typename U>16  static constexpr int x = 0;17 18  template<typename U>19  static constexpr int x<U*> = 1;20};21 22template<typename T>23template<typename U>24struct A<T>::B<U[]> {25  static constexpr int y = 2;26};27 28template<typename T>29template<typename U>30constexpr int A<T>::x<U[]> = 2;31 32static_assert(A<short>::B<int>::y == 0);33static_assert(A<short>::B<int*>::y == 1);34static_assert(A<short>::B<int[]>::y == 2);35static_assert(A<short>::x<int> == 0);36static_assert(A<short>::x<int*> == 1);37static_assert(A<short>::x<int[]> == 2);38 39template<>40template<typename U>41struct A<int>::B {42  static constexpr int y = 3;43};44 45template<>46template<typename U>47struct A<int>::B<U&> {48  static constexpr int y = 4;49};50 51template<>52template<typename U>53struct A<long>::B<U&> {54  static constexpr int y = 5;55};56 57template<>58template<typename U>59constexpr int A<int>::x = 3;60 61template<>62template<typename U>63constexpr int A<int>::x<U&> = 4;64 65template<>66template<typename U>67constexpr int A<long>::x<U&> = 5;68 69static_assert(A<int>::B<int>::y == 3);70static_assert(A<int>::B<int*>::y == 3);71static_assert(A<int>::B<int[]>::y == 3);72 73// FIXME: This should pass!74static_assert(A<int>::B<int&>::y == 4); // expected-error {{static assertion failed due to requirement 'A<int>::B<int &>::y == 4'}}75                                        // expected-note@-1 {{expression evaluates to '3 == 4'}}76static_assert(A<int>::x<int> == 3);77static_assert(A<int>::x<int*> == 3);78static_assert(A<int>::x<int[]> == 3);79 80// FIXME: This should pass!81static_assert(A<int>::x<int&> == 4); // expected-error {{static assertion failed due to requirement 'A<int>::x<int &> == 4'}}82                                     // expected-note@-1 {{expression evaluates to '3 == 4'}}83static_assert(A<long>::B<int>::y == 0);84static_assert(A<long>::B<int*>::y == 1);85static_assert(A<long>::B<int[]>::y == 2);86static_assert(A<long>::B<int&>::y == 5);87static_assert(A<long>::x<int> == 0);88static_assert(A<long>::x<int*> == 1);89static_assert(A<long>::x<int[]> == 2);90static_assert(A<long>::x<int&> == 5);91