aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-16 21:30:33 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-16 21:30:33 +0000
commit72b505b7904b3c9320a1312998800ba76e4f5841 (patch)
treef42af0b9389fa6b9366de74a72faaf14b769496d /lib/Sema/SemaDecl.cpp
parent82b4e768d38c12ceba7db23a96e8d845e00fdeb7 (diff)
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
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp29
1 files changed, 5 insertions, 24 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 0d48c62612..81a4abea7f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1230,30 +1230,8 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl,
}
}
- 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 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagD,
DeclSpec::SCS_mutable,
/*PrevDecl=*/0);
+ if (getLangOptions().CPlusPlus)
+ CheckExtraCXXDefaultArguments(D);
+
ProcessDeclAttributes(NewFD, D);
if (D.getInvalidType() || InvalidDecl)