summaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-03-13 00:28:45 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-03-13 00:28:45 +0000
commit3fb5afbb70da8cd74e697b1b2ed329b851f9ef20 (patch)
treeca2c85e72ca9605935800f8991a0334ef945b18e /test/SemaTemplate
parentc05006fda51658dc0a2fd551aeceaf90605bfc41 (diff)
downloadclang-3fb5afbb70da8cd74e697b1b2ed329b851f9ef20.tar.gz
clang-3fb5afbb70da8cd74e697b1b2ed329b851f9ef20.tar.bz2
clang-3fb5afbb70da8cd74e697b1b2ed329b851f9ef20.tar.xz
PR18275: If a member function of a class template is declared with a
const-qualified parameter type and the defined with a non-const-qualified parameter type, the parameter is not const inside its body. Ensure that the type we use when instantiating the body is the right one. Patch by suyog sarda! This is still rather unsatisfactory; it seems like it might be better to instantiate at least the function parameters, and maybe the complete function declaration, when we instantiate the definition for such a member function (instead of reusing the declaration from inside the instantiated class definition). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/dependent-type-identity.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/SemaTemplate/dependent-type-identity.cpp b/test/SemaTemplate/dependent-type-identity.cpp
index 731013c863..a796834ce0 100644
--- a/test/SemaTemplate/dependent-type-identity.cpp
+++ b/test/SemaTemplate/dependent-type-identity.cpp
@@ -98,3 +98,27 @@ namespace PR7460 {
template <typename T>
T TemplateClass2<T>::member[TemplateClass2<T>::SIZE];
}
+
+namespace PR18275 {
+ template<typename T> struct A {
+ void f(const int);
+ void g(int);
+ void h(const T);
+ void i(T);
+ };
+
+ template<typename T>
+ void A<T>::f(int x) { x = 0; }
+
+ template<typename T>
+ void A<T>::g(const int x) { x = 0; } // expected-error {{not assignable}}
+
+ template<typename T>
+ void A<T>::h(T) {} // FIXME: Should reject this. Type is different from prior decl if T is an array type.
+
+ template<typename T>
+ void A<T>::i(const T) {} // FIXME: Should reject this. Type is different from prior decl if T is an array type.
+
+ template struct A<int>;
+ template struct A<int[1]>;
+}