Delay parsing of default arguments of member functions until the class
is completely defined (C++ [class.mem]p2).

Reverse the order in which we process the definitions of member
functions specified inline. This way, we'll get diagnostics in the
order in which the member functions were declared in the class.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61103 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 0d48c62..81a4abe 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1230,30 +1230,8 @@
       }
     }
 
-    if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(NewFD)) {
-      CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(DC);
-
-      // C++ [class.copy]p3:
-      //   A declaration of a constructor for a class X is ill-formed if
-      //   its first parameter is of type (optionally cv-qualified) X and
-      //   either there are no other parameters or else all other
-      //   parameters have default arguments.
-      if ((Constructor->getNumParams() == 1) || 
-          (Constructor->getNumParams() > 1 && 
-           Constructor->getParamDecl(1)->getDefaultArg() != 0)) {
-        QualType ParamType = Constructor->getParamDecl(0)->getType();
-        QualType ClassTy = Context.getTagDeclType(ClassDecl);
-        if (Context.getCanonicalType(ParamType).getUnqualifiedType() 
-              == ClassTy) {
-          Diag(Constructor->getLocation(), diag::err_constructor_byvalue_arg)
-            << SourceRange(Constructor->getParamDecl(0)->getLocation());
-          Constructor->setInvalidDecl();
-        }
-      }
-
-      // Notify the class that we've added a constructor.
-      ClassDecl->addedConstructor(Context, Constructor);
-    }
+    if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(NewFD))
+      InvalidDecl = InvalidDecl || CheckConstructor(Constructor);
     else if (isa<CXXDestructorDecl>(NewFD))
       cast<CXXRecordDecl>(NewFD->getParent())->setUserDeclaredDestructor(true);
     else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(NewFD))
@@ -2865,6 +2843,9 @@
                               DeclSpec::SCS_mutable,
                             /*PrevDecl=*/0);
 
+  if (getLangOptions().CPlusPlus)
+    CheckExtraCXXDefaultArguments(D);
+
   ProcessDeclAttributes(NewFD, D);
 
   if (D.getInvalidType() || InvalidDecl)