]> granicus.if.org Git - clang/commitdiff
constexpr is allowed on static member functions of non-literal classes. Per report...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 13 Jan 2012 02:31:53 +0000 (02:31 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 13 Jan 2012 02:31:53 +0000 (02:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148090 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp

index 9fcac224a2368ef91240a338ce3fd000d7ee41e5..9bb2639877c14e77f0ced35f5825954ac844157b 100644 (file)
@@ -3675,7 +3675,7 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) {
     for (CXXRecordDecl::method_iterator M = Record->method_begin(),
                                      MEnd = Record->method_end();
          M != MEnd; ++M) {
-      if ((*M)->isConstexpr()) {
+      if (M->isConstexpr() && M->isInstance()) {
         switch (Record->getTemplateSpecializationKind()) {
         case TSK_ImplicitInstantiation:
         case TSK_ExplicitInstantiationDeclaration:
index 51a062d86692bc5b67f8e2470df67f230e32084e..c4935b34a062d6cd9e9187d2c357fc92c87cfc17 100644 (file)
@@ -30,3 +30,9 @@ namespace std_example {
     { return x * 2 + 3 * y; }
 
 }
+
+// The constexpr specifier is allowed for static member functions of non-literal types.
+class NonLiteralClass {
+  NonLiteralClass(bool);
+  static constexpr bool isDebugFlag();
+};