Differential D41284 Diff 209688 test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp

# Changeset View

Changeset View

# Standalone View

Standalone View

# test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp

1 | // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s | 1 | // RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s | ||
---|---|---|---|---|---|

2 | 2 | | |||

3 | namespace nodiag { | 3 | namespace nodiag { | ||

4 | 4 | | |||

5 | template <typename T> requires bool(T()) | 5 | template <typename T> requires bool(T()) | ||

6 | struct A; | 6 | struct A; | ||

7 | template <typename U> requires bool(U()) | 7 | template <typename U> requires bool(U()) | ||

8 | struct A; | 8 | struct A; | ||

9 | 9 | | |||

10 | } // end namespace nodiag | 10 | } // end namespace nodiag | ||

11 | 11 | | |||

12 | namespace diag { | 12 | namespace diag { | ||

13 | 13 | | |||

14 | template <typename T> requires true // expected-note{{previous template declaration is here}} | 14 | template <typename T> requires true // expected-note{{previous template declaration is here}} | ||

15 | struct A; | 15 | struct A; | ||

16 | template <typename T> struct A; // expected-error{{associated constraints differ in template redeclaration}} | 16 | template <typename T> struct A; // expected-error{{requires clause differs in template redeclaration}} | ||

17 | 17 | | |||

18 | template <typename T> struct B; // expected-note{{previous template declaration is here}} | 18 | template <typename T> struct B; // expected-note{{previous template declaration is here}} | ||

19 | template <typename T> requires true // expected-error{{associated constraints differ in template redeclaration}} | 19 | template <typename T> requires true // expected-error{{requires clause differs in template redeclaration}} | ||

20 | struct B; | 20 | struct B; | ||

21 | 21 | | |||

22 | template <typename T> requires true // expected-note{{previous template declaration is here}} | 22 | template <typename T> requires true // expected-note{{previous template declaration is here}} | ||

23 | struct C; | 23 | struct C; | ||

24 | template <typename T> requires !0 // expected-error{{associated constraints differ in template redeclaration}} | 24 | template <typename T> requires !0 // expected-error{{requires clause differs in template redeclaration}} | ||

25 | struct C; | 25 | struct C; | ||

26 | 26 | | |||

27 | } // end namespace diag | 27 | } // end namespace diag | ||

28 | 28 | | |||

29 | namespace nodiag { | 29 | namespace nodiag { | ||

30 | 30 | | |||

31 | struct AA { | 31 | struct AA { | ||

32 | template <typename T> requires someFunc(T()) | 32 | template <typename T> requires someFunc(T()) | ||

33 | struct A; | 33 | struct A; | ||

34 | }; | 34 | }; | ||

35 | 35 | | |||

36 | template <typename T> requires someFunc(T()) | 36 | template <typename U> requires someFunc(U()) | ||

37 | struct AA::A { }; | 37 | struct AA::A { }; | ||

38 | 38 | | |||

39 | struct AAF { | 39 | struct AAF { | ||

40 | template <typename T> requires someFunc(T()) | 40 | template <typename T> requires someFunc(T()) | ||

41 | friend struct AA::A; | 41 | friend struct AA::A; | ||

42 | }; | 42 | }; | ||

43 | 43 | | |||

44 | } // end namespace nodiag | 44 | } // end namespace nodiag | ||

45 | 45 | | |||

46 | namespace diag { | 46 | namespace diag { | ||

47 | 47 | | |||

48 | template <unsigned N> | 48 | template <unsigned N> | ||

49 | struct TA { | 49 | struct TA { | ||

50 | template <template <unsigned> class TT> requires TT<N>::happy // expected-note 2{{previous template declaration is here}} | 50 | template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}} | ||

51 | struct A; | 51 | struct A; | ||

52 | 52 | | |||

53 | template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}} | ||||

54 | struct B; | ||||

55 | | ||||

53 | struct AF; | 56 | struct AF; | ||

54 | }; | 57 | }; | ||

55 | 58 | | |||

56 | template <unsigned N> | 59 | template <unsigned N> | ||

57 | template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{associated constraints differ in template redeclaration}} | 60 | template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{requires clause differs in template redeclaration}} | ||

61 | | ||||

62 | | ||||

63 | template <unsigned N> | ||||

64 | template <template <unsigned> class TT> requires TT<N + 1>::happy struct TA<N>::B { }; // expected-error{{requires clause differs in template redeclaration}} | ||||

58 | 65 | | |||

59 | template <unsigned N> | 66 | template <unsigned N> | ||

60 | struct TA<N>::AF { | 67 | struct TA<N>::AF { | ||

61 | template <template <unsigned> class TT> requires TT<N + 0>::happy // expected-error{{associated constraints differ in template redeclaration}} | 68 | // we do not expect a diagnostic here because the template parameter list is dependent. | ||

69 | template <template <unsigned> class TT> requires TT<N + 0>::happy | ||||

62 | friend struct TA::A; | 70 | friend struct TA::A; | ||

63 | }; | 71 | }; | ||

64 | 72 | | |||

65 | } // end namespace diag | 73 | } // end namespace diag |