aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/cxx11.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/AST/ByteCode/cxx11.cpp')
-rw-r--r--clang/test/AST/ByteCode/cxx11.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp
index 7aecf23b..08caca0 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -330,3 +330,33 @@ namespace ReadMutableInCopyCtor {
// both-note {{read of mutable member 'u'}} \
// both-note {{in call to 'G(g1)'}}
}
+
+namespace GH150709 {
+ struct C { };
+ struct D : C {
+ constexpr int f() const { return 1; };
+ };
+ struct E : C { };
+ struct F : D { };
+ struct G : E { };
+
+ constexpr C c1, c2[2];
+ constexpr D d1, d2[2];
+ constexpr E e1, e2[2];
+ constexpr F f;
+ constexpr G g;
+
+ constexpr auto mp = static_cast<int (C::*)() const>(&D::f);
+
+ // sanity checks for fix of GH150709 (unchanged behavior)
+ static_assert((c1.*mp)() == 1, ""); // both-error {{constant expression}}
+ static_assert((d1.*mp)() == 1, "");
+ static_assert((f.*mp)() == 1, "");
+ static_assert((c2[0].*mp)() == 1, ""); // ref-error {{constant expression}}
+ static_assert((d2[0].*mp)() == 1, "");
+
+ // incorrectly undiagnosed before fix of GH150709
+ static_assert((e1.*mp)() == 1, ""); // ref-error {{constant expression}}
+ static_assert((e2[0].*mp)() == 1, ""); // ref-error {{constant expression}}
+ static_assert((g.*mp)() == 1, ""); // ref-error {{constant expression}}
+}