Richard Smith 81f5ade227 Move checks for creation of objects of abstract class type from the various
constructs that can do so into the initialization code. This fixes a number
of different cases in which we used to fail to check for abstract types.

Thanks to Tim Shen for inspiring the weird code that uncovered this!

llvm-svn: 289753
2016-12-15 02:28:18 +00:00

24 lines
461 B
C++

// RUN: %clang_cc1 -std=c++1z -verify %s
// no objects of an abstract class can be created except as subobjects of a
// class derived from it
struct A {
A() {}
A(int) : A() {} // ok
virtual void f() = 0; // expected-note 1+{{unimplemented}}
};
void f(A &&a);
void g() {
f({}); // expected-error {{abstract class}}
f({0}); // expected-error {{abstract class}}
f(0); // expected-error {{abstract class}}
}
struct B : A {
B() : A() {} // ok
};