Files
TheRock/compiler/amd-llvm/clang/test/CXX/class/class.local/p3.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

139 lines
3.0 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -verify-directives %s
void f1() {
struct X {
struct Y;
};
struct X::Y {
void f() {}
};
}
void f2() {
struct X {
struct Y;
struct Y {
void f() {}
};
};
}
// A class nested within a local class is a local class.
void f3(int a) { // #a-param
struct X {
struct Y {
int f() { return a; }
// expected-error@-1 {{reference to local variable 'a' declared in enclosing function 'f3'}}
// expected-note@#a-param {{'a' declared here}}
};
};
}
void f4() {
{
struct A {
struct B;
struct B {};
};
}
{
struct A { struct B; };
struct A::B {};
}
{
struct A { struct B; };
{
struct A { struct B; };
struct A::B {};
}
struct A::B {};
}
{
struct A { struct B; };
struct A::B { struct C; };
struct A::B::C {};
}
{
struct A {
void f() {
struct B { struct C; };
struct B::C {};
}
};
}
struct A {
void f() {
struct B { struct C; }; // #B
{ struct B::C {}; }
// expected-error@-1 {{nested local class 'C' must be defined in the same block scope as 'B'}}
// expected-note@#B {{'B' defined here}}
}
};
{
struct A { struct B; }; // #A1
{
struct A::B {};
// expected-error@-1 {{nested local class 'B' must be defined in the same block scope as 'A'}}
// expected-note@#A1 {{'A' defined here}}
}
}
{
struct A { struct B { struct C; }; }; // #A2
{
struct A::B::C {};
// expected-error@-1 {{nested local class 'C' must be defined in the same block scope as 'A'}}
// expected-note@#A2 {{'A' defined here}}
}
}
{
struct A { struct B; }; // #A3
using AliasForA = A;
{
struct AliasForA::B {};
// expected-error@-1 {{nested local class 'B' must be defined in the same block scope as 'A'}}
// expected-note@#A3 {{'A' defined here}}
}
}
{
struct A;
struct A { struct B; }; // #A4
struct A;
{
struct A::B {};
// expected-error@-1 {{nested local class 'B' must be defined in the same block scope as 'A'}}
// expected-note@#A4 {{'A' defined here}}
}
}
}
template <typename>
void f5() {
struct A { struct B; }; // #A5
{
struct A::B {};
// expected-error@-1 {{nested local class 'B' must be defined in the same block scope as 'A'}}
// expected-note@#A5 {{'A' defined here}}
}
}
decltype(auto) f6() {
struct S { struct A; }; // #S
return S();
}
using X = decltype(f6());
struct X::A {};
// expected-error@-1 {{nested local class 'A' must be defined in the same block scope as 'S'}}
// expected-note@#S {{'S' defined here}}
auto f7 = [] {
struct L { struct B; }; // #L
{
struct L::B {};
// expected-error@-1 {{nested local class 'B' must be defined in the same block scope as 'L'}}
// expected-note@#L {{'L' defined here}}
}
};