diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-11 00:19:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-11 00:19:33 +0000 |
commit | 3a7796bccc3682d1d206d62f367ec409cdfd21f5 (patch) | |
tree | e72469db2dd718c320fbfb8729bfc1e2406644a9 /clang/test | |
parent | c8dcf4d72bec6eb1b0402941fe4e865eb7c39f83 (diff) | |
download | bcm5719-llvm-3a7796bccc3682d1d206d62f367ec409cdfd21f5.tar.gz bcm5719-llvm-3a7796bccc3682d1d206d62f367ec409cdfd21f5.zip |
Add partial semantic checking of template arguments that are meant for
non-type template parameters of pointer-to-object and
pointer-to-function type. The most fun part of this is the use of
overload resolution to pick a function from the set of overloaded
functions that comes in as a template argument.
Also, fixed two minor bugs in this area:
- We were allowing non-type template parameters of type pointer to
void.
- We weren't patching up an expression that refers to an overloaded
function set via "&f" properly.
We're still not performing complete checking of the expression to be
sure that it is referring to an object or function with external
linkage (C++ [temp.arg.nontype]p1).
llvm-svn: 64266
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype.cpp | 29 | ||||
-rw-r--r-- | clang/test/SemaTemplate/temp_param.cpp | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp index 46d92c537b1..4b1db5ad687 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp @@ -33,8 +33,37 @@ A<f(17)> *a10; // expected-error{{non-type template argument of type 'int' is no class X { public: + X(); X(int, int); operator int() const; }; A<X(17, 42)> *a11; // expected-error{{non-type template argument of type 'class X' must have an integral or enumeration type}} \ // FIXME:expected-error{{expected unqualified-id}} + +template<X const *Ptr> struct A2; + +X *X_ptr; +X array_of_Xs[10]; +A2<X_ptr> *a12; +A2<array_of_Xs> *a13; + +float f(float); + +float g(float); +double g(double); + +int h(int); +float h2(float); + +template<int fp(int)> struct A3; // expected-note 2{{template parameter is declared here}} +A3<h> *a14_1; +A3<&h> *a14_2; +A3<f> *a14_3; +A3<&f> *a14_4; +A3<((&f))> *a14_5; +A3<h2> *a14_6; // expected-error{{non-type template argument of type 'float (*)(float)' cannot be converted to a value of type 'int (*)(int)'}} \ +// FIXME: expected-error{{expected unqualified-id}} +A3<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (*)(int)'}}\ +// FIXME: expected-error{{expected unqualified-id}} +// FIXME: the first error includes the string <overloaded function +// type>, which makes Doug slightly unhappy. diff --git a/clang/test/SemaTemplate/temp_param.cpp b/clang/test/SemaTemplate/temp_param.cpp index e45d45629a5..1f10cc49c10 100644 --- a/clang/test/SemaTemplate/temp_param.cpp +++ b/clang/test/SemaTemplate/temp_param.cpp @@ -18,6 +18,7 @@ template<typename T, T x> struct A10; template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} +template<void *Ptr> struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}} // C++ [temp.param]p8 template<int X[10]> struct A5; |