[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

Sebastian Redl sebastian.redl at getdesigned.at
Tue Dec 1 13:19:31 PST 2009


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.

Sebastian



More information about the cfe-commits mailing list