-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang] NFC: add a few template template parameter test cases #160230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) ChangesI also posted these on the core reflector today. Full diff: https://github.com/llvm/llvm-project/pull/160230.diff 2 Files Affected:
diff --git a/clang/test/SemaTemplate/cwg2398.cpp b/clang/test/SemaTemplate/cwg2398.cpp
index 06333c81a603e..315fa952932c5 100644
--- a/clang/test/SemaTemplate/cwg2398.cpp
+++ b/clang/test/SemaTemplate/cwg2398.cpp
@@ -672,3 +672,22 @@ namespace nttp_partial_order {
template void f<B>(B<nullptr>);
} // namespace t6
} // namespace nttp_partial_order
+
+namespace nttp_inconsistent {
+ namespace t1 {
+ template<class A, A B> struct X {};
+ // expected-error@-1 {{conflicting deduction 'C' against 'int' for parameter}}
+ template<template<class C, int D> class TT> struct Y {};
+ // expected-note@-1 {{previous template template parameter is here}}
+ template struct Y<X>;
+ // expected-note@-1 {{has different template parameters}}
+ } // namespace t1
+ namespace t2 {
+ template<class A, A B = 0> struct X {};
+ // expected-error@-1 {{conflicting deduction 'C' against 'int' for parameter}}
+ template<template<class C> class TT> struct Y {};
+ // expected-note@-1 {{previous template template parameter is here}}
+ template struct Y<X>;
+ // expected-note@-1 {{has different template parameters}}
+ } // namespace t2
+} // namespace nttp_inconsistent
diff --git a/clang/test/SemaTemplate/temp_arg_template.cpp b/clang/test/SemaTemplate/temp_arg_template.cpp
index c9576e2057e53..3d71061f9cfd5 100644
--- a/clang/test/SemaTemplate/temp_arg_template.cpp
+++ b/clang/test/SemaTemplate/temp_arg_template.cpp
@@ -168,3 +168,28 @@ namespace PR10147 {
template<template<typename...> class A> void f(A<int>*) { A<> a; } // expected-warning 0-1{{extension}}
void g() { f((A<>*)0); }
}
+
+namespace multiple_conversions {
+ constexpr int g = 1;
+ struct Z {
+ constexpr operator const int&() const { return g; }
+ constexpr operator int() { return 2; }
+ } z;
+
+ template<template<const int&> class TT> struct A {
+ // precxx17-note@-1 {{template parameter is declared here}}
+ static constexpr int value = TT<z>::value;
+ // precxx17-error@-1 {{'const int &' cannot bind to template argument of type 'struct Z'}}
+ // FIXME: Bad error recovery.
+ // precxx17-error@-3 {{requires an initializer}}
+ };
+
+ template<int I> struct B {
+ static constexpr int value = I;
+ };
+ // FIXME: This should probably convert z to (const int &) first, then
+ // convert that to int.
+ static_assert(A<B>::value == 1);
+ // cxx17-error@-1 {{static assertion failed}}
+ // cxx17-note@-2 {{expression evaluates to '2 == 1'}}
+} // namespace multiple_conversions
|
I also posted these on the core reflector today.
068855e
to
554e56e
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/72/builds/15183 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/18375 Here is the relevant piece of the build log for the reference
|
I also posted these on the core reflector today.