Files
TheRock/compiler/amd-llvm/clang/test/SemaCXX/address-packed.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

124 lines
2.8 KiB
C++

// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
extern void f1(int *);
extern void f2(char *);
struct __attribute__((packed)) Arguable {
int x;
char c;
static void foo();
};
extern void f3(void());
namespace Foo {
struct __attribute__((packed)) Arguable {
char c;
int x;
static void foo();
};
}
struct Arguable *get_arguable();
void f4(int &);
void to_void(void *);
template <typename... T>
void sink(T...);
void g0() {
{
Foo::Arguable arguable;
f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
f2(&arguable.c); // no-warning
f3(&arguable.foo); // no-warning
to_void(&arguable.x); // no-warning
void *p1 = &arguable.x; // no-warning
void *p2 = static_cast<void *>(&arguable.x); // no-warning
void *p3 = reinterpret_cast<void *>(&arguable.x); // no-warning
void *p4 = (void *)&arguable.x; // no-warning
sink(p1, p2, p3, p4);
}
{
Arguable arguable1;
Arguable &arguable(arguable1);
f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
f2(&arguable.c); // no-warning
f3(&arguable.foo); // no-warning
}
{
Arguable *arguable1;
Arguable *&arguable(arguable1);
f1(&arguable->x); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
f2(&arguable->c); // no-warning
f3(&arguable->foo); // no-warning
}
}
struct __attribute__((packed)) A {
int x;
char c;
int *f0() {
return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
}
int *g0() {
return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
}
char *h0() {
return &c; // no-warning
}
};
struct B : A {
int *f1() {
return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
}
int *g1() {
return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
}
char *h1() {
return &c; // no-warning
}
};
template <typename Ty>
class __attribute__((packed)) S {
Ty X;
public:
const Ty *get() const {
return &X; // expected-warning {{packed member 'X' of class or structure 'S<int>'}}
// expected-warning@-1 {{packed member 'X' of class or structure 'S<float>'}}
}
};
template <typename Ty>
void h(Ty *);
void g1() {
S<int> s1;
s1.get(); // expected-note {{in instantiation of member function 'S<int>::get'}}
S<char> s2;
s2.get();
S<float> s3;
s3.get(); // expected-note {{in instantiation of member function 'S<float>::get'}}
}
// PR35509
typedef long L1;
struct Incomplete;
struct S2 {
L1 d;
Incomplete *e() const;
} __attribute__((packed));
Incomplete *S2::e() const { return (Incomplete *)&d; } // no-warning