[clang] 4a6a4f8 - [clang][Interp] Add a failing test case
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 13 06:58:23 PDT 2023
Author: Timm Bäder
Date: 2023-04-13T15:55:57+02:00
New Revision: 4a6a4f84a7af7212d36aea9c34a1a8b9bb05d733
URL: https://github.com/llvm/llvm-project/commit/4a6a4f84a7af7212d36aea9c34a1a8b9bb05d733
DIFF: https://github.com/llvm/llvm-project/commit/4a6a4f84a7af7212d36aea9c34a1a8b9bb05d733.diff
LOG: [clang][Interp] Add a failing test case
Added:
Modified:
clang/test/AST/Interp/records.cpp
Removed:
################################################################################
diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp
index 745a30bec33b..a874bf378150 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -451,3 +451,40 @@ namespace ConditionalInit {
static_assert(getS(true).a == 12, "");
static_assert(getS(false).a == 13, "");
};
+/// FIXME: The following tests are broken.
+/// They are using CXXDefaultInitExprs which contain a CXXThisExpr. The This pointer
+/// in those refers to the declaration we are currently initializing, *not* the
+/// This pointer of the current stack frame. This is something we haven't
+/// implemented in the new interpreter yet.
+namespace DeclRefs {
+ struct A{ int m; const int &f = m; }; // expected-note {{implicit use of 'this'}}
+
+ constexpr A a{10}; // expected-error {{must be initialized by a constant expression}}
+ static_assert(a.m == 10, "");
+ static_assert(a.f == 10, ""); // expected-error {{not an integral constant expression}} \
+ // expected-note {{read of object outside its lifetime}}
+
+ class Foo {
+ public:
+ int z = 1337;
+ constexpr int a() const {
+ A b{this->z};
+
+ return b.f;
+ }
+ };
+ constexpr Foo f;
+ static_assert(f.a() == 1337, "");
+
+
+ struct B {
+ A a = A{100};
+ };
+ constexpr B b;
+ /// FIXME: The following two lines don't work because we don't get the
+ /// pointers on the LHS correct. They make us run into an assertion
+ /// in CheckEvaluationResult. However, this may just be caused by the
+ /// problems in the previous examples.
+ //static_assert(b.a.m == 100, "");
+ //static_assert(b.a.f == 100, "");
+}
More information about the cfe-commits
mailing list