diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-22 02:56:56 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-22 02:56:56 +0000 |
commit | bc46e4341e954a47dbb86e272847ab65fcdcc44f (patch) | |
tree | 4b17f4700ea2ed225c1de9cbdd23797adc727fdf /clang/test/SemaCXX/abstract.cpp | |
parent | 75a7c32a3cf1e029fadd01f6a93952c975f7fcd6 (diff) | |
download | bcm5719-llvm-bc46e4341e954a47dbb86e272847ab65fcdcc44f.tar.gz bcm5719-llvm-bc46e4341e954a47dbb86e272847ab65fcdcc44f.zip |
Implement DR257 / fix PR16659:
A constructor for an abstract class does not call constructors for virtual
base classes, so it is not an error if no initializer is present for the
virtual base and the virtual base cannot be default initialized.
Also provide a (disabled by default, for now) warning for the case where a
virtual base class's initializer is ignored in an abstract class's constructor,
and address a defect in DR257 where it was not carried through to C++11's rules
for implicit deletion of special member functions.
Based on a patch by Maurice Bos.
llvm-svn: 186803
Diffstat (limited to 'clang/test/SemaCXX/abstract.cpp')
-rw-r--r-- | clang/test/SemaCXX/abstract.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/abstract.cpp b/clang/test/SemaCXX/abstract.cpp index 1c5b715775d..d7e2d0a3dcf 100644 --- a/clang/test/SemaCXX/abstract.cpp +++ b/clang/test/SemaCXX/abstract.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wabstract-vbase-init #ifndef __GXX_EXPERIMENTAL_CXX0X__ #define __CONCAT(__X, __Y) __CONCAT1(__X, __Y) @@ -280,3 +280,30 @@ namespace pr12658 { foo(C(99)); // expected-error {{allocating an object of abstract class type 'pr12658::C'}}
} } + +namespace pr16659 { + struct A { + A(int); + virtual void x() = 0; // expected-note {{unimplemented pure virtual method 'x' in 'RedundantInit'}} + }; + struct B : virtual A {}; + struct C : B { + C() : A(37) {} + void x() override {} + }; + + struct X { + friend class Z; + private: + X &operator=(const X&); + }; + struct Y : virtual X { // expected-note {{::X' has an inaccessible copy assignment}} + virtual ~Y() = 0; + }; + struct Z : Y {}; // expected-note {{::Y' has a deleted copy assignment}} + void f(Z &a, const Z &b) { a = b; } // expected-error {{copy assignment operator is implicitly deleted}} + + struct RedundantInit : virtual A { + RedundantInit() : A(0) {} // expected-warning {{initializer for virtual base class 'pr16659::A' of abstract class 'RedundantInit' will never be used}} + }; +} |