summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR45124: Don't leave behind pending cleanups when declaring implicitRichard Smith2020-03-111-0/+15
| | | | | | | | | | | | | | deduction guides. Previously if an implicit deduction guide had a default argument with a cleanup, we'd leave the 'pending cleanup' flag set after declaring the implicit guide. But it turns out that there's no reason to even substitute into the default argument when declaring an implicit deduction guide: we only need to record that the default argument exists, not what it is, since we never actually form a call to a deduction guide. (cherry picked from commit 6d894afdea433879f54e5ba07e827db006645b7b)
* PR42513: Enter the proper DeclContext before substituting into anRichard Smith2019-08-241-3/+6
| | | | | | | | | | | | default template argument expression. We already did this for type template parameters and template template parameters, but apparently forgot to do so for non-type template parameters. This causes the substituted default argument expression to be substituted in the proper context, and in particular to properly mark its subexpressions as odr-used. llvm-svn: 369834
* [clang] Fixing incorrect implicit deduction guides (PR41549)Gauthier Harnisch2019-06-141-0/+15
| | | | | | | | | | | | | | | | | | | | | Summary: [[ https://bugs.llvm.org/show_bug.cgi?id=41549 | bug report ]] Before this patch, implicit deduction guides were generated from the first declaration found by lookup. With this patch implicit deduction guides are generated from the definition of the class template. Also added test that was previously failing. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, Quuxplusone Tags: #clang Differential Revision: https://reviews.llvm.org/D63072 llvm-svn: 363361
* Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined ↵Eric Fiselier2019-01-171-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | deduction guides. Summary: Some style guides want to allow using CTAD only on types that "opt-in"; i.e. on types that are designed to support it and not just types that *happen* to work with it. This patch implements the `-Wctad-maybe-unsupported` warning, which is off by default, which warns when CTAD is used on a type that does not define any deduction guides. The following pattern can be used to suppress the warning in cases where the type intentionally doesn't define any deduction guides: ``` struct allow_ctad_t; template <class T> struct TestSuppression { TestSuppression(T) {} }; TestSuppression(allow_ctad_t)->TestSuppression<void>; // guides with incomplete parameter types are never considered. ``` Reviewers: rsmith, james.dennett, gromer Reviewed By: rsmith Subscribers: jdennett, Quuxplusone, lebedev.ri, cfe-commits Differential Revision: https://reviews.llvm.org/D56731 llvm-svn: 351484
* Handle dependent class template names in class template argumentRichard Smith2018-09-281-0/+7
| | | | | | deduction for new-expressions. llvm-svn: 343293
* [Sema] Use a TreeTransform to extract deduction guide parameter typesErik Pilkington2018-07-271-0/+29
| | | | | | | | | | | | | | | Previously, we just canonicalized the type, but this lead to crashes with parameter types that referred to ParmVarDecls of the constructor. There may be more cases that this TreeTransform needs to handle though, such as a constructor parameter type referring to a member in an unevaluated context. Canonicalization doesn't address these cases either though, so we can address them as-needed in follow-up commits. rdar://41330135 Differential revision: https://reviews.llvm.org/D49439 llvm-svn: 338165
* [Sema] Fix a crash by completing a type before using itErik Pilkington2018-07-261-0/+25
| | | | | | | | | | Only apply this exception on a type that we're able to check. rdar://41903969 Differential revision: https://reviews.llvm.org/D49868 llvm-svn: 338089
* PR37631: verify that a member deduction guide has the same access as its ↵Richard Smith2018-05-301-0/+16
| | | | | | template. llvm-svn: 333599
* PR34520: after instantiating a non-templated member deduction guide, don't ↵Richard Smith2018-05-301-0/+12
| | | | | | forget to push it into the class scope. llvm-svn: 333589
* PR35045: Convert injected-class-name to its corresponding simple-template-idRichard Smith2018-01-041-0/+11
| | | | | | | | | | during template argument deduction. We already did this when the injected-class-name was in P, but missed the case where it was in A. This (probably) can't happen except in implicit deduction guides. llvm-svn: 321779
* Never try to instantiate a deduction guide's "definition". Fixes bogus ↵Richard Smith2017-10-281-2/+2
| | | | | | warning when there inevitably isn't one. llvm-svn: 316820
* PR33489: A function-style cast to a deduced class template specialization ↵Richard Smith2017-08-111-0/+23
| | | | | | type is type-dependent if it can't be resolved due to a type-dependent argument. llvm-svn: 310691
* Don't emit undefined-internal warnings for CXXDeductionGuideDecls.Richard Smith2017-08-031-1/+24
| | | | | | Patch by ~paul (cynecx on phabricator)! Some test massaging by me. llvm-svn: 309975
* Weaken restriction in r304862 to allow implicit deduction guides to referenceRichard Smith2017-06-081-0/+8
| | | | | | | the injected-class-name of a specialization that uses a partial / explicit specialization. llvm-svn: 304957
* Fix a couple of class template argument deduction crashes with libc++'s tuple.Richard Smith2017-06-071-0/+24
| | | | | | | | | | | | | | | | RecursiveASTVisitor was not properly recursing through a SubstTemplateTypeParmTypes, resulting in crashes in pack expansion where we couldn't always find an unexpanded pack within a pack expansion. We also have an issue where substitution of deduced template arguments for an implicit deduction guide creates the "impossible" case of naming a non-dependent member of the current instantiation, but within a specialization that is actually instantiated from a different (partial/explicit) specialization of the template. We resolve this by declaring that constructors that do so can only be used to deduce specializations of the primary template. I'm running this past CWG to see if people agree this is the right thing to do. llvm-svn: 304862
* PR32673: Don't wrap parameter packs in SubstTemplateTypeParmPackType nodes ↵Richard Smith2017-04-201-0/+35
| | | | | | | | | when forming implicit deduction guides. Doing so thwarts template type deduction. Instead, substitute the pack directly by picking "slice 0" of the resulting expansion. llvm-svn: 300805
* PR32185: Revert r291512 and add a testcase for PR32185.Richard Smith2017-04-131-12/+6
| | | | | | | | | | | | | | | This reverts an attempt to check that types match when matching a dependently-typed non-type template parameter. (This comes up when matching the parameters of a template template parameter against the parameters of a template template argument.) The matching rules here are murky at best. Our behavior after this revert is definitely wrong for certain C++17 features (for 'auto' template parameter types within the parameter list of a template template argument in particular), but our behavior before this revert is wrong for some pre-existing testcases, so reverting to our prior behavior seems like our best option. llvm-svn: 300262
* Fix deduction of type of pack-expanded non-type template parameter.Richard Smith2017-02-211-4/+10
| | | | | | | | | We need to look through the PackExpansionType in the parameter type when deducing, and we need to consider the possibility of deducing arguments for packs that are not lexically mentioned in the pattern (but are nonetheless deducible) when figuring out which packs are covered by a pack deduction scope. llvm-svn: 295790
* Fix lookup through injected-class-names in implicit deduction guides in theRichard Smith2017-02-211-4/+17
| | | | | | | | | | case where the class template has a parameter pack. Checking of the template arguments expects an "as-written" template argument list, which in particular does not have any parameter packs. So flatten the packs into separate arguments before passing them in. llvm-svn: 295710
* When deducing an array bound from the length of an initializer list, don'tRichard Smith2017-02-211-6/+4
| | | | | | assume the bound has a non-dependent integral type. llvm-svn: 295698
* PR32010: Fix template argument depth mixup when forming implicit constructorRichard Smith2017-02-211-0/+26
| | | | | | | | | | | | | template deduction guides for class template argument deduction. Ensure that we have a local instantiation scope for tracking the instantiated parameters. Additionally, unusually, we're substituting at depth 1 and leaving depth 0 alone; make sure that we don't reduce template parameter depth by 2 for inner parameters in the process. (This is probably also broken for alias templates in the case where they're expanded within a dependent context, but this patch doesn't fix that.) llvm-svn: 295696
* Properly set up the DeclContext for parameters of implicit deduction guides;Richard Smith2017-02-161-0/+8
| | | | | | this is needed for deferred instantiation of default arguments. llvm-svn: 295379
* [c++1z] Diagnose non-deducible template parameters in deduction guide ↵Richard Smith2017-02-161-0/+18
| | | | | | templates, per [temp.param]p11. llvm-svn: 295264
* Canonicalize implicit deduction guide parameter types when forming a deductionRichard Smith2017-02-141-0/+13
| | | | | | | | | | | | guide from a constructor. The purpose of this change is to avoid triggering instantiation of the class when substituting back into the deduction guide if it uses a typedef member. We will still instantiate the class if the constructor (explicitly or implicitly, directly or indirectly) uses the current instantiation in a way that we can't canonicalize out, but that seems unavoidable. llvm-svn: 295016
* [c++1z] Add some more tests for class template argument deduction, addRichard Smith2017-02-141-0/+20
| | | | | | feature-test macro, and mark feature as done on status page. llvm-svn: 295011
* [c++1z] Tests for class template argument deduction in dependent contexts.Richard Smith2017-02-101-0/+30
| | | | llvm-svn: 294802
* [c++1z] P0512R0: support for 'explicit' specifier on deduction-guides.Richard Smith2017-02-101-6/+11
| | | | llvm-svn: 294693
* [c++1z] P0091R3: Basic support for deducing class template arguments via ↵Richard Smith2017-02-091-0/+84
deduction-guides. llvm-svn: 294613
OpenPOWER on IntegriCloud