[cfe-commits] r144715 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CXX/special/class.ctor/p5-0x.cpp

Eli Friedman eli.friedman at gmail.com
Tue Nov 15 14:39:08 PST 2011


Author: efriedma
Date: Tue Nov 15 16:39:08 2011
New Revision: 144715

URL: http://llvm.org/viewvc/llvm-project?rev=144715&view=rev
Log:
Compute whether a class is trivial correctly for template classes with an explicitly deleted or defaulted special member.  PR11387.


Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=144715&r1=144714&r2=144715&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Nov 15 16:39:08 2011
@@ -1526,6 +1526,12 @@
 
   SemaRef.CheckOverrideControl(Method);
 
+  // If a function is defined as defaulted or deleted, mark it as such now.
+  if (D->isDefaulted())
+    Method->setDefaulted();
+  if (D->isDeletedAsWritten())
+    Method->setDeletedAsWritten();
+
   if (FunctionTemplate) {
     // If there's a function template, let our caller handle it.
   } else if (Method->isInvalidDecl() && !Previous.empty()) {

Modified: cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp?rev=144715&r1=144714&r2=144715&view=diff
==============================================================================
--- cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp (original)
+++ cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp Tue Nov 15 16:39:08 2011
@@ -157,7 +157,14 @@
 
 // Otherwise, the default constructor is non-trivial.
 class Trivial2 { Trivial2() = delete; };
-static_assert(__has_trivial_constructor(Trivial2), "NonTrivialDefCtor2 is trivial");
+static_assert(__has_trivial_constructor(Trivial2), "Trivial2 is trivial");
 
 class Trivial3 { Trivial3() = default; };
-static_assert(__has_trivial_constructor(Trivial3), "NonTrivialDefCtor3 is trivial");
+static_assert(__has_trivial_constructor(Trivial3), "Trivial3 is trivial");
+
+template<typename T> class Trivial4 { Trivial4() = default; };
+static_assert(__has_trivial_constructor(Trivial4<int>), "Trivial4 is trivial");
+
+template<typename T> class Trivial5 { Trivial5() = delete; };
+static_assert(__has_trivial_constructor(Trivial5<int>), "Trivial5 is trivial");
+





More information about the cfe-commits mailing list