File tree 3 files changed +47
-6
lines changed 3 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -309,6 +309,8 @@ Bug Fixes to C++ Support
309
309
template depth than the friend function template. (#GH98258)
310
310
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
311
311
of the current instantiation in all cases.
312
+ - Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
313
+
312
314
313
315
Bug Fixes to AST Handling
314
316
^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -6669,9 +6669,15 @@ QualType
6669
6669
TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB,
6670
6670
PackIndexingTypeLoc TL) {
6671
6671
// Transform the index
6672
- ExprResult IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
6673
- if (IndexExpr.isInvalid())
6674
- return QualType();
6672
+ ExprResult IndexExpr;
6673
+ {
6674
+ EnterExpressionEvaluationContext ConstantContext(
6675
+ SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
6676
+
6677
+ IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
6678
+ if (IndexExpr.isInvalid())
6679
+ return QualType();
6680
+ }
6675
6681
QualType Pattern = TL.getPattern();
6676
6682
6677
6683
const PackIndexingType *PIT = TL.getTypePtr();
@@ -15299,9 +15305,14 @@ TreeTransform<Derived>::TransformPackIndexingExpr(PackIndexingExpr *E) {
15299
15305
return E;
15300
15306
15301
15307
// Transform the index
15302
- ExprResult IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
15303
- if (IndexExpr.isInvalid())
15304
- return ExprError();
15308
+ ExprResult IndexExpr;
15309
+ {
15310
+ EnterExpressionEvaluationContext ConstantContext(
15311
+ SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
15312
+ IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
15313
+ if (IndexExpr.isInvalid())
15314
+ return ExprError();
15315
+ }
15305
15316
15306
15317
SmallVector<Expr *, 5> ExpandedExprs;
15307
15318
if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
Original file line number Diff line number Diff line change @@ -231,3 +231,31 @@ struct type_info {
231
231
namespace GH93650 {
232
232
auto func (auto ... inputArgs) { return typeid (inputArgs...[0 ]); }
233
233
} // namespace GH93650
234
+
235
+
236
+ namespace GH105900 {
237
+
238
+ template <typename ... opts>
239
+ struct types {
240
+ template <unsigned idx>
241
+ static constexpr __SIZE_TYPE__ get_index () { return idx; }
242
+
243
+ template <unsigned s>
244
+ static auto x () -> opts...[get_index<s>()] {}
245
+ };
246
+
247
+ template <auto ... opts>
248
+ struct vars {
249
+ template <unsigned idx>
250
+ static constexpr __SIZE_TYPE__ get_index () { return idx; }
251
+
252
+ template <unsigned s>
253
+ static auto x () -> decltype(opts...[get_index<s>()]) {return 0 ;}
254
+ };
255
+
256
+ void f () {
257
+ types<void >::x<0 >();
258
+ vars<0 >::x<0 >();
259
+ }
260
+
261
+ }
You can’t perform that action at this time.
0 commit comments