Don't check for triviality on fields of templated records. We can't know the

answer until after instantiation. Fixes PR16061!

llvm-svn: 184890
This commit is contained in:
Nick Lewycky 2013-06-25 23:22:23 +00:00
parent 502b0ed264
commit 7a2a4799d6
2 changed files with 24 additions and 2 deletions

View File

@ -10748,8 +10748,8 @@ bool Sema::CheckNontrivialField(FieldDecl *FD) {
assert(FD);
assert(getLangOpts().CPlusPlus && "valid check only for C++");
if (FD->isInvalidDecl())
return true;
if (FD->isInvalidDecl() || FD->getType()->isDependentType())
return false;
QualType EltTy = Context.getBaseElementType(FD->getType());
if (const RecordType *RT = EltTy->getAs<RecordType>()) {

View File

@ -122,3 +122,25 @@ namespace optional {
o2 = optional<non_trivial>();
}
}
namespace pr16061 {
struct X { X(); };
template<typename T> struct Test1 {
union {
struct {
X x;
};
};
};
template<typename T> struct Test2 {
union {
struct { // expected-note {{default constructor of 'Test2<pr16061::X>' is implicitly deleted because variant field '' has a non-trivial default constructor}}
T x;
};
};
};
Test2<X> t2x; // expected-error {{call to implicitly-deleted default constructor of 'Test2<pr16061::X>'}}
}