summaryrefslogtreecommitdiff
path: root/test/CXX
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-05-13 13:19:09 +0000
committerHans Wennborg <hans@hanshq.net>2019-05-13 13:19:09 +0000
commit24e6d2a7b6f041a6df9e61cf9cecfc15c1f7ccac (patch)
treefc365619cc8ebc19a6743544184f14d4674f3321 /test/CXX
parentf585a602f52c5f1c02c0c39400a2ca273e3a51b1 (diff)
downloadclang-24e6d2a7b6f041a6df9e61cf9cecfc15c1f7ccac.tar.gz
Revert r360559 "[c++20] P1064R0: Allow virtual function calls in constant expression evaluation."
This caused Chromium builds to hit the new "can't handle virtual calls with virtual bases" assert. Reduced repro coming up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360580 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp22
-rw-r--r--test/CXX/drs/dr18xx.cpp14
-rw-r--r--test/CXX/drs/dr6xx.cpp15
3 files changed, 10 insertions, 41 deletions
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index cc3917093e..ffc408cddb 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -20,10 +20,7 @@ struct Literal {
};
struct S {
- virtual int ImplicitlyVirtual() const = 0;
-#if __cplusplus <= 201703L
- // expected-note@-2 {{overridden virtual function}}
-#endif
+ virtual int ImplicitlyVirtual() const = 0; // expected-note {{overridden virtual function}}
};
struct SS : S {
int ImplicitlyVirtual() const;
@@ -35,21 +32,12 @@ struct T : SS, NonLiteral {
constexpr T();
constexpr int f() const;
- // - it shall not be virtual; [until C++20]
- virtual constexpr int ExplicitlyVirtual() const { return 0; }
-#if __cplusplus <= 201703L
- // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+ // - it shall not be virtual;
+ virtual constexpr int ExplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}}
- constexpr int ImplicitlyVirtual() const { return 0; }
-#if __cplusplus <= 201703L
- // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+ constexpr int ImplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}}
- virtual constexpr int OutOfLineVirtual() const;
-#if __cplusplus <= 201703L
- // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+ virtual constexpr int OutOfLineVirtual() const; // expected-error {{virtual function cannot be constexpr}}
// - its return type shall be a literal type;
constexpr NonLiteral NonLiteralReturn() const { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
diff --git a/test/CXX/drs/dr18xx.cpp b/test/CXX/drs/dr18xx.cpp
index 33c0452b6c..5df132c368 100644
--- a/test/CXX/drs/dr18xx.cpp
+++ b/test/CXX/drs/dr18xx.cpp
@@ -52,19 +52,9 @@ namespace dr1872 { // dr1872: 9
struct Z : virtual X {};
constexpr int x = A<X>().f();
- constexpr int y = A<Y>().f();
-#if __cplusplus <= 201703L
- // expected-error@-2 {{constant expression}} expected-note@-2 {{call to virtual function}}
-#else
- static_assert(y == 0);
-#endif
+ constexpr int y = A<Y>().f(); // expected-error {{constant expression}} expected-note {{call to virtual function}}
// Note, this is invalid even though it would not use virtual dispatch.
- constexpr int y2 = A<Y>().A<Y>::f();
-#if __cplusplus <= 201703L
- // expected-error@-2 {{constant expression}} expected-note@-2 {{call to virtual function}}
-#else
- static_assert(y == 0);
-#endif
+ constexpr int y2 = A<Y>().A<Y>::f(); // expected-error {{constant expression}} expected-note {{call to virtual function}}
constexpr int z = A<Z>().f(); // expected-error {{constant expression}} expected-note {{non-literal type}}
#endif
}
diff --git a/test/CXX/drs/dr6xx.cpp b/test/CXX/drs/dr6xx.cpp
index 31642dfbb0..318096c299 100644
--- a/test/CXX/drs/dr6xx.cpp
+++ b/test/CXX/drs/dr6xx.cpp
@@ -479,21 +479,12 @@ namespace dr647 { // dr647: yes
// This is partially superseded by dr1358.
struct A {
constexpr virtual void f() const;
- constexpr virtual void g() const {}
-#if __cplusplus <= 201703L
- // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+ constexpr virtual void g() const {} // expected-error {{virtual function cannot be constexpr}}
};
- struct X { virtual void f() const; };
-#if __cplusplus <= 201703L
- // expected-note@-2 {{overridden}}
-#endif
+ struct X { virtual void f() const; }; // expected-note {{overridden}}
struct B : X {
- constexpr void f() const {}
-#if __cplusplus <= 201703L
- // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+ constexpr void f() const {} // expected-error {{virtual function cannot be constexpr}}
};
struct NonLiteral { NonLiteral() {} }; // expected-note {{not an aggregate and has no constexpr constructors}}