File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -17626,6 +17626,25 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
17626
17626
for (unsigned I = 0; I < Elts.size(); ++I)
17627
17627
Tree.merge(Elts[I]);
17628
17628
}
17629
+
17630
+ void VisitCXXParenListInitExpr(const CXXParenListInitExpr *PLIE) {
17631
+ // C++20 parenthesized list initializations are sequenced. See C++20
17632
+ // [decl.init]p17.5 and [decl.init]p17.6.2.2
17633
+ SmallVector<SequenceTree::Seq, 32> Elts;
17634
+ SequenceTree::Seq Parent = Region;
17635
+ for (const Expr *E : PLIE->getInitExprs()) {
17636
+ if (!E)
17637
+ continue;
17638
+ Region = Tree.allocate(Parent);
17639
+ Elts.push_back(Region);
17640
+ Visit(E);
17641
+ }
17642
+
17643
+ // Forget that the initializers are sequenced.
17644
+ Region = Parent;
17645
+ for (unsigned I = 0; I < Elts.size(); ++I)
17646
+ Tree.merge(Elts[I]);
17647
+ }
17629
17648
};
17630
17649
17631
17650
SequenceChecker::UsageInfo::UsageInfo() = default;
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wno-unused -Wunsequenced -verify %s
2
+
3
+ struct A {
4
+ int x, y;
5
+ };
6
+
7
+ void test () {
8
+ int a = 0 ;
9
+
10
+ A agg1 ( a++, a++ ); // no warning
11
+ A agg2 ( a++ + a, a++ ); // expected-warning {{unsequenced modification and access to 'a'}}
12
+
13
+ int arr1[]( a++, a++ ); // no warning
14
+ int arr2[]( a++ + a, a++ ); // expected-warning {{unsequenced modification and access to 'a'}}
15
+ }
You can’t perform that action at this time.
0 commit comments