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:
parent
502b0ed264
commit
7a2a4799d6
|
@ -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>()) {
|
||||
|
|
|
@ -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>'}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue