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
140 lines
4.4 KiB
C++
140 lines
4.4 KiB
C++
// RUN: %clang_cc1 -std=c++03 -verify -ast-dump %s > %t-03
|
|
// RUN: FileCheck --input-file=%t-03 %s
|
|
// RUN: %clang_cc1 -std=c++11 -verify -ast-dump %s > %t-11
|
|
// RUN: FileCheck --input-file=%t-11 %s
|
|
// RUN: FileCheck --input-file=%t-11 %s --check-prefix=CHECK-CXX11
|
|
// RUN: %clang_cc1 -verify -std=c++17 %s
|
|
|
|
// http://llvm.org/PR7905
|
|
namespace PR7905 {
|
|
struct S; // expected-note {{forward declaration}}
|
|
void foo1() {
|
|
(void)(S[]) {{3}}; // expected-error {{array has incomplete element type}}
|
|
}
|
|
|
|
template <typename T> struct M { T m; };
|
|
void foo2() {
|
|
(void)(M<short> []) {{3}};
|
|
}
|
|
}
|
|
|
|
// Check compound literals mixed with C++11 list-initialization.
|
|
namespace brace_initializers {
|
|
struct POD {
|
|
int x, y;
|
|
};
|
|
struct HasCtor {
|
|
HasCtor(int x, int y);
|
|
};
|
|
struct HasDtor {
|
|
int x, y;
|
|
~HasDtor();
|
|
};
|
|
struct HasCtorDtor {
|
|
HasCtorDtor(int x, int y);
|
|
~HasCtorDtor();
|
|
};
|
|
|
|
POD p = (POD){1, 2};
|
|
// CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'brace_initializers::POD'
|
|
// CHECK: CompoundLiteralExpr {{.*}} 'POD'{{$}}
|
|
// CHECK-NEXT: InitListExpr {{.*}} 'POD' explicit{{$}}
|
|
// CHECK-NEXT: ConstantExpr {{.*}}
|
|
// CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}}
|
|
// CHECK-NEXT: ConstantExpr {{.*}}
|
|
// CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}}
|
|
|
|
void test() {
|
|
(void)(POD){1, 2};
|
|
// CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'POD'
|
|
// CHECK-NOT: ConstantExpr {{.*}} 'POD'
|
|
// CHECK: CompoundLiteralExpr {{.*}} 'POD'{{$}}
|
|
// CHECK-NEXT: InitListExpr {{.*}} 'POD' explicit{{$}}
|
|
// CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}}
|
|
// CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}}
|
|
|
|
(void)(HasDtor){1, 2};
|
|
// CHECK: CXXBindTemporaryExpr {{.*}} 'HasDtor'
|
|
// CHECK-NEXT: CompoundLiteralExpr {{.*}} 'HasDtor'{{$}}
|
|
// CHECK-NEXT: InitListExpr {{.*}} 'HasDtor' explicit{{$}}
|
|
// CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}}
|
|
// CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}}
|
|
|
|
#if __cplusplus >= 201103L
|
|
(void)(HasCtor){1, 2};
|
|
// CHECK-CXX11-NOT: CXXBindTemporaryExpr {{.*}} 'HasCtor'
|
|
// CHECK-CXX11-NOT: ConstantExpr {{.*}} 'HasCtor'
|
|
// CHECK-CXX11: CompoundLiteralExpr {{.*}} 'HasCtor'{{$}}
|
|
// CHECK-CXX11-NEXT: CXXTemporaryObjectExpr {{.*}} 'HasCtor'
|
|
// CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 1{{$}}
|
|
// CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 2{{$}}
|
|
|
|
(void)(HasCtorDtor){1, 2};
|
|
// CHECK-CXX11: CXXBindTemporaryExpr {{.*}} 'HasCtorDtor'
|
|
// CHECK-CXX11-NOT: ConstantExpr {{.*}} 'HasCtorDtor'
|
|
// CHECK-CXX11: CompoundLiteralExpr {{.*}} 'HasCtorDtor'{{$}}
|
|
// CHECK-CXX11-NEXT: CXXTemporaryObjectExpr {{.*}} 'HasCtorDtor'
|
|
// CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 1{{$}}
|
|
// CHECK-CXX11-NEXT: IntegerLiteral {{.*}} 2{{$}}
|
|
#endif
|
|
}
|
|
|
|
struct PrivateDtor {
|
|
int x, y;
|
|
private:
|
|
~PrivateDtor(); // expected-note {{declared private here}}
|
|
};
|
|
|
|
void testPrivateDtor() {
|
|
(void)(PrivateDtor){1, 2}; // expected-error {{temporary of type 'PrivateDtor' has private destructor}}
|
|
}
|
|
}
|
|
|
|
// This doesn't necessarily need to be an error, but CodeGen can't handle it
|
|
// at the moment.
|
|
int PR17415 = (int){PR17415}; // expected-error {{initializer element is not a compile-time constant}}
|
|
|
|
// Make sure we accept this. (Not sure if we actually should... but we do
|
|
// at the moment.)
|
|
template<unsigned> struct Value { };
|
|
template<typename T>
|
|
int &check_narrowed(Value<sizeof((T){1.1})>);
|
|
|
|
#if __cplusplus >= 201103L
|
|
// Compound literals in global lambdas have automatic storage duration
|
|
// and are not subject to the constant-initialization rules.
|
|
int computed_with_lambda = [] {
|
|
int x = 5;
|
|
int result = ((int[]) { x, x + 2, x + 4, x + 6 })[0];
|
|
return result;
|
|
}();
|
|
#endif
|
|
|
|
namespace DynamicFileScopeLiteral {
|
|
// This covers the case where we have a file-scope compound literal with a
|
|
// non-constant initializer in C++. Previously, we had a bug where Clang forgot
|
|
// to consider initializer list elements for bases.
|
|
struct Empty {};
|
|
struct Foo : Empty { // expected-note 0+ {{candidate constructor}}
|
|
int x;
|
|
int y;
|
|
};
|
|
int f();
|
|
#if __cplusplus < 201103L
|
|
// expected-error@+6 {{non-aggregate type 'Foo' cannot be initialized with an initializer list}}
|
|
#elif __cplusplus < 201703L
|
|
// expected-error@+4 {{no matching constructor}}
|
|
#else
|
|
// expected-error@+2 {{initializer element is not a compile-time constant}}
|
|
#endif
|
|
Foo o = (Foo){ {}, 1, f() };
|
|
}
|
|
|
|
#if __cplusplus >= 201103L
|
|
namespace GH147949 {
|
|
// Make sure we handle transparent InitListExprs correctly.
|
|
struct S { int x : 3; };
|
|
const S* x = (const S[]){S{S{3}}};
|
|
}
|
|
#endif
|