
GCC from 11 onwards defaults to -std=gnu++17 for C++ source files. We want to do the same (https://discourse.llvm.org/t/c-objc-switch-to-gnu-17-as-the-default-dialect/64360). Split RUN lines, adjust `-verify`, or add `__cplusplus < 201703L` or `-Wno-dynamic-exception-spec`, so that tests will pass regardless of gnu++14/gnu++17 default. We have a desire to mark a test compatible with multiple language standards. There are ongoing discussions how to add markers in the long term: * https://discourse.llvm.org/t/iterating-lit-run-lines/62596 * https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932 As a workaround in the short term, add lit substitutions `%std_cxx98-`, `%std_cxx11-14`, etc. They can be used for tests which work across multiple language standards. If a range has `n` standards, run lit multiple times, with `LIT_CLANG_STD_GROUP=0`, `LIT_CLANG_STD_GROUP=1`, etc to cover all `n` standards. Reviewed By: #clang-language-wg, aaron.ballman Differential Revision: https://reviews.llvm.org/D131464
105 lines
2.3 KiB
C++
105 lines
2.3 KiB
C++
// RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.layouts
|
|
// RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.before
|
|
// RUN: %clang_cc1 %std_cxx98-14 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
|
|
// RUN: diff -u %t.before %t.after
|
|
// RUN: FileCheck --check-prefixes=CHECK,PRE17 %s < %t.after
|
|
|
|
// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.layouts
|
|
// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.before
|
|
// RUN: %clang_cc1 -std=c++17 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
|
|
// RUN: diff -u %t.before %t.after
|
|
// RUN: FileCheck --check-prefixes=CHECK,CXX17 %s < %t.after
|
|
|
|
// CXX17: Type: struct X6
|
|
|
|
// If not explicitly disabled, set PACKED to the packed attribute.
|
|
#ifndef PACKED
|
|
# define PACKED __attribute__((packed))
|
|
#endif
|
|
|
|
struct Empty1 { };
|
|
struct Empty2 { };
|
|
|
|
// CHECK: Type: struct X0
|
|
struct X0 : public Empty1 {
|
|
int x[6] PACKED;
|
|
};
|
|
|
|
// CHECK: Type: struct X1
|
|
struct X1 : public X0, public Empty2 {
|
|
char x[13];
|
|
struct X0 y;
|
|
} PACKED;
|
|
|
|
// CHECK: Type: struct X2
|
|
struct PACKED X2 : public X1, public X0, public Empty1 {
|
|
short x;
|
|
int y;
|
|
};
|
|
|
|
// CHECK: Type: struct X3
|
|
struct PACKED X3 : virtual public X1, public X0 {
|
|
short x;
|
|
int y;
|
|
};
|
|
|
|
// CHECK: Type: struct X4
|
|
struct PACKED X4 {
|
|
unsigned int a : 1;
|
|
unsigned int b : 1;
|
|
unsigned int c : 1;
|
|
unsigned int d : 1;
|
|
unsigned int e : 1;
|
|
unsigned int f : 1;
|
|
unsigned int g : 1;
|
|
unsigned int h : 1;
|
|
unsigned int i : 1;
|
|
unsigned int j : 1;
|
|
unsigned int k : 1;
|
|
unsigned int l : 1;
|
|
unsigned int m : 1;
|
|
unsigned int n : 1;
|
|
X4();
|
|
};
|
|
|
|
// CHECK: Type: struct X5
|
|
struct PACKED X5 {
|
|
union {
|
|
long a;
|
|
long b;
|
|
};
|
|
short l;
|
|
short r;
|
|
};
|
|
|
|
// PRE17: Type: struct X6
|
|
struct __attribute__((aligned(16))) X6 {
|
|
int x;
|
|
int y;
|
|
virtual ~X6();
|
|
};
|
|
|
|
// PRE17: Type: struct X7
|
|
struct X7 {
|
|
int z;
|
|
};
|
|
|
|
// PRE17: Type: struct X8
|
|
struct X8 : X6, virtual X7 {
|
|
char c;
|
|
};
|
|
|
|
void use_structs() {
|
|
X0 x0s[sizeof(X0)];
|
|
X1 x1s[sizeof(X1)];
|
|
X2 x2s[sizeof(X2)];
|
|
X3 x3s[sizeof(X3)];
|
|
X4 x4s[sizeof(X4)];
|
|
X5 x5s[sizeof(X5)];
|
|
X6 x6s[sizeof(X6)];
|
|
X7 x7s[sizeof(X7)];
|
|
X8 x8s[sizeof(X8)];
|
|
x4s[1].a = 1;
|
|
x5s[1].a = 17;
|
|
}
|