7 Commits

Author SHA1 Message Date
Younan Zhang
d15559d69d
[Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (#112896)
Nested lambdas could refer to outer packs that would be expanded by a
larger CXXFoldExpr, in which case that reference could happen to be a
full expression containing intermediate types/expressions, e.g.
SubstTemplateTypeParmPackType/FunctionParmPackExpr. They are designated
as "UnexpandedPack" dependencies but don't introduce new packs anyway.

This also handles a missed case for VarDecls, where the flag of
ContainsUnexpandedPack was not propagated up to the surrounding lambda.

Fixes #112352
2024-10-22 16:51:43 +08:00
Younan Zhang
8549b324bc
[Clang] Don't assert non-empty packs for FunctionParmPackExprs (#107561)
`FunctionParmPackExpr`s are peculiar in that they have to be of
unexpanded dependency while they don't introduce any unexpanded packs.
So this patch rules them out in the non-empty pack assertion in
`DiagnoseUnexpandedParameterPack()`.

There was a fix #69224, but that turned out to be insufficient.

I also moved the separate tests to a pre-existing file.

Fixes https://github.com/llvm/llvm-project/issues/86361
2024-09-09 15:09:43 +08:00
Mital Ashok
7536ebf0ea
[Clang][SemaCXX] Fix bug where unexpanded lambda captures where assumed to have size 1 (#101385)
Fixes #63677
2024-08-05 16:16:55 +08:00
cor3ntin
0431c61f6b
[Clang] Correctly recognize unexpanded packs in lambda template params (#98496)
Fixes #48937
Fixes #49099
2024-07-11 17:58:15 +02:00
Younan Zhang
3eeed79946
[clang] Correctly implement CWG 2672 (#75001) 2024-01-05 20:36:41 +08:00
Ilya Biryukov
629170fe45 [Sema] Lambdas are not part of immediate context for deduction
This commit implements [temp.deduct]p9.
Test updates include:
- New notes in `cxx1y-init-captures.cpp`, `lambda-expressions.cpp`
  and 'warn-unused-lambda-capture.cpp'.
  This seems to be caused by diagnosing errors earlier (during
  deduction) that were previously surfaced later (during
  instantiation).
- New error `lambda-unevaluated.cpp` is in line with [temp.deduct]p9.

Reviewed By: erichkeane, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D148802
2023-05-09 12:06:33 +02:00
Jens Massberg
edbea62f72 [clang] Correctly handle by-reference capture with an initializer that is a pack expansion in lambdas.
Ensure that the correct information whether an init-capture of a lambda
is passed by reference or by copy. This information is already computed
and has to be passed to the place where `NewInitCaptureType` is
created.

Before this fix it has been checked whether the VarDecl is a reference
type. This doesn't work for packed expansions, as the information
whether it is passed by reference or by copy is stored at the pattern of
a `PackExpansionType` and not at the type itself.

However, as the information has been already computed, we just have to
pass it.

Add tests that lambda captures with var decls which are reference types
are created in the AST and a disgnotics test for pack expansions.

Fixes #49266

Differential Revision: https://reviews.llvm.org/D139125
2022-12-07 16:00:58 +01:00