[cfe-commits] r90241 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaCXX/virtual-override.cpp

Douglas Gregor dgregor at apple.com
Thu Dec 3 10:37:09 PST 2009


On Dec 1, 2009, at 1:19 PM, Sebastian Redl wrote:

> Douglas Gregor wrote:
>> Author: dgregor
>> Date: Tue Dec  1 11:24:26 2009
>> New Revision: 90241
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=90241&view=rev
>> Log:
>> Move the checking of overridden virtual functions into the code path
>> common to both parsing and template instantiation, so that we'll find
>> overridden virtuals for member functions of class templates when they
>> are instantiated. 
>> 
>> Additionally, factor out the checking for pure virtual functions, so
>> that it will be executed both at parsing time and at template
>> instantiation time. 
>> 
>> These changes fix PR5656 (for real), although one more tweak
>> w.r.t. member function templates will be coming along shortly.
>> 
>> +
>> +template <typename Base>
>> +struct Foo : Base { 
>> +  void f() = 0; // expected-error{{not virtual and cannot be declared pure}}
>> +};
>> +
>> +struct Base1 { virtual void f(); };
>> +struct Base2 { };
>> +
>> +void test() {
>> +  Foo<Base1> f1;
>> +  Foo<Base2> f2; // expected-note{{instantiation}}
>> +}
>> 
> It appears that we don't yet check for abstract classes when creating
> variables. Or is there something else here? Foo<Base1> should be
> abstract, and the declaration of f1 should create an error pointing this
> out.


We do have checks for variables whose types are abstract (test/SemaCXX/abstract.cpp has some examples), and you're right: there's something else going on here. Check out the fix in:

	http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20091130/024826.html

	- Doug



More information about the cfe-commits mailing list