Skip to content

Commit 15f05dc

Browse files
authored
[clang] NFC: add a few template template parameter test cases (#160230)
I also posted these on the core reflector today.
1 parent 9008c44 commit 15f05dc

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

clang/test/SemaTemplate/cwg2398.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,3 +672,22 @@ namespace nttp_partial_order {
672672
template void f<B>(B<nullptr>);
673673
} // namespace t6
674674
} // namespace nttp_partial_order
675+
676+
namespace nttp_inconsistent {
677+
namespace t1 {
678+
template<class A, A B> struct X {};
679+
// expected-error@-1 {{conflicting deduction 'C' against 'int' for parameter}}
680+
template<template<class C, int D> class TT> struct Y {};
681+
// expected-note@-1 {{previous template template parameter is here}}
682+
template struct Y<X>;
683+
// expected-note@-1 {{has different template parameters}}
684+
} // namespace t1
685+
namespace t2 {
686+
template<class A, A B = 0> struct X {};
687+
// expected-error@-1 {{conflicting deduction 'C' against 'int' for parameter}}
688+
template<template<class C> class TT> struct Y {};
689+
// expected-note@-1 {{previous template template parameter is here}}
690+
template struct Y<X>;
691+
// expected-note@-1 {{has different template parameters}}
692+
} // namespace t2
693+
} // namespace nttp_inconsistent

clang/test/SemaTemplate/temp_arg_template.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,26 @@ namespace PR10147 {
168168
template<template<typename...> class A> void f(A<int>*) { A<> a; } // expected-warning 0-1{{extension}}
169169
void g() { f((A<>*)0); }
170170
}
171+
172+
#if __cplusplus >= 201703L
173+
namespace multiple_conversions {
174+
constexpr int g = 1;
175+
struct Z {
176+
constexpr operator const int&() const { return g; }
177+
constexpr operator int() { return 2; }
178+
} z;
179+
180+
template<template<const int&> class TT> struct A {
181+
static constexpr int value = TT<z>::value;
182+
};
183+
184+
template<int I> struct B {
185+
static constexpr int value = I;
186+
};
187+
// FIXME: This should probably convert z to (const int &) first, then
188+
// convert that to int.
189+
static_assert(A<B>::value == 1);
190+
// cxx17-error@-1 {{static assertion failed}}
191+
// cxx17-note@-2 {{expression evaluates to '2 == 1'}}
192+
} // namespace multiple_conversions
193+
#endif

0 commit comments

Comments
 (0)