Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
clang/test/SemaCXX/class-layout.cpp
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions | // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base | // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15 | // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15 | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6 | // RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6 | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6 | // RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6 | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6 | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14 | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 | ||||||||||||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16 | ||||||||||||
// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15 | |||||||||||||
// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 | |||||||||||||
// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15 | |||||||||||||
// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 | |||||||||||||
// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base | |||||||||||||
hubert.reinterpretcast: See comment for line 688 of this Diff. | |||||||||||||
Should change //RUN: to // RUN: to match other lines as well. hubert.reinterpretcast: Should change `//RUN:` to `// RUN:` to match other lines as well. | |||||||||||||
// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 | |||||||||||||
// expected-no-diagnostics | // expected-no-diagnostics | ||||||||||||
There are no AIX and z/OS RUN lines here? For AIX, we expect -DCLANG_ABI_COMPAT=15 behaviour with and without the -fclang-abi-compat=15 option. hubert.reinterpretcast: There are no AIX and z/OS `RUN` lines here? For AIX, we expect `-DCLANG_ABI_COMPAT=15`… | |||||||||||||
#if !defined(__MVS__) && !defined(_AIX) | |||||||||||||
Not Done ReplyInline ActionsWhat's the reason this part is #ifdef'd out? Does it contain code that's unsupported on these platforms? dblaikie: What's the reason this part is #ifdef'd out? Does it contain code that's unsupported on these… | |||||||||||||
Not Done ReplyInline ActionsThe correct values need to be evaluated for those parts. This test was never run with those platforms as targets. We're trying to get the newer tests enabled first. hubert.reinterpretcast: The correct values need to be evaluated for those parts. This test was never run with those… | |||||||||||||
#define SA(n, p) int a##n[(p) ? 1 : -1] | #define SA(n, p) int a##n[(p) ? 1 : -1] | ||||||||||||
struct A { | struct A { | ||||||||||||
int a; | int a; | ||||||||||||
char b; | char b; | ||||||||||||
}; | }; | ||||||||||||
SA(0, sizeof(A) == 8); | SA(0, sizeof(A) == 8); | ||||||||||||
▲ Show 20 Lines • Show All 586 Lines • ▼ Show 20 Lines | #if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 6 | ||||||||||||
_Static_assert(__builtin_offsetof(D, n) == 1, ""); | _Static_assert(__builtin_offsetof(D, n) == 1, ""); | ||||||||||||
#else | #else | ||||||||||||
_Static_assert(_Alignof(D) == 2, ""); | _Static_assert(_Alignof(D) == 2, ""); | ||||||||||||
_Static_assert(__builtin_offsetof(D, n) == 2, ""); | _Static_assert(__builtin_offsetof(D, n) == 2, ""); | ||||||||||||
#endif | #endif | ||||||||||||
#pragma pack(pop) | #pragma pack(pop) | ||||||||||||
} | } | ||||||||||||
#endif // !defined(__MVS__) && !defined(__AIX__) | |||||||||||||
nit: line numbers may shift on you as other commits touch this file. Prefer a same line comment that keeps the comment together with the actual directive. daltenty: nit: line numbers may shift on you as other commits touch this file. Prefer a same line… | |||||||||||||
namespace non_pod { | namespace non_pod { | ||||||||||||
struct t1 { | struct t1 { | ||||||||||||
protected: | protected: | ||||||||||||
int a; | int a; | ||||||||||||
}; | }; | ||||||||||||
// GCC prints warning: ignoring packed attribute because of unpacked non-POD field 't1 t2::v1'` | // GCC prints warning: ignoring packed attribute because of unpacked non-POD field 't1 t2::v1'` | ||||||||||||
struct t2 { | struct t2 { | ||||||||||||
char c1; | char c1; | ||||||||||||
short s1; | short s1; | ||||||||||||
char c2; | char c2; | ||||||||||||
t1 v1; | t1 v1; | ||||||||||||
} __attribute__((packed)); | } __attribute__((packed)); | ||||||||||||
#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15 | #if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15 | ||||||||||||
_Static_assert(_Alignof(t1) == 4, ""); | _Static_assert(_Alignof(t1) == 4, ""); | ||||||||||||
_Static_assert(_Alignof(t2) == 1, ""); | _Static_assert(_Alignof(t2) == 1, ""); | ||||||||||||
I am having trouble understanding how this line is passing with //RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15 The Clang 16 behaviour should be effective on z/OS given the state of this patch. hubert.reinterpretcast: I am having trouble understanding how this line is passing with
```
//RUN: %clang_cc1 -triple… | |||||||||||||
#else | #else | ||||||||||||
_Static_assert(_Alignof(t1) == 4, ""); | _Static_assert(_Alignof(t1) == 4, ""); | ||||||||||||
_Static_assert(_Alignof(t2) == 4, ""); | _Static_assert(_Alignof(t2) == 4, ""); | ||||||||||||
#endif | #endif | ||||||||||||
_Static_assert(sizeof(t2) == 8, ""); // it's still packing the rest of the struct | _Static_assert(sizeof(t2) == 8, ""); // it's still packing the rest of the struct | ||||||||||||
} // namespace non_pod | } // namespace non_pod | ||||||||||||
namespace non_pod_packed { | namespace non_pod_packed { | ||||||||||||
Show All 28 Lines | struct t1 { | ||||||||||||
~t1() = delete; | ~t1() = delete; | ||||||||||||
t1(t1&&) = default; | t1(t1&&) = default; | ||||||||||||
int a; | int a; | ||||||||||||
char c; | char c; | ||||||||||||
}; | }; | ||||||||||||
struct t2 { | struct t2 { | ||||||||||||
t1 v1; | t1 v1; | ||||||||||||
} __attribute__((packed)); | } __attribute__((packed)); | ||||||||||||
#if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || !defined(__MVS__) | |||||||||||||
_Static_assert(_Alignof(t2) == 1, ""); | _Static_assert(_Alignof(t2) == 1, ""); | ||||||||||||
#else | |||||||||||||
_Static_assert(_Alignof(t2) == 4, ""); | |||||||||||||
#endif | |||||||||||||
Just a note: As mentioned above, for some releases of Open XL on z/OS, the -fclang-abi-compat level that gives this result is less than 15 (but, then again, the behaviour expected by this line persisted in vanilla Clang 15). What is more important is the default behaviour (confirmed below) anyway. hubert.reinterpretcast: Just a note: As mentioned above, for some releases of Open XL on z/OS, the `-fclang-abi-compat`… | |||||||||||||
struct t3 : t1 { | struct t3 : t1 { | ||||||||||||
char c; | char c; | ||||||||||||
}; | }; | ||||||||||||
#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15 | #if (defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15) || defined(__MVS__) | ||||||||||||
Because z/OS has some of the Clang 16 changes but not all, I think we can't rely on claiming that it uses the Clang 15 ABI for the purposes of the testing (and need to make a change here to say that it does follow the "Clang 15 ABI" for this aspect). hubert.reinterpretcast: Because z/OS has some of the Clang 16 changes but not all, I think we can't rely on claiming… | |||||||||||||
Sorry, my last suggestion for this line should be reverted. z/OS works just like Linux for this right now: no special code needed here. hubert.reinterpretcast: Sorry, my last suggestion for this line should be reverted. z/OS works just like Linux for this… | |||||||||||||
I was actually confused about being confused before (and now I am just very confused). This is the test corresponding to the changes to areDefaultedSMFStillPOD. z/OS does not work just like Linux for this part. Under __MVS__, we really should always be returning 8 for the size of t3. I am not sure how we ended up with 12 as I was told offline. hubert.reinterpretcast: > Sorry, my last suggestion for this line should be reverted. z/OS works just like Linux for… | |||||||||||||
I discussed offline with Hubert, and we went through the test cases. My updated diff has applied Hubert's original suggestion for this line, as well as a similar change for line 684 to update the assertions for the z/OS case. This test case now passes all the AIX & z/OS run lines. nicolerabjohn: I discussed offline with Hubert, and we went through the test cases. My updated diff has… | |||||||||||||
_Static_assert(sizeof(t3) == 8, ""); | _Static_assert(sizeof(t3) == 8, ""); | ||||||||||||
#else | #else | ||||||||||||
_Static_assert(sizeof(t3) == 12, ""); | _Static_assert(sizeof(t3) == 12, ""); | ||||||||||||
#endif | #endif | ||||||||||||
} | } |
See comment for line 688 of this Diff.