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
77 lines
2.3 KiB
C++
77 lines
2.3 KiB
C++
// RUN: %clang_cc1 -std=c++11 -verify=expected,expected11,both,both11 %s -fexperimental-new-constant-interpreter
|
|
// RUN: %clang_cc1 -std=c++14 -verify=expected,expected14,both %s -fexperimental-new-constant-interpreter
|
|
// RUN: %clang_cc1 -std=c++11 -verify=ref,ref11,both,both11 %s
|
|
// RUN: %clang_cc1 -std=c++14 -verify=ref,ref14,both %s
|
|
|
|
namespace Simple {
|
|
struct S {
|
|
mutable int a; // both-note {{declared here}} \
|
|
// both11-note {{declared here}}
|
|
int a2;
|
|
};
|
|
|
|
constexpr S s{12, 24};
|
|
static_assert(s.a == 12, ""); // both-error {{not an integral constant expression}} \
|
|
// both-note {{read of mutable member 'a'}}
|
|
static_assert(s.a2 == 24, "");
|
|
|
|
|
|
constexpr S s2{12, s2.a}; // both11-error {{must be initialized by a constant expression}} \
|
|
// both11-note {{read of mutable member 'a'}} \
|
|
// both11-note {{declared here}}
|
|
static_assert(s2.a2 == 12, ""); // both11-error {{not an integral constant expression}} \
|
|
// both11-note {{initializer of 's2' is not a constant expression}}
|
|
}
|
|
#if __cplusplus >= 201402L
|
|
namespace ConstInMutable {
|
|
class B {
|
|
public:
|
|
|
|
const int f;
|
|
constexpr B() : f(12) {}
|
|
};
|
|
class A {
|
|
public:
|
|
mutable B b;
|
|
constexpr A() = default;
|
|
};
|
|
constexpr int constInMutable() {
|
|
A a;
|
|
|
|
int *m = (int*)&a.b.f;
|
|
*m = 12; // both-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
|
|
return 1;
|
|
}
|
|
static_assert(constInMutable() == 1, ""); // both-error {{not an integral constant expression}} \
|
|
// both-note {{in call to}}
|
|
}
|
|
|
|
namespace MutableInConst {
|
|
class C {
|
|
public:
|
|
mutable int c;
|
|
constexpr C() : c(50) {}
|
|
};
|
|
class D {
|
|
public:
|
|
C c;
|
|
constexpr D() {}
|
|
};
|
|
constexpr int mutableInConst() {
|
|
const D d{};
|
|
int *m = (int*)&d.c.c;
|
|
*m = 12;
|
|
return 1;
|
|
}
|
|
static_assert(mutableInConst() == 1, "");
|
|
}
|
|
#endif
|
|
|
|
struct D { mutable int y; }; // both-note {{declared here}}
|
|
constexpr D d1 = { 1 };
|
|
constexpr D d2 = d1; // both-error {{must be initialized by a constant expression}} \
|
|
// both-note {{read of mutable member 'y}} \
|
|
// both-note {{in call to}}
|
|
|
|
|