summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/temp/temp.decls/temp.variadic
Commit message (Collapse)AuthorAgeFilesLines
...
* When we're instantiating a direct variable initializer that has a packDouglas Gregor2011-01-141-0/+9
| | | | | | | | expansion in it, we may end up instantiating to an empty expression-list. In this case, the variable is uninitialized; tweak the instantiation logic to handle this case. Fixes PR8977. llvm-svn: 123449
* Keep track of the number of expansions to be produced from a type packDouglas Gregor2011-01-141-3/+10
| | | | | | | | | | | | | | | | | | | | | | | expansion, when it is known due to the substitution of an out parameter pack. This allows us to properly handle substitution into pack expansions that involve multiple parameter packs at different template parameter levels, even when this substitution happens one level at a time (as with partial specializations of member class templates and the signatures of member function templates). Note that the diagnostic we provide when there is an arity mismatch between an outer parameter pack and an inner parameter pack in this case isn't as clear as the normal diagnostic for an arity mismatch. However, this doesn't matter because these cases are very, very rare and (even then) only typically occur in a SFINAE context. The other kinds of pack expansions (expression, template, etc.) still need to support optional tracking of the number of expansions, and we need the moral equivalent of SubstTemplateTypeParmPackType for substituted argument packs of template template and non-type template parameters. llvm-svn: 123448
* Start implementing support for substitution into pack expansions thatDouglas Gregor2011-01-141-0/+20
| | | | | | | | | | | | | | | | | involve template parameter packs at multiple template levels that occur within the signatures members of class templates (and partial specializations thereof). This is a work-in-progress that is deficient in several ways, notably: - It only works for template type parameter packs, but we need to also support non-type template parameter packs and template template parameter packs. - It doesn't keep track of the lengths of the substituted argument packs in the expansion, so it can't properly diagnose length mismatches. However, this is a concrete step in the right direction. llvm-svn: 123425
* Only apply the parameter pack matching of C++0x [temp.arg.template]p3Douglas Gregor2011-01-131-0/+16
| | | | | | | | | when we're actually matching a template template argument to a template template parameter. Otherwise, use strict matching. Fixes <rdar://problem/8859985> clang++: variadics and out-of-line definitions. llvm-svn: 123385
* Allow us to transform pack expansion expressions.Douglas Gregor2011-01-131-0/+16
| | | | llvm-svn: 123349
* Implement C++0x [temp.arg.template]p3, which allows slightly fuzzyDouglas Gregor2011-01-131-0/+17
| | | | | | | | matching of variadic template template parameters to template arguments. This paragraph was the subject of ISO C++ committee document N2555: Extending Variadic Template Template Parameters. llvm-svn: 123348
* Add some more partial-ordering tests, including one that changes withDouglas Gregor2011-01-121-0/+33
| | | | | | | the proposed resolution to core isue 692. I'm not certain which way we'll go on this one. llvm-svn: 123331
* Teach TreeTransform how to transform a pack expansion type intoDouglas Gregor2011-01-121-0/+18
| | | | | | | | | another pack expansion type. This can happen when rebuilding types in the current instantiation. Fixes <rdar://problem/8848837> (Clang crashing on libc++ <functional>). llvm-svn: 123316
* Implement partial ordering of class template partial specializationsDouglas Gregor2011-01-111-0/+30
| | | | | | | | | | | | | | | | | | | | | | and function templates that contain variadic templates. This involves three small-ish changes: (1) When transforming a pack expansion, if the transformed argument still contains unexpanded parameter packs, build a pack expansion. This can happen during the substitution that occurs into class template partial specialiation template arguments during partial ordering. (2) When performing template argument deduction where the argument is a pack expansion, match against the pattern of that pack expansion. (3) When performing template argument deduction against a non-pack parameter, or a non-expansion template argument, deduction fails if the argument itself is a pack expansion (C++0x [temp.deduct.type]p22). llvm-svn: 123279
* Add testing for unexpanded parameter packs in all of the C++Douglas Gregor2011-01-111-1/+128
| | | | | | | | expression kinds. This is (indirectly) a test verifying that the recursive AST visitor is visiting the children of these expression nodes. llvm-svn: 123198
* Work-in-progress implementation of C++0x [temp.arg.explicit]p9, whichDouglas Gregor2011-01-102-4/+352
| | | | | | | | | | | | | | | | | | | | | | | | | | allows an argument pack determines via explicit specification of function template arguments to be extended by further, deduced arguments. For example: template<class ... Types> void f(Types ... values); void g() { f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int } There are a number of FIXMEs in here that indicate places where we need to implement + test retained expansions, plus a number of other places in deduction where we need to correctly cope with the explicitly-specified arguments when deducing an argument pack. Furthermore, it appears that the RecursiveASTVisitor needs to be auditied; it's missing some traversals (especially w.r.t. template arguments) that cause it not to find unexpanded parameter packs when it should. The good news, however, is that the tr1::tuple implementation now works fully, and the tr1::bind example (both from N2080) is actually working now. llvm-svn: 123163
* Variadic templates example: a nearly-complete implementation of a TR1Douglas Gregor2011-01-072-1/+87
| | | | | | function class template. llvm-svn: 123024
* Variadic templates example: a nearly-complete implementation of a TR1Douglas Gregor2011-01-071-0/+264
| | | | | | | | | | tuple class template. This implementation is boosted directly from the variadic templates proposal. N2080. Note that one section is #ifdef'd out. I'll implement that aspect of template argument deduction next. llvm-svn: 123016
* Implement substitution of a function parameter pack for its set ofDouglas Gregor2011-01-072-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | instantiated function parameters, enabling instantiation of arbitrary pack expansions involving function parameter packs. At this point, we can now correctly compile a simple, variadic print() example: #include <iostream> #include <string> void print() {} template<typename Head, typename ...Tail> void print(const Head &head, const Tail &...tail) { std::cout << head; print(tail...); } int main() { std::string hello = "Hello"; print(hello, ", world!", " ", 2011, '\n'); } llvm-svn: 123000
* Initial implementation of function parameter packs. This implementation allows:Douglas Gregor2011-01-051-0/+24
| | | | | | | | | | | | | | 1) Declaration of function parameter packs 2) Instantiation of function parameter packs within function types. 3) Template argument deduction of function parameter packs when matching two function types. We're missing all of the important template-instantiation logic for function template definitions, along with template argument deduction from the argument list of a function call, so don't even think of trying to use these for real yet. llvm-svn: 122926
* When we're converting deduced template arguments to the type of theDouglas Gregor2011-01-051-0/+27
| | | | | | | corresponding template parameter, make sure that prior converted template arguments are available for substitution. llvm-svn: 122902
* Replace the representation of template template argument packDouglas Gregor2011-01-052-1/+41
| | | | | | | | | | | | | expansions with something that is easier to use correctly: a new template argment kind, rather than a bit on an existing kind. Update all of the switch statements that deal with template arguments, fixing a few latent bugs in the process. I"m happy with this representation, now. And, oh look! Template instantiation and deduction work for template template argument pack expansions. llvm-svn: 122896
* Implement proper parameter pack matching for non-type templateDouglas Gregor2011-01-051-7/+11
| | | | | | parameters and template template parameters. llvm-svn: 122875
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-053-0/+33
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Improve our handling of non-type template parameters in partialDouglas Gregor2011-01-041-0/+25
| | | | | | | | | | | | | specializations. We weren't dealing with any of the cases where the type of the non-type template argument differs from the type of the corresponding template parameter in the primary template. We would think that the template parameter in the partial specialization was not deducible (and warn about it, incorrectly), then fail to convert a deduced parameter to the type of the template parameter in the partial specialization (which may involve truncation, among other things). Fixes PR8905. llvm-svn: 122851
* Improve the checking of deduced template arguments stored within template ↵Douglas Gregor2011-01-041-0/+25
| | | | | | argument packs when finishing template argument deduction for a function template llvm-svn: 122843
* When creating the injected-class-name for a class template involving aDouglas Gregor2011-01-041-3/+0
| | | | | | | non-type template parameter pack, make sure to create a pack expansion for the corresponding template argument. llvm-svn: 122799
* Implement pack expansion of base initializers, so that we canDouglas Gregor2011-01-041-2/+30
| | | | | | | initialize those lovely mixins that come from pack expansions of base specifiers. llvm-svn: 122793
* Implement pack expansions whose pattern is a base-specifier.Douglas Gregor2011-01-031-0/+18
| | | | llvm-svn: 122782
* Add a test that is currently failingDouglas Gregor2011-01-031-0/+14
| | | | llvm-svn: 122780
* Properly rebuild pack expansions whose pattern is a non-type templateDouglas Gregor2011-01-032-1/+13
| | | | | | | argument. As part of this, be more careful when determining if there are any parameter packs that cannot be expanded. llvm-svn: 122776
* Diagnose the presence of unexpanded parameter packs within classDouglas Gregor2011-01-031-4/+4
| | | | | | template partial specialization arguments. llvm-svn: 122769
* Implement support for pack expansions in initializer lists andDouglas Gregor2011-01-031-0/+14
| | | | | | expression lists. llvm-svn: 122764
* Another variadic template metafunction test case: summing values.Douglas Gregor2011-01-031-2/+16
| | | | llvm-svn: 122752
* Implement support for pack expansions whose pattern is a non-typeDouglas Gregor2011-01-031-0/+49
| | | | | | | | | | | | | | | | | template argument (described by an expression, of course). For example: template<int...> struct int_tuple { }; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; It also lays the foundation for pack expansions in an initializer-list. llvm-svn: 122751
* Consolidate template metafunction tests for variadic templates into a single ↵Douglas Gregor2011-01-032-28/+32
| | | | | | file llvm-svn: 122748
* When instantiating a non-type template parameter pack, be sure toDouglas Gregor2010-12-241-5/+25
| | | | | | | | extract the appropriate argument from the argument pack (based on the current substitution index, of course). Simple instantiation of pack expansions involving non-type template parameter packs now works. llvm-svn: 122532
* Add an AST representation for non-type template parameterDouglas Gregor2010-12-231-0/+20
| | | | | | | | | | | | | | packs, e.g., template<typename T, unsigned ...Dims> struct multi_array; along with semantic analysis support for finding unexpanded non-type template parameter packs in types, expressions, and so on. Template instantiation involving non-type template parameter packs probably doesn't work yet. That'll come soon. llvm-svn: 122527
* When forming the injected-class-name of a variadic template, theDouglas Gregor2010-12-231-0/+41
| | | | | | | | | template argument corresponding to a template parameter pack is an argument pack of a pack expansion of that template parameter pack. Implements C++0x [temp.dep.type]p2 (at least, as much of it as we can). llvm-svn: 122498
* Implement template argument deduction for pack expansions whoseDouglas Gregor2010-12-221-11/+30
| | | | | | | | | | | pattern is a template argument, which involves repeatedly deducing template arguments using the pattern of the pack expansion, then bundling the resulting deductions into an argument pack. We can now handle a variety of simple list-handling metaprograms using variadic templates. See, e.g., the new "count" metaprogram. llvm-svn: 122439
* When performing template argument deduction where the argument is aDouglas Gregor2010-12-221-0/+26
| | | | | | | | | | dependent template specialization type, the number of template arguments need not match precisely. Rather than checking the number of arguments eagerly (which does not consider argument packs), let the deduction routine for template argument lists cope with too many/too few arguments. llvm-svn: 122425
* Implicitly expand argument packs when performing template argumentDouglas Gregor2010-12-221-0/+17
| | | | | | | | | | | | deduction. Unify all of the looping over template arguments for deduction purposes into a single place, where argument pack expansion occurs; this is also the hook for deducing from pack expansions, which itself is not yet implemented. For now, at least we can handle a basic "count" metafunction written with variadics. See the new test for the formulation that works. llvm-svn: 122418
* Implement instantiation of pack expansions whose pattern is a type-idDouglas Gregor2010-12-211-6/+6
| | | | | | in an exception specification. llvm-svn: 122297
* Extend the parser to support pack expansions within exceptionDouglas Gregor2010-12-201-0/+18
| | | | | | | specifications. We can't yet instantiate them, however, since I tripped over PR8835. llvm-svn: 122292
* Test template instantiation of pack expansions where the parameter pack is ↵Douglas Gregor2010-12-201-3/+16
| | | | | | in a nested-name-specifier llvm-svn: 122282
* Clean up the printing of template argument packs; previously, we wereDouglas Gregor2010-12-202-2/+2
| | | | | | getting extra "<>" delimiters around template argument packs. llvm-svn: 122280
* Implement basic support for template instantiation of pack expansionsDouglas Gregor2010-12-202-0/+34
| | | | | | | | | | | | | | | | | whose patterns are template arguments. We can now instantiate, e.g., typedef tuple<pair<OuterTypes, InnerTypes>...> type; where OuterTypes and InnerTypes are template type parameter packs. There is a horrible inefficiency in TemplateArgumentLoc::getPackExpansionPattern(), where we need to create copies of TypeLoc data because our interfaces traffic in TypeSourceInfo pointers where they should traffic in TypeLocs instead. I've isolated in efficiency in this one routine; once we refactor our interfaces to traffic in TypeLocs, we can eliminate it. llvm-svn: 122278
* When checking a template argument list against a template containingDouglas Gregor2010-12-201-0/+9
| | | | | | | | | | | | a parameter pack, check the parameter pack against each of the template arguments it corresponds to, then pack the converted arguments into a template argument pack. Allows us to use variadic class templates so long as instantiation isn't required, e.g., template<typename... Types> struct Tuple; Tuple<int, float> *t2; llvm-svn: 122251
* Introduce a new type, PackExpansionType, to capture types that areDouglas Gregor2010-12-201-2/+14
| | | | | | | | | | | | | | | | | | | | pack expansions, e.g. given template<typename... Types> struct tuple; template<typename... Types> struct tuple_of_refs { typedef tuple<Types&...> types; }; the type of the "types" typedef is a PackExpansionType whose pattern is Types&. This commit introduces support for creating pack expansions for template type arguments, as above, but not for any other kind of pack expansion, nor for any form of instantiation. llvm-svn: 122223
* Add tests checking for unexpanded parameter packs in declarations thatDouglas Gregor2010-12-161-1/+20
| | | | | | | occur within statements. Teach Sema::ActOnExceptionDeclarator() to check for unexpanded parameter packs in the exception type. llvm-svn: 121984
* Check for unexpanded parameter packs in non-type template parameter types.Douglas Gregor2010-12-161-0/+3
| | | | llvm-svn: 121964
* Check for unexpanded parameter packs in default arguments.Douglas Gregor2010-12-161-0/+9
| | | | llvm-svn: 121962
* Check for unexpanded parameter packs within variable initializers.Douglas Gregor2010-12-161-0/+7
| | | | llvm-svn: 121938
* Check for unexpanded parameter packs in friend declarations.Douglas Gregor2010-12-161-0/+4
| | | | llvm-svn: 121934
* Check for unexpanded parameter packs in using declarations. As aDouglas Gregor2010-12-161-2/+7
| | | | | | | drive-by, make sure to check for unexpanded parameter packs within the name of a declaration. llvm-svn: 121930
OpenPOWER on IntegriCloud