mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 07:06:42 +00:00

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
16 lines
406 B
C++
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'}}
|
|
}
|