xref: /aosp_15_r20/external/clang/test/SemaTemplate/overloaded-functions.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li namespace {
4*67e74705SXin Li template <bool, typename>
Foo()5*67e74705SXin Li void Foo() {}
6*67e74705SXin Li 
7*67e74705SXin Li template <int size>
Foo()8*67e74705SXin Li void Foo() {
9*67e74705SXin Li   int arr[size];
10*67e74705SXin Li   // expected-error@-1 {{'arr' declared as an array with a negative size}}
11*67e74705SXin Li }
12*67e74705SXin Li }
13*67e74705SXin Li 
test_foo()14*67e74705SXin Li void test_foo() {
15*67e74705SXin Li   Foo<-1>();
16*67e74705SXin Li   // expected-note@-1 {{in instantiation of function template specialization '(anonymous namespace)::Foo<-1>' requested here}}
17*67e74705SXin Li }
18*67e74705SXin Li 
19*67e74705SXin Li template <bool, typename>
Bar()20*67e74705SXin Li void Bar() {}
21*67e74705SXin Li 
22*67e74705SXin Li template <int size>
Bar()23*67e74705SXin Li void Bar() {
24*67e74705SXin Li   int arr[size];
25*67e74705SXin Li   // expected-error@-1 {{'arr' declared as an array with a negative size}}
26*67e74705SXin Li }
27*67e74705SXin Li 
test_bar()28*67e74705SXin Li void test_bar() {
29*67e74705SXin Li   Bar<-1>();
30*67e74705SXin Li   // expected-note@-1 {{in instantiation of function template specialization 'Bar<-1>' requested here}}
31*67e74705SXin Li }
32*67e74705SXin Li 
33