File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,11 @@ class TreeTransform {
142
142
// /
143
143
// / Subclasses may override this function to specify when the transformation
144
144
// / should rebuild all AST nodes.
145
- bool AlwaysRebuild () { return false ; }
145
+ // /
146
+ // / We must always rebuild all AST nodes when performing variadic template
147
+ // / pack expansion, in order to avoid violating the AST invariant that each
148
+ // / statement node appears at most once in its containing declaration.
149
+ bool AlwaysRebuild () { return SemaRef.ArgumentPackSubstitutionIndex != -1 ; }
146
150
147
151
// / \brief Returns the location of the entity being transformed, if that
148
152
// / information was not available elsewhere in the AST.
Original file line number Diff line number Diff line change @@ -1811,3 +1811,16 @@ namespace NeverConstantTwoWays {
1811
1811
1 / 0 : // expected-warning {{division by zero}} expected-note {{division by zero}}
1812
1812
0 ;
1813
1813
}
1814
+
1815
+ namespace PR17800 {
1816
+ struct A {
1817
+ constexpr int operator ()() const { return 0 ; }
1818
+ };
1819
+ template <typename ...T> constexpr int sink (T ...) {
1820
+ return 0 ;
1821
+ }
1822
+ template <int ...N> constexpr int run () {
1823
+ return sink (A ()() + N ...);
1824
+ }
1825
+ constexpr int k = run<1 , 2 , 3 >();
1826
+ }
You can’t perform that action at this time.
0 commit comments