brintos

brintos / llvm-project-archived public Read only

0
0
Text · 628 B · 22667ac Raw
24 lines · cpp
1// RUN: %clang_cc1 -Wno-uninitialized -std=c++1y %s -verify2 3// expected-no-diagnostics4 5struct S { int a; const char *b; int c; int d = b[a]; };6constexpr S ss = { 1, "asdf" };7 8static_assert(ss.a == 1, "");9static_assert(ss.b[2] == 'd', "");10static_assert(ss.c == 0, "");11static_assert(ss.d == 's', "");12 13struct X { int i, j, k = 42; };14constexpr X a[] = { 1, 2, 3, 4, 5, 6 };15constexpr X b[2] = { { 1, 2, 3 }, { 4, 5, 6 } };16 17constexpr bool operator==(X a, X b) {18  return a.i == b.i && a.j == b.j && a.k == b.k;19}20 21static_assert(sizeof(a) == sizeof(b), "");22static_assert(a[0] == b[0], "");23static_assert(a[1] == b[1], "");24