[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

2025-05-09 Thread Jay Feldblum via cfe-commits


@@ -60,3 +61,98 @@ void f3() {
   f2(0);
   f2(0); // expected-error {{no matching function for call to 'f2'}}
 }
+
+#if __cplusplus >= 202002L
+namespace GH138657 {
+template  // #gh138657-template-head
+class meta {};
+template
+class meta {}; // expected-error {{called object type 'int' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'int *' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'char *' is not a 
function or function point}}
+
+struct S {};
+template
+class meta {}; // 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 struct X {};
+template struct A {
+  template
+  A(X<0(Ps)...>, Ts (*...qs)[Ns]);
+  // expected-error@-1{{called object type 'int' is not a function or function 
pointer}}
+
+};
+}
+
+namespace GH68852 {
+template 
+struct constexpr_value {
+  template 
+  constexpr constexpr_value call(Ts...) {
+//expected-error@-1 {{called object type 'int' is not a function or 
function pointer}}
+return {};
+  }
+};
+
+template  constexpr static inline auto c_ = constexpr_value{};
+// expected-note@-1 {{in instantiation of template}}
+auto k = c_<1>; // expected-note {{in instantiation of variable}}
+
+}
+
+namespace GH138731 {

yfeldblum wrote:

This regression test does not need to be limited to C++ >= 20. It uses variable 
templates so it should work with C++ >= 14 as well (provided that this 
definition of `void_t` works). A variation without variable templates would 
work with C++ >= 11. Not sure how important that all is.

https://github.com/llvm/llvm-project/pull/139246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

2025-05-09 Thread Jay Feldblum via cfe-commits


@@ -60,3 +61,98 @@ void f3() {
   f2(0);
   f2(0); // expected-error {{no matching function for call to 'f2'}}
 }
+
+#if __cplusplus >= 202002L
+namespace GH138657 {
+template  // #gh138657-template-head
+class meta {};
+template
+class meta {}; // expected-error {{called object type 'int' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'int *' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'char *' is not a 
function or function point}}
+
+struct S {};
+template
+class meta {}; // 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 struct X {};
+template struct A {
+  template
+  A(X<0(Ps)...>, Ts (*...qs)[Ns]);
+  // expected-error@-1{{called object type 'int' is not a function or function 
pointer}}
+
+};
+}
+
+namespace GH68852 {
+template 
+struct constexpr_value {
+  template 
+  constexpr constexpr_value call(Ts...) {
+//expected-error@-1 {{called object type 'int' is not a function or 
function pointer}}
+return {};
+  }
+};
+
+template  constexpr static inline auto c_ = constexpr_value{};
+// expected-note@-1 {{in instantiation of template}}
+auto k = c_<1>; // expected-note {{in instantiation of variable}}
+
+}
+
+namespace GH138731 {
+template 
+using void_t = void;
+template 
+using void_t = void;

yfeldblum wrote:

Duplicate definitions of `void_`. May be deduplicated.

https://github.com/llvm/llvm-project/pull/139246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits