overloaded-functions.cpp 696 B

1234567891011121314151617181920212223242526272829303132
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. namespace {
  3. template <bool, typename>
  4. void Foo() {}
  5. template <int size>
  6. void Foo() {
  7. int arr[size];
  8. // expected-error@-1 {{'arr' declared as an array with a negative size}}
  9. }
  10. }
  11. void test_foo() {
  12. Foo<-1>();
  13. // expected-note@-1 {{in instantiation of function template specialization '(anonymous namespace)::Foo<-1>' requested here}}
  14. }
  15. template <bool, typename>
  16. void Bar() {}
  17. template <int size>
  18. void Bar() {
  19. int arr[size];
  20. // expected-error@-1 {{'arr' declared as an array with a negative size}}
  21. }
  22. void test_bar() {
  23. Bar<-1>();
  24. // expected-note@-1 {{in instantiation of function template specialization 'Bar<-1>' requested here}}
  25. }