From 15b66535cae9ec01c643b5dde8c45d468ab1ee67 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Sat, 24 Jan 2015 02:48:32 +0000 Subject: When checking the template argument list, use a copy of that list for changes and only update the orginal list on a valid arugment list. When checking an individual expression template argument, and conversions are required, update the expression in the template argument. Since template arguments are speculatively checked, the copying of the template argument list prevents updating the template arguments when the list does not match the template. Additionally, clean up the integer checking code in the template diffing code. The code performs unneccessary conversions from APSInt to APInt. Fixes PR21758. This essentially reverts r224770 to recommits r224667 and r224668 with extra changes to prevent the template instantiation problems seen in PR22006. A test to catch the discovered problem is also added. llvm-svn: 226983 --- clang/test/SemaTemplate/overloaded-functions.cpp | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 clang/test/SemaTemplate/overloaded-functions.cpp (limited to 'clang/test/SemaTemplate/overloaded-functions.cpp') 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 +void Foo() {} + +template +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 +void Bar() {} + +template +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}} +} + -- cgit v1.2.3