r184890 - Don't check for triviality on fields of templated records. We can't know the
Nick Lewycky
nicholas at mxc.ca
Tue Jun 25 16:22:24 PDT 2013
Author: nicholas
Date: Tue Jun 25 18:22:23 2013
New Revision: 184890
URL: http://llvm.org/viewvc/llvm-project?rev=184890&view=rev
Log:
Don't check for triviality on fields of templated records. We can't know the
answer until after instantiation. Fixes PR16061!
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/cxx0x-nontrivial-union.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=184890&r1=184889&r2=184890&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 25 18:22:23 2013
@@ -10748,8 +10748,8 @@ bool Sema::CheckNontrivialField(FieldDec
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>()) {
Modified: cfe/trunk/test/SemaCXX/cxx0x-nontrivial-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-nontrivial-union.cpp?rev=184890&r1=184889&r2=184890&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-nontrivial-union.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-nontrivial-union.cpp Tue Jun 25 18:22:23 2013
@@ -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>'}}
+}
More information about the cfe-commits
mailing list