summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/temp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add semantic analysis for the creation of and an AST representationDouglas Gregor2011-01-051-7/+5
| | | | | | | | | | | | | | | | | | | | | for template template argument pack expansions. This allows fun such as: template<template<class> class ...> struct apply_impl { /*...*/ }; template<template<class> class ...Metafunctions> struct apply { typedef typename apply_impl<Metafunctions...>::type type; }; However, neither template argument deduction nor template instantiation is implemented for template template argument packs, so this functionality isn't useful yet. I'll probably replace the encoding of template template argument pack expansions in TemplateArgument so that it's harder to accidentally forget about the expansion. However, this is a step in the right general direction. llvm-svn: 122890
* Implement C++0x [temp.param]p11 for non-type and template templateDouglas Gregor2011-01-051-0/+50
| | | | | | | parameter packs. Also, the "no template parameters after a template parameter pack" rule only applies to primary class templates. llvm-svn: 122877
* 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-054-0/+37
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Improve our handling of non-type template parameters in partialDouglas Gregor2011-01-042-0/+51
| | | | | | | | | | | | | 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
* Unwrap template argument packs when checking the template arguments ofDouglas Gregor2011-01-031-0/+8
| | | | | | | a class template partial specialiation, and look through pack expansions when checking the conditions of C++0x [temp.class.spec]p8. llvm-svn: 122774
* 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
* Fix a thinko in a helper routine for template argument deduction thatDouglas Gregor2010-12-241-1/+31
| | | | | | | | caused an assertion when dealing with non-type template parameter packs. Add some tests for deduction and instantiation of non-type template parameter packs. llvm-svn: 122534
* Non-type template parameter packs cannot have default arguments.Douglas Gregor2010-12-241-0/+10
| | | | llvm-svn: 122533
* 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
* Reimplement the comparison of a class template partialDouglas Gregor2010-12-231-0/+13
| | | | | | | | | | | specialization's template arguments against the primary template's template arguments using the obvious, correct method of checking the injected-class-name type (C++ [temp.class.spec]p9b3). The previous incarnation of this comparison attempted to use its own formulation of the injected-class-name, which is redudant and, with the introduction of variadic templates, became wrong (again). llvm-svn: 122508
* 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 the part of C++0x [temp.arg.explicit]p3 that pertains toDouglas Gregor2010-12-231-0/+27
| | | | | | | | | | | | parameter packs. In particular, a parameter pack not otherwise deduced is deduced to an empty parameter pack. The C++0x wording here is a bit unfortunate; this should really only apply to function templates, and it mentions "trailing" parameter packs, which doesn't really make sense in the context of function templates. Will file a core issue separately. llvm-svn: 122463
* Implement the rest of C++0x [temp.deduct.type]p9, which specifies thatDouglas Gregor2010-12-232-1/+26
| | | | | | | | the presence of a pack expansion anywhere except at the end of a template-argument-list causes the entire template-argument-list to be a non-deduced context. llvm-svn: 122461
* Unify the consistency checking for deduced template arguments into aDouglas Gregor2010-12-221-0/+23
| | | | | | | | | single routine. Extend that routine to handle consistency checking for template argument packs, so that we can compare the deduced packs for template parameter packs across different pack expansions. llvm-svn: 122452
* 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
* Add test for C++ [temp.friend]p8, which bans partial specializations from ↵Douglas Gregor2010-12-211-0/+6
| | | | | | being friends llvm-svn: 122335
* 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
* Check for unexpanded parameter packs in enumeration types and enumerators.Douglas Gregor2010-12-161-0/+4
| | | | llvm-svn: 121928
* Check for unexpanded parameter packs in static assertion expressions.Douglas Gregor2010-12-151-0/+1
| | | | llvm-svn: 121922
* Check for unexpanded parameter packs in various kinds ofDouglas Gregor2010-12-151-0/+15
| | | | | | | | declarations. This is a work in progress, as I go through the C++ declaration grammar to identify where unexpanded parameter packs can occur. llvm-svn: 121912
* Test that all of the relevant types properly compute the "containsDouglas Gregor2010-12-151-3/+89
| | | | | | | unexpanded parameter pack" bit and that the recursive AST visitor can then find those unexpanded parameter packs. llvm-svn: 121899
* Introduce a RecursiveASTVisitor subclass that finds all unexpandedDouglas Gregor2010-12-151-3/+18
| | | | | | | | | | | | | | | | parameter packs within a statement, type, etc. Use this visitor to provide improved diagnostics for the presence of unexpanded parameter packs in a full expression, base type, declaration type, etc., by highlighting the unexpanded parameter packs and providing their names, e.g., test/CXX/temp/temp.decls/temp.variadic/p5.cpp:28:85: error: declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ... ...VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; ~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ^ llvm-svn: 121883
* Variadic templates: extend the Expr class with a bit that specifiesDouglas Gregor2010-12-151-0/+5
| | | | | | | | | | | | | | | | | | whether the expression contains an unexpanded parameter pack, in the same vein as the changes to the Type hierarchy. Compute this bit within all of the Expr subclasses. This change required a bunch of reshuffling of dependency calculations, mainly to consolidate them inside the constructors and to fuse multiple loops that iterate over arguments to determine type dependence, value dependence, and (now) containment of unexpanded parameter packs. Again, testing is painfully sparse, because all of the diagnostics will change and it is more important to test the to-be-written visitor that collects unexpanded parameter packs. llvm-svn: 121831
* Variadic templates: extend Type, NestedNameSpecifier, TemplateName,Douglas Gregor2010-12-131-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | and TemplateArgument with an operation that determines whether there are any unexpanded parameter packs within that construct. Use this information to diagnose the appearance of the names of parameter packs that have not been expanded (C++ [temp.variadic]p5). Since this property is checked often (every declaration, ever expression statement, etc.), we extend Type and Expr with a bit storing the result of this computation, rather than walking the AST each time to determine whether any unexpanded parameter packs occur. This commit is deficient in several ways, which will be remedied with future commits: - Expr has a bit to store the presence of an unexpanded parameter pack, but it is never set. - The error messages don't point out where the unexpanded parameter packs were named in the type/expression, but they should. - We don't check for unexpanded parameter packs in all of the places where we should. - Testing is sparse, pending the resolution of the above three issues. llvm-svn: 121724
OpenPOWER on IntegriCloud