Files
TheRock/compiler/amd-llvm/clang/test/SemaCXX/class-base-member-init.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

111 lines
2.7 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
class S {
public:
S ();
};
struct D : S {
D() :
b1(0), // expected-note {{previous initialization is here}}
b2(1),
b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
S(), // expected-note {{previous initialization is here}}
S() // expected-error {{multiple initializations given for base 'S'}}
{}
int b1;
int b2;
};
struct A {
struct {
int a;
int b;
};
A();
};
A::A() : a(10), b(20) { }
namespace Test1 {
template<typename T> struct A {};
template<typename T> struct B : A<T> {
B() : A<T>(), // expected-note {{previous initialization is here}}
A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
};
}
namespace Test2 {
template<typename T> struct A : T {
A() : T(), // expected-note {{previous initialization is here}}
T() { } // expected-error {{multiple initializations given for base 'T'}}
};
}
namespace Test3 {
template<typename T> struct A {
T t;
A() : t(1), // expected-note {{previous initialization is here}}
t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
};
}
namespace test4 {
class A {
union {
struct {
int a;
int b;
};
int c;
union {
int d;
int e;
};
};
A(char _) : a(0), b(0) {}
A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
};
}
namespace test5 {
struct Base {
Base(int);
};
struct A : Base {
A() : decltype(Base(1))(3) {
}
A(int) : Base(3), // expected-note {{previous initialization is here}}
decltype(Base(1))(2), // expected-error {{multiple initializations given for base 'decltype(Base(1))' (aka 'Base')}}
decltype(int())() { // expected-error {{constructor initializer 'decltype(int())' (aka 'int') does not name a class}}
}
A(float) : decltype(A())(3) {
}
};
}
namespace rdar13185264 {
class X {
X() : a(), // expected-note{{previous initialization is here}}
a() { } // expected-error{{multiple initializations given for non-static member 'a'}}
union { void *a; };
};
}
namespace PR16596 {
class A { public: virtual ~A(); };
typedef const A Foo;
void Apply(Foo processor);
struct Bar : public Foo {};
void Fetch() {
Apply(Bar());
}
}