[clang][AVR] Fix basic type size/alignment values to match avr-gcc. (#111290)
Closes #102172
This commit is contained in:
committed by
GitHub
parent
95b4128c6a
commit
d906ac52ab
@@ -87,6 +87,7 @@ enum class FloatModeKind {
|
||||
struct TransferrableTargetInfo {
|
||||
unsigned char PointerWidth, PointerAlign;
|
||||
unsigned char BoolWidth, BoolAlign;
|
||||
unsigned char ShortWidth, ShortAlign;
|
||||
unsigned char IntWidth, IntAlign;
|
||||
unsigned char HalfWidth, HalfAlign;
|
||||
unsigned char BFloat16Width, BFloat16Align;
|
||||
@@ -497,13 +498,10 @@ public:
|
||||
unsigned getCharWidth() const { return 8; } // FIXME
|
||||
unsigned getCharAlign() const { return 8; } // FIXME
|
||||
|
||||
/// Return the size of 'signed short' and 'unsigned short' for this
|
||||
/// target, in bits.
|
||||
unsigned getShortWidth() const { return 16; } // FIXME
|
||||
|
||||
/// Return the alignment of 'signed short' and 'unsigned short' for
|
||||
/// this target.
|
||||
unsigned getShortAlign() const { return 16; } // FIXME
|
||||
/// getShortWidth/Align - Return the size of 'signed short' and
|
||||
/// 'unsigned short' for this target, in bits.
|
||||
unsigned getShortWidth() const { return ShortWidth; }
|
||||
unsigned getShortAlign() const { return ShortAlign; }
|
||||
|
||||
/// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
|
||||
/// this target, in bits.
|
||||
|
||||
@@ -70,6 +70,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
|
||||
HasStrictFP = false;
|
||||
PointerWidth = PointerAlign = 32;
|
||||
BoolWidth = BoolAlign = 8;
|
||||
ShortWidth = ShortAlign = 16;
|
||||
IntWidth = IntAlign = 32;
|
||||
LongWidth = LongAlign = 32;
|
||||
LongLongWidth = LongLongAlign = 64;
|
||||
@@ -437,6 +438,7 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
|
||||
// what these normally are for the target.
|
||||
// We also define long long and long double here, although the
|
||||
// OpenCL standard only mentions these as "reserved".
|
||||
ShortWidth = ShortAlign = 16;
|
||||
IntWidth = IntAlign = 32;
|
||||
LongWidth = LongAlign = 64;
|
||||
LongLongWidth = LongLongAlign = 128;
|
||||
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
TLSSupported = false;
|
||||
PointerWidth = 16;
|
||||
PointerAlign = 8;
|
||||
ShortWidth = 16;
|
||||
ShortAlign = 8;
|
||||
IntWidth = 16;
|
||||
IntAlign = 8;
|
||||
LongWidth = 32;
|
||||
@@ -65,6 +67,8 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool allowsLargerPreferedTypeAlignment() const override { return false; }
|
||||
|
||||
BuiltinVaListKind getBuiltinVaListKind() const override {
|
||||
return TargetInfo::VoidPtrBuiltinVaList;
|
||||
}
|
||||
|
||||
@@ -1264,24 +1264,24 @@ _Complex float mulf(_Complex float a, _Complex float b) {
|
||||
// AVRFP32-SAME: float noundef [[A_COERCE0:%.*]], float noundef [[A_COERCE1:%.*]], float noundef [[B_COERCE0:%.*]], float noundef [[B_COERCE1:%.*]]) addrspace(1) #[[ATTR0]] {
|
||||
// AVRFP32-NEXT: entry:
|
||||
// AVRFP32-NEXT: [[RETVAL:%.*]] = alloca { float, float }, align 1
|
||||
// AVRFP32-NEXT: [[A:%.*]] = alloca { float, float }, align 4
|
||||
// AVRFP32-NEXT: [[B:%.*]] = alloca { float, float }, align 4
|
||||
// AVRFP32-NEXT: [[A:%.*]] = alloca { float, float }, align 1
|
||||
// AVRFP32-NEXT: [[B:%.*]] = alloca { float, float }, align 1
|
||||
// AVRFP32-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: store float [[A_COERCE0]], ptr [[TMP0]], align 4
|
||||
// AVRFP32-NEXT: store float [[A_COERCE0]], ptr [[TMP0]], align 1
|
||||
// AVRFP32-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: store float [[A_COERCE1]], ptr [[TMP1]], align 4
|
||||
// AVRFP32-NEXT: store float [[A_COERCE1]], ptr [[TMP1]], align 1
|
||||
// AVRFP32-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: store float [[B_COERCE0]], ptr [[TMP2]], align 4
|
||||
// AVRFP32-NEXT: store float [[B_COERCE0]], ptr [[TMP2]], align 1
|
||||
// AVRFP32-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: store float [[B_COERCE1]], ptr [[TMP3]], align 4
|
||||
// AVRFP32-NEXT: store float [[B_COERCE1]], ptr [[TMP3]], align 1
|
||||
// AVRFP32-NEXT: [[A_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: [[A_REAL:%.*]] = load float, ptr [[A_REALP]], align 4
|
||||
// AVRFP32-NEXT: [[A_REAL:%.*]] = load float, ptr [[A_REALP]], align 1
|
||||
// AVRFP32-NEXT: [[A_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: [[A_IMAG:%.*]] = load float, ptr [[A_IMAGP]], align 4
|
||||
// AVRFP32-NEXT: [[A_IMAG:%.*]] = load float, ptr [[A_IMAGP]], align 1
|
||||
// AVRFP32-NEXT: [[B_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: [[B_REAL:%.*]] = load float, ptr [[B_REALP]], align 4
|
||||
// AVRFP32-NEXT: [[B_REAL:%.*]] = load float, ptr [[B_REALP]], align 1
|
||||
// AVRFP32-NEXT: [[B_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: [[B_IMAG:%.*]] = load float, ptr [[B_IMAGP]], align 4
|
||||
// AVRFP32-NEXT: [[B_IMAG:%.*]] = load float, ptr [[B_IMAGP]], align 1
|
||||
// AVRFP32-NEXT: [[TMP4:%.*]] = call addrspace(1) float @llvm.fabs.f32(float [[B_REAL]])
|
||||
// AVRFP32-NEXT: [[TMP5:%.*]] = call addrspace(1) float @llvm.fabs.f32(float [[B_IMAG]])
|
||||
// AVRFP32-NEXT: [[ABS_CMP:%.*]] = fcmp ugt float [[TMP4]], [[TMP5]]
|
||||
@@ -1321,24 +1321,24 @@ _Complex float mulf(_Complex float a, _Complex float b) {
|
||||
// AVRFP64-LABEL: define dso_local void @divd(
|
||||
// AVRFP64-SAME: ptr dead_on_unwind noalias writable sret({ double, double }) align 1 [[AGG_RESULT:%.*]], double noundef [[A_COERCE0:%.*]], double noundef [[A_COERCE1:%.*]], double noundef [[B_COERCE0:%.*]], double noundef [[B_COERCE1:%.*]]) addrspace(1) #[[ATTR0]] {
|
||||
// AVRFP64-NEXT: entry:
|
||||
// AVRFP64-NEXT: [[A:%.*]] = alloca { double, double }, align 8
|
||||
// AVRFP64-NEXT: [[B:%.*]] = alloca { double, double }, align 8
|
||||
// AVRFP64-NEXT: [[A:%.*]] = alloca { double, double }, align 1
|
||||
// AVRFP64-NEXT: [[B:%.*]] = alloca { double, double }, align 1
|
||||
// AVRFP64-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: store double [[A_COERCE0]], ptr [[TMP0]], align 8
|
||||
// AVRFP64-NEXT: store double [[A_COERCE0]], ptr [[TMP0]], align 1
|
||||
// AVRFP64-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: store double [[A_COERCE1]], ptr [[TMP1]], align 8
|
||||
// AVRFP64-NEXT: store double [[A_COERCE1]], ptr [[TMP1]], align 1
|
||||
// AVRFP64-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: store double [[B_COERCE0]], ptr [[TMP2]], align 8
|
||||
// AVRFP64-NEXT: store double [[B_COERCE0]], ptr [[TMP2]], align 1
|
||||
// AVRFP64-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: store double [[B_COERCE1]], ptr [[TMP3]], align 8
|
||||
// AVRFP64-NEXT: store double [[B_COERCE1]], ptr [[TMP3]], align 1
|
||||
// AVRFP64-NEXT: [[A_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: [[A_REAL:%.*]] = load double, ptr [[A_REALP]], align 8
|
||||
// AVRFP64-NEXT: [[A_REAL:%.*]] = load double, ptr [[A_REALP]], align 1
|
||||
// AVRFP64-NEXT: [[A_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: [[A_IMAG:%.*]] = load double, ptr [[A_IMAGP]], align 8
|
||||
// AVRFP64-NEXT: [[A_IMAG:%.*]] = load double, ptr [[A_IMAGP]], align 1
|
||||
// AVRFP64-NEXT: [[B_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: [[B_REAL:%.*]] = load double, ptr [[B_REALP]], align 8
|
||||
// AVRFP64-NEXT: [[B_REAL:%.*]] = load double, ptr [[B_REALP]], align 1
|
||||
// AVRFP64-NEXT: [[B_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: [[B_IMAG:%.*]] = load double, ptr [[B_IMAGP]], align 8
|
||||
// AVRFP64-NEXT: [[B_IMAG:%.*]] = load double, ptr [[B_IMAGP]], align 1
|
||||
// AVRFP64-NEXT: [[TMP4:%.*]] = call addrspace(1) double @llvm.fabs.f64(double [[B_REAL]])
|
||||
// AVRFP64-NEXT: [[TMP5:%.*]] = call addrspace(1) double @llvm.fabs.f64(double [[B_IMAG]])
|
||||
// AVRFP64-NEXT: [[ABS_CMP:%.*]] = fcmp ugt double [[TMP4]], [[TMP5]]
|
||||
@@ -1862,24 +1862,24 @@ _Complex double divd(_Complex double a, _Complex double b) {
|
||||
// AVRFP32-SAME: float noundef [[A_COERCE0:%.*]], float noundef [[A_COERCE1:%.*]], float noundef [[B_COERCE0:%.*]], float noundef [[B_COERCE1:%.*]]) addrspace(1) #[[ATTR0]] {
|
||||
// AVRFP32-NEXT: entry:
|
||||
// AVRFP32-NEXT: [[RETVAL:%.*]] = alloca { float, float }, align 1
|
||||
// AVRFP32-NEXT: [[A:%.*]] = alloca { float, float }, align 4
|
||||
// AVRFP32-NEXT: [[B:%.*]] = alloca { float, float }, align 4
|
||||
// AVRFP32-NEXT: [[A:%.*]] = alloca { float, float }, align 1
|
||||
// AVRFP32-NEXT: [[B:%.*]] = alloca { float, float }, align 1
|
||||
// AVRFP32-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: store float [[A_COERCE0]], ptr [[TMP0]], align 4
|
||||
// AVRFP32-NEXT: store float [[A_COERCE0]], ptr [[TMP0]], align 1
|
||||
// AVRFP32-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: store float [[A_COERCE1]], ptr [[TMP1]], align 4
|
||||
// AVRFP32-NEXT: store float [[A_COERCE1]], ptr [[TMP1]], align 1
|
||||
// AVRFP32-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: store float [[B_COERCE0]], ptr [[TMP2]], align 4
|
||||
// AVRFP32-NEXT: store float [[B_COERCE0]], ptr [[TMP2]], align 1
|
||||
// AVRFP32-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: store float [[B_COERCE1]], ptr [[TMP3]], align 4
|
||||
// AVRFP32-NEXT: store float [[B_COERCE1]], ptr [[TMP3]], align 1
|
||||
// AVRFP32-NEXT: [[A_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: [[A_REAL:%.*]] = load float, ptr [[A_REALP]], align 4
|
||||
// AVRFP32-NEXT: [[A_REAL:%.*]] = load float, ptr [[A_REALP]], align 1
|
||||
// AVRFP32-NEXT: [[A_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: [[A_IMAG:%.*]] = load float, ptr [[A_IMAGP]], align 4
|
||||
// AVRFP32-NEXT: [[A_IMAG:%.*]] = load float, ptr [[A_IMAGP]], align 1
|
||||
// AVRFP32-NEXT: [[B_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP32-NEXT: [[B_REAL:%.*]] = load float, ptr [[B_REALP]], align 4
|
||||
// AVRFP32-NEXT: [[B_REAL:%.*]] = load float, ptr [[B_REALP]], align 1
|
||||
// AVRFP32-NEXT: [[B_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP32-NEXT: [[B_IMAG:%.*]] = load float, ptr [[B_IMAGP]], align 4
|
||||
// AVRFP32-NEXT: [[B_IMAG:%.*]] = load float, ptr [[B_IMAGP]], align 1
|
||||
// AVRFP32-NEXT: [[MUL_AC:%.*]] = fmul float [[A_REAL]], [[B_REAL]]
|
||||
// AVRFP32-NEXT: [[MUL_BD:%.*]] = fmul float [[A_IMAG]], [[B_IMAG]]
|
||||
// AVRFP32-NEXT: [[MUL_AD:%.*]] = fmul float [[A_REAL]], [[B_IMAG]]
|
||||
@@ -1896,24 +1896,24 @@ _Complex double divd(_Complex double a, _Complex double b) {
|
||||
// AVRFP64-LABEL: define dso_local void @muld(
|
||||
// AVRFP64-SAME: ptr dead_on_unwind noalias writable sret({ double, double }) align 1 [[AGG_RESULT:%.*]], double noundef [[A_COERCE0:%.*]], double noundef [[A_COERCE1:%.*]], double noundef [[B_COERCE0:%.*]], double noundef [[B_COERCE1:%.*]]) addrspace(1) #[[ATTR0]] {
|
||||
// AVRFP64-NEXT: entry:
|
||||
// AVRFP64-NEXT: [[A:%.*]] = alloca { double, double }, align 8
|
||||
// AVRFP64-NEXT: [[B:%.*]] = alloca { double, double }, align 8
|
||||
// AVRFP64-NEXT: [[A:%.*]] = alloca { double, double }, align 1
|
||||
// AVRFP64-NEXT: [[B:%.*]] = alloca { double, double }, align 1
|
||||
// AVRFP64-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: store double [[A_COERCE0]], ptr [[TMP0]], align 8
|
||||
// AVRFP64-NEXT: store double [[A_COERCE0]], ptr [[TMP0]], align 1
|
||||
// AVRFP64-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: store double [[A_COERCE1]], ptr [[TMP1]], align 8
|
||||
// AVRFP64-NEXT: store double [[A_COERCE1]], ptr [[TMP1]], align 1
|
||||
// AVRFP64-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: store double [[B_COERCE0]], ptr [[TMP2]], align 8
|
||||
// AVRFP64-NEXT: store double [[B_COERCE0]], ptr [[TMP2]], align 1
|
||||
// AVRFP64-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: store double [[B_COERCE1]], ptr [[TMP3]], align 8
|
||||
// AVRFP64-NEXT: store double [[B_COERCE1]], ptr [[TMP3]], align 1
|
||||
// AVRFP64-NEXT: [[A_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: [[A_REAL:%.*]] = load double, ptr [[A_REALP]], align 8
|
||||
// AVRFP64-NEXT: [[A_REAL:%.*]] = load double, ptr [[A_REALP]], align 1
|
||||
// AVRFP64-NEXT: [[A_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[A]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: [[A_IMAG:%.*]] = load double, ptr [[A_IMAGP]], align 8
|
||||
// AVRFP64-NEXT: [[A_IMAG:%.*]] = load double, ptr [[A_IMAGP]], align 1
|
||||
// AVRFP64-NEXT: [[B_REALP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 0
|
||||
// AVRFP64-NEXT: [[B_REAL:%.*]] = load double, ptr [[B_REALP]], align 8
|
||||
// AVRFP64-NEXT: [[B_REAL:%.*]] = load double, ptr [[B_REALP]], align 1
|
||||
// AVRFP64-NEXT: [[B_IMAGP:%.*]] = getelementptr inbounds nuw { double, double }, ptr [[B]], i32 0, i32 1
|
||||
// AVRFP64-NEXT: [[B_IMAG:%.*]] = load double, ptr [[B_IMAGP]], align 8
|
||||
// AVRFP64-NEXT: [[B_IMAG:%.*]] = load double, ptr [[B_IMAGP]], align 1
|
||||
// AVRFP64-NEXT: [[MUL_AC:%.*]] = fmul double [[A_REAL]], [[B_REAL]]
|
||||
// AVRFP64-NEXT: [[MUL_BD:%.*]] = fmul double [[A_IMAG]], [[B_IMAG]]
|
||||
// AVRFP64-NEXT: [[MUL_AD:%.*]] = fmul double [[A_REAL]], [[B_IMAG]]
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
double x = 0;
|
||||
int size = sizeof(x);
|
||||
|
||||
// FIXME: the double should have an alignment of 1 on AVR, not 4 or 8.
|
||||
// AVR-FP64: @x ={{.*}} global double {{.*}}, align 8
|
||||
// AVR-FP64: @x ={{.*}} global double {{.*}}, align 1
|
||||
// AVR-FP64: @size ={{.*}} global i16 8
|
||||
// AVR-FP32: @x ={{.*}} global float {{.*}}, align 4
|
||||
// AVR-FP32: @x ={{.*}} global float {{.*}}, align 1
|
||||
// AVR-FP32: @size ={{.*}} global i16 4
|
||||
|
||||
49
clang/test/Sema/avr-size-align.c
Normal file
49
clang/test/Sema/avr-size-align.c
Normal file
@@ -0,0 +1,49 @@
|
||||
// RUN: %clang_cc1 %s -triple avr -fsyntax-only
|
||||
|
||||
_Static_assert(sizeof(char) == 1, "sizeof(char) == 1");
|
||||
_Static_assert(_Alignof(char) == 1, "_Alignof(char) == 1");
|
||||
_Static_assert(__alignof(char) == 1, "__alignof(char) == 1");
|
||||
|
||||
_Static_assert(sizeof(short) == 2, "sizeof(short) == 2");
|
||||
_Static_assert(_Alignof(short) == 1, "_Alignof(short) == 1");
|
||||
_Static_assert(__alignof(short) == 1, "__alignof(short) == 1");
|
||||
|
||||
_Static_assert(sizeof(unsigned short) == 2, "sizeof(unsigned short) == 2");
|
||||
_Static_assert(_Alignof(unsigned short) == 1, "_Alignof(unsigned short) == 1");
|
||||
_Static_assert(__alignof(unsigned short) == 1, "__alignof(unsigned short) == 1");
|
||||
|
||||
_Static_assert(sizeof(int) == 2, "sizeof(int) == 2");
|
||||
_Static_assert(_Alignof(int) == 1, "_Alignof(int) == 1");
|
||||
_Static_assert(__alignof(int) == 1, "__alignof(int) == 1");
|
||||
|
||||
_Static_assert(sizeof(unsigned int) == 2, "sizeof(unsigned int) == 2");
|
||||
_Static_assert(_Alignof(unsigned int) == 1, "_Alignof(unsigned int) == 1");
|
||||
_Static_assert(__alignof(unsigned int) == 1, "__alignof(unsigned int) == 1");
|
||||
|
||||
_Static_assert(sizeof(long) == 4, "sizeof(long) == 4");
|
||||
_Static_assert(_Alignof(long) == 1, "_Alignof(long) == 1");
|
||||
_Static_assert(__alignof(long) == 1, "__alignof(long) == 1");
|
||||
|
||||
_Static_assert(sizeof(unsigned long) == 4, "sizeof(unsigned long) == 4");
|
||||
_Static_assert(_Alignof(unsigned long) == 1, "_Alignof(unsigned long) == 1");
|
||||
_Static_assert(__alignof(unsigned long) == 1, "__alignof(unsigned long) == 1");
|
||||
|
||||
_Static_assert(sizeof(long long) == 8, "sizeof(long long) == 8");
|
||||
_Static_assert(_Alignof(long long) == 1, "_Alignof(long long) == 1");
|
||||
_Static_assert(__alignof(long long) == 1, "__alignof(long long) == 1");
|
||||
|
||||
_Static_assert(sizeof(unsigned long long) == 8, "sizeof(unsigned long long) == 8");
|
||||
_Static_assert(_Alignof(unsigned long long) == 1, "_Alignof(unsigned long long) == 1");
|
||||
_Static_assert(__alignof(unsigned long long) == 1, "__alignof(unsigned long long) == 1");
|
||||
|
||||
_Static_assert(sizeof(float) == 4, "sizeof(float) == 4");
|
||||
_Static_assert(_Alignof(float) == 1, "_Alignof(float) == 1");
|
||||
_Static_assert(__alignof(float) == 1, "__alignof(float) == 1");
|
||||
|
||||
_Static_assert(sizeof(double) == 4, "sizeof(double) == 4");
|
||||
_Static_assert(_Alignof(double) == 1, "_Alignof(double) == 1");
|
||||
_Static_assert(__alignof(double) == 1, "__alignof(double) == 1");
|
||||
|
||||
_Static_assert(sizeof(long double) == 4, "sizeof(long double) == 4");
|
||||
_Static_assert(_Alignof(long double) == 1, "_Alignof(long double) == 1");
|
||||
_Static_assert(__alignof(long double) == 1, "__alignof(long double) == 1");
|
||||
@@ -14,11 +14,11 @@ struct S s[]; // expected-warning {{tentative array definition}} expected-note {
|
||||
void f1(void) {
|
||||
++s[3].a;
|
||||
++s[7073650413200313099].b;
|
||||
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 160-bit (20-byte) elements (max possible 3276 elements)}}
|
||||
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
|
||||
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178956970 elements)}}
|
||||
// addr64-warning@-3 {{array index 7073650413200313099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements)}}
|
||||
++s[7073650].c;
|
||||
// addr16-warning@-1 {{array index 7073650 refers past the last possible element for an array in 16-bit address space containing 160-bit (20-byte) elements (max possible 3276 elements)}}
|
||||
// addr16-warning@-1 {{array index 7073650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
|
||||
}
|
||||
|
||||
long long ll[]; // expected-warning {{tentative array definition}} expected-note {{declared here}} addr16-note {{declared here}} addr32-note {{declared here}}
|
||||
@@ -37,21 +37,21 @@ void f2(void) {
|
||||
void f3(struct S p[]) { // expected-note {{declared here}} addr16-note {{declared here}}
|
||||
++p[3].a;
|
||||
++p[7073650413200313099].b;
|
||||
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 160-bit (20-byte) elements (max possible 3276 elements)}}
|
||||
// addr16-warning@-1 {{array index 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
|
||||
// addr32-warning@-2 {{array index 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178956970 elements)}}
|
||||
// addr64-warning@-3 {{array index 7073650413200313099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements)}}
|
||||
++p[7073650].c;
|
||||
// addr16-warning@-1 {{array index 7073650 refers past the last possible element for an array in 16-bit address space containing 160-bit (20-byte) elements (max possible 3276 elements)}}
|
||||
// addr16-warning@-1 {{array index 7073650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
|
||||
}
|
||||
|
||||
void f4(struct S *p) { // expected-note {{declared here}} addr16-note {{declared here}}
|
||||
p += 3;
|
||||
p += 7073650413200313099;
|
||||
// addr16-warning@-1 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 160-bit (20-byte) elements (max possible 3276 elements)}}
|
||||
// addr16-warning@-1 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
|
||||
// addr32-warning@-2 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 32-bit address space containing 192-bit (24-byte) elements (max possible 178956970 elements)}}
|
||||
// addr64-warning@-3 {{the pointer incremented by 7073650413200313099 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements)}}
|
||||
p += 7073650;
|
||||
// addr16-warning@-1 {{the pointer incremented by 7073650 refers past the last possible element for an array in 16-bit address space containing 160-bit (20-byte) elements (max possible 3276 elements)}}
|
||||
// addr16-warning@-1 {{the pointer incremented by 7073650 refers past the last possible element for an array in 16-bit address space containing 152-bit (19-byte) elements (max possible 3449 elements)}}
|
||||
}
|
||||
|
||||
struct BQ {
|
||||
@@ -63,7 +63,7 @@ struct BQ bq[]; // expected-warning {{tentative array definition}} addr16-note {
|
||||
void f5(void) {
|
||||
++bq[0].bigblock[0].a;
|
||||
++bq[1].bigblock[0].a;
|
||||
// addr16-warning@-1 {{array index 1 refers past the last possible element for an array in 16-bit address space containing 524160-bit (65520-byte) elements (max possible 1 element)}}
|
||||
// addr16-warning@-1 {{array index 1 refers past the last possible element for an array in 16-bit address space containing 497952-bit (62244-byte) elements (max possible 1 element)}}
|
||||
}
|
||||
|
||||
void f6(void) {
|
||||
|
||||
Reference in New Issue
Block a user