Commit c86a53d
authored
[clang] Implement provisional wording for CWG2398 regarding packs (llvm#90820)
This solves some ambuguity introduced in P0522 regarding how
template template parameters are partially ordered, and should reduce
the negative impact of enabling `-frelaxed-template-template-args`
by default.
When performing template argument deduction, a template template
parameter
containing no packs should be more specialized than one that does.
Given the following example:
```C++
template<class T2> struct A;
template<template<class ...T3s> class TT1, class T4> struct A<TT1<T4>>; // #1
template<template<class T5 > class TT2, class T6> struct A<TT2<T6>>; // llvm#2
template<class T1> struct B;
template struct A<B<char>>;
```
Prior to P0522, candidate `llvm#2` would be more specialized.
After P0522, neither is more specialized, so this becomes ambiguous.
With this change, `llvm#2` becomes more specialized again,
maintaining compatibility with pre-P0522 implementations.
The problem is that in P0522, candidates are at least as specialized
when matching packs to fixed-size lists both ways, whereas before,
a fixed-size list is more specialized.
This patch keeps the original behavior when checking template arguments
outside deduction, but restores this aspect of pre-P0522 matching
during deduction.
---
Since this changes provisional implementation of CWG2398 which has
not been released yet, and already contains a changelog entry,
we don't provide a changelog entry here.1 parent 997eae3 commit c86a53d
File tree
4 files changed
+65
-32
lines changed- clang
- include/clang/Sema
- lib/Sema
- test/SemaTemplate
4 files changed
+65
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9133 | 9133 | | |
9134 | 9134 | | |
9135 | 9135 | | |
9136 | | - | |
| 9136 | + | |
9137 | 9137 | | |
9138 | 9138 | | |
9139 | 9139 | | |
| |||
9612 | 9612 | | |
9613 | 9613 | | |
9614 | 9614 | | |
9615 | | - | |
| 9615 | + | |
| 9616 | + | |
9616 | 9617 | | |
9617 | 9618 | | |
9618 | 9619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6554 | 6554 | | |
6555 | 6555 | | |
6556 | 6556 | | |
6557 | | - | |
| 6557 | + | |
| 6558 | + | |
6558 | 6559 | | |
6559 | 6560 | | |
6560 | 6561 | | |
| |||
8472 | 8473 | | |
8473 | 8474 | | |
8474 | 8475 | | |
8475 | | - | |
| 8476 | + | |
| 8477 | + | |
8476 | 8478 | | |
8477 | 8479 | | |
8478 | 8480 | | |
| |||
8524 | 8526 | | |
8525 | 8527 | | |
8526 | 8528 | | |
8527 | | - | |
8528 | | - | |
| 8529 | + | |
| 8530 | + | |
8529 | 8531 | | |
8530 | 8532 | | |
8531 | 8533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | | - | |
| 149 | + | |
| 150 | + | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| |||
2550 | 2552 | | |
2551 | 2553 | | |
2552 | 2554 | | |
2553 | | - | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
2554 | 2558 | | |
2555 | 2559 | | |
2556 | 2560 | | |
| |||
2581 | 2585 | | |
2582 | 2586 | | |
2583 | 2587 | | |
2584 | | - | |
2585 | | - | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
2586 | 2593 | | |
2587 | 2594 | | |
2588 | 2595 | | |
| |||
2609 | 2616 | | |
2610 | 2617 | | |
2611 | 2618 | | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
2612 | 2622 | | |
2613 | | - | |
2614 | | - | |
| 2623 | + | |
| 2624 | + | |
2615 | 2625 | | |
2616 | 2626 | | |
2617 | 2627 | | |
| |||
6299 | 6309 | | |
6300 | 6310 | | |
6301 | 6311 | | |
6302 | | - | |
| 6312 | + | |
| 6313 | + | |
6303 | 6314 | | |
6304 | 6315 | | |
6305 | 6316 | | |
| |||
6309 | 6320 | | |
6310 | 6321 | | |
6311 | 6322 | | |
6312 | | - | |
6313 | | - | |
6314 | | - | |
6315 | 6323 | | |
6316 | 6324 | | |
| 6325 | + | |
| 6326 | + | |
6317 | 6327 | | |
6318 | 6328 | | |
6319 | 6329 | | |
| |||
6356 | 6366 | | |
6357 | 6367 | | |
6358 | 6368 | | |
6359 | | - | |
6360 | | - | |
| 6369 | + | |
| 6370 | + | |
| 6371 | + | |
| 6372 | + | |
6361 | 6373 | | |
6362 | 6374 | | |
6363 | 6375 | | |
6364 | 6376 | | |
6365 | | - | |
6366 | | - | |
| 6377 | + | |
| 6378 | + | |
| 6379 | + | |
| 6380 | + | |
| 6381 | + | |
| 6382 | + | |
| 6383 | + | |
| 6384 | + | |
| 6385 | + | |
| 6386 | + | |
| 6387 | + | |
| 6388 | + | |
| 6389 | + | |
| 6390 | + | |
| 6391 | + | |
| 6392 | + | |
| 6393 | + | |
| 6394 | + | |
| 6395 | + | |
| 6396 | + | |
| 6397 | + | |
| 6398 | + | |
| 6399 | + | |
| 6400 | + | |
| 6401 | + | |
| 6402 | + | |
| 6403 | + | |
| 6404 | + | |
| 6405 | + | |
6367 | 6406 | | |
6368 | 6407 | | |
6369 | 6408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | 65 | | |
67 | | - | |
68 | 66 | | |
69 | 67 | | |
70 | 68 | | |
71 | | - | |
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
77 | | - | |
78 | 74 | | |
79 | | - | |
80 | 75 | | |
81 | 76 | | |
82 | 77 | | |
83 | | - | |
84 | 78 | | |
85 | 79 | | |
86 | 80 | | |
| |||
140 | 134 | | |
141 | 135 | | |
142 | 136 | | |
143 | | - | |
144 | 137 | | |
145 | | - | |
146 | | - | |
| 138 | + | |
147 | 139 | | |
148 | | - | |
149 | | - | |
| 140 | + | |
150 | 141 | | |
151 | 142 | | |
152 | 143 | | |
| |||
193 | 184 | | |
194 | 185 | | |
195 | 186 | | |
196 | | - | |
| 187 | + | |
197 | 188 | | |
0 commit comments