diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Misc/diag-template-diffing.cpp | 14 | ||||
-rw-r--r-- | clang/test/SemaTemplate/overloaded-functions.cpp | 32 |
2 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp index bdd6d62fdda..9f4806f64c9 100644 --- a/clang/test/Misc/diag-template-diffing.cpp +++ b/clang/test/Misc/diag-template-diffing.cpp @@ -1247,6 +1247,20 @@ template <class T> using A7 = A<(T::num)>; // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<(T::num), (default) 0>' vs 'A<T::num, 1>') } +namespace TemplateArgumentImplicitConversion { +template <int X> struct condition {}; + +struct is_const { + constexpr operator int() const { return 10; } +}; + +using T = condition<(is_const())>; +void foo(const T &t) { + T &t2 = t; +} +// CHECK-ELIDE-NOTREE: binding of reference to type 'condition<[...]>' to a value of type 'const condition<[...]>' drops qualifiers +} + // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated. diff --git a/clang/test/SemaTemplate/overloaded-functions.cpp b/clang/test/SemaTemplate/overloaded-functions.cpp new file mode 100644 index 00000000000..26565753dd7 --- /dev/null +++ b/clang/test/SemaTemplate/overloaded-functions.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace { +template <bool, typename> +void Foo() {} + +template <int size> +void Foo() { + int arr[size]; + // expected-error@-1 {{'arr' declared as an array with a negative size}} +} +} + +void test_foo() { + Foo<-1>(); + // expected-note@-1 {{in instantiation of function template specialization '(anonymous namespace)::Foo<-1>' requested here}} +} + +template <bool, typename> +void Bar() {} + +template <int size> +void Bar() { + int arr[size]; + // expected-error@-1 {{'arr' declared as an array with a negative size}} +} + +void test_bar() { + Bar<-1>(); + // expected-note@-1 {{in instantiation of function template specialization 'Bar<-1>' requested here}} +} + |