Files
TheRock/compiler/amd-llvm/clang/test/CXX/dcl.dcl/dcl.attr/dcl.align/p5.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

66 lines
2.6 KiB
C++

// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -verify %s
alignas(1) int n1; // expected-error {{requested alignment is less than minimum alignment of 4 for type 'int'}}
alignas(1) alignas(2) int n2; // expected-error {{less than minimum alignment}}
alignas(1) alignas(2) alignas(4) int n3; // ok
alignas(1) alignas(2) alignas(0) int n4; // expected-error {{less than minimum alignment}}
alignas(1) alignas(2) int n5 alignas(4); // ok
alignas(1) alignas(4) int n6 alignas(2); // ok
alignas(1) int n7 alignas(2), // expected-error {{less than minimum alignment}}
n8 alignas(4); // ok
alignas(8) int n9 alignas(2); // ok, overaligned
alignas(1) extern int n10; // expected-error {{less than minimum alignment}}
typedef __attribute__((aligned(16))) int IntAlign16;
enum E6 : IntAlign16 {};
static_assert(alignof(E6) == 4, "");
struct S1 {
alignas(8) int n;
};
struct alignas(2) S2 { // expected-error {{requested alignment is less than minimum alignment of 4 for type 'S2'}}
int n;
};
struct alignas(2) S3 { // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S3'}}
S1 s1;
};
struct alignas(2) S4 : S1 { // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S4'}}
};
struct S5 : S1 {
alignas(2) S1 s1; // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S1'}}
};
struct S6 {
S1 s1;
};
struct S7 : S1 {
};
struct alignas(2) alignas(8) alignas(1) S8 : S1 {
};
S1 s1 alignas(4); // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S1'}}
S6 s6 alignas(4); // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S6'}}
S7 s7 alignas(4); // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S7'}}
template<int N, int M, typename T>
struct alignas(N) X { // expected-error 3{{requested alignment is less than minimum}}
alignas(M) T t; // expected-error 3{{requested alignment is less than minimum}}
};
template struct X<1, 1, char>;
template struct X<4, 1, char>;
template struct X<1, 2, char>; // expected-note {{instantiation}}
template struct X<1, 1, short>; // expected-note {{instantiation}}
template struct X<2, 1, short>; // expected-note {{instantiation}}
template struct X<2, 2, short>;
template struct X<16, 8, S1>;
template struct X<4, 4, S1>; // expected-note {{instantiation}}
template<int N, typename T>
void f() {
alignas(N) T v; // expected-error {{requested alignment is less than minimum}}
};
template void f<1, char>();
template void f<2, char>();
template void f<1, short>(); // expected-note {{instantiation}}
template void f<2, short>();