[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)
Jay Feldblum via cfe-commits
cfe-commits at lists.llvm.org
Fri May 9 10:11:55 PDT 2025
================
@@ -60,3 +61,98 @@ void f3() {
f2<int*>(0);
f2<int>(0); // expected-error {{no matching function for call to 'f2'}}
}
+
+#if __cplusplus >= 202002L
+namespace GH138657 {
+template <auto V> // #gh138657-template-head
+class meta {};
+template<int N>
+class meta<N()> {}; // expected-error {{called object type 'int' is not a function or function point}}
+
+template<int N[1]>
+class meta<N()> {}; // expected-error {{called object type 'int *' is not a function or function point}}
+
+template<char* N>
+class meta<N()> {}; // expected-error {{called object type 'char *' is not a function or function point}}
+
+struct S {};
+template<S>
+class meta<S()> {}; // expected-error {{template argument for non-type template parameter is treated as function type 'S ()'}}
+ // expected-note@#gh138657-template-head {{template parameter is declared here}}
+
+}
+
+namespace GH115725 {
+template<auto ...> struct X {};
+template<typename T, typename ...Ts> struct A {
+ template<Ts ...Ns, T *...Ps>
+ A(X<0(Ps)...>, Ts (*...qs)[Ns]);
+ // expected-error at -1{{called object type 'int' is not a function or function pointer}}
+
+};
+}
+
+namespace GH68852 {
+template <auto v>
+struct constexpr_value {
+ template <class... Ts>
+ constexpr constexpr_value<v(Ts::value...)> call(Ts...) {
+ //expected-error at -1 {{called object type 'int' is not a function or function pointer}}
+ return {};
+ }
+};
+
+template <auto v> constexpr static inline auto c_ = constexpr_value<v>{};
+// expected-note at -1 {{in instantiation of template}}
+auto k = c_<1>; // expected-note {{in instantiation of variable}}
+
+}
+
+namespace GH138731 {
+template <class...>
+using void_t = void;
+template <class...>
+using void_t = void;
----------------
yfeldblum wrote:
Duplicate definitions of `void_`. May be deduplicated.
https://github.com/llvm/llvm-project/pull/139246
More information about the cfe-commits
mailing list