"%select{return|parameter|variable|field}0 type %1 is an abstract class">;
def err_allocation_of_abstract_type : Error<
"allocation of an object of abstract type %0">;
+def err_throw_abstract_type : Error<
+ "cannot throw an object of abstract type %0">;
def err_multiple_final_overriders : Error<
"virtual function %q0 has more than one final overrider in %1">;
<< E->getSourceRange()))
return true;
+ if (RequireNonAbstractType(ThrowLoc, E->getType(),
+ PDiag(diag::err_throw_abstract_type)
+ << E->getSourceRange()))
+ return true;
+
// FIXME: This is just a hack to mark the copy constructor referenced.
// This should go away when the next FIXME is fixed.
const RecordType *RT = Ty->getAs<RecordType>();
}
}
}
+
+// Cannot throw an abstract type.
+class foo {
+public:
+ foo() {}
+ void bar () {
+ throw *this; // expected-error{{cannot throw an object of abstract type 'foo'}}
+ }
+ virtual void test () = 0; // expected-note{{pure virtual function 'test'}}
+};