================
@@ -964,3 +964,79 @@ namespace is_aggregate {
static_assert(__is_aggregate(S7[10]));
}
+
+namespace is_abstract_tests {
+struct Abstract1 {
+ virtual void fn1() = 0;
+};
+
+struct Abstract2 {
+ virtual void fn2() = 0;
+};
+
+struct NonAbstract
+{
+ virtual void f() {}
+};
+
+// Multiple inheritance reports all abstract base classes that had their pure
virtual functions overridden.
+struct Overrides : Abstract1, Abstract2, NonAbstract {
+ void fn1() override {}
+ void fn2() override {}
+};
+
+static_assert(__is_abstract(Overrides));
+// expected-error@-1 {{static assertion failed due to requirement
'__is_abstract(is_abstract_tests::Overrides)'}} \
+// expected-note@-1 {{'Overrides' is not abstract}} \
+// expected-note@-1 {{because it overrides all pure virtual functions from
base class 'Abstract1'}} \
+// expected-note@-1 {{because it overrides all pure virtual functions from
base class 'Abstract2'}} \
+
+// Inheriting over two levels reports the last class only although the source
of the pure virtual function
+// is the top-most base.
+struct Derived : Abstract1 {
+};
+
+struct Derived2 : Derived {
+ void fn1() override {}
+};
+
+static_assert(__is_abstract(Derived2));
+// expected-error@-1 {{static assertion failed due to requirement
'__is_abstract(is_abstract_tests::Derived2)'}} \
+// expected-note@-1 {{'Derived2' is not abstract}} \
+// expected-note@-1 {{because it overrides all pure virtual functions from
base class 'Derived'}} \
+
+
+using I = int;
+static_assert(__is_abstract(I));
+// expected-error@-1 {{static assertion failed due to requirement
'__is_abstract(int)'}} \
+// expected-note@-1 {{'I' (aka 'int') is not abstract}} \
+// expected-note@-1 {{because it is not a struct or class type}}
+
+using Fty = void(); // function type
----------------
shafik wrote:
```suggestion
using Fty = void();
```
I don't think this comment adds anything b/c the diagnostic below gives the
reason
https://github.com/llvm/llvm-project/pull/156199
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits