llvm-project/clang/test/SemaCXX/warn-unsequenced-paren-list-init.cpp
Douglas Deslauriers 4ce737bfd6
[clang] Sequence C++20 Parenthesized List Init (#83476)
Parenthesized list intializers are sequenced operations, see C++20
[decl.init]p16.5 and [decl.init]p16.6.2.2 for more details.

Fixes #83474
2024-03-05 15:07:54 +01:00

16 lines
406 B
C++

// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wno-unused -Wunsequenced -verify %s
struct A {
int x, y;
};
void test() {
int a = 0;
A agg1( a++, a++ ); // no warning
A agg2( a++ + a, a++ ); // expected-warning {{unsequenced modification and access to 'a'}}
int arr1[]( a++, a++ ); // no warning
int arr2[]( a++ + a, a++ ); // expected-warning {{unsequenced modification and access to 'a'}}
}