diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-05-07 04:49:29 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-05-07 04:49:29 +0000 |
commit | 6d6eb57225b53fb627c565861d1d0e90645400d1 (patch) | |
tree | 78f85cfa25a37b468300c0bd09e59cf7e6e131e8 /lib/Sema/SemaDecl.cpp | |
parent | 84060dbbe5b06c26b25d0ba7107213479a2e0f8b (diff) |
Diagnose attempts to use C++ default arguments outside of a function declaration
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2624f5019d..9e9509adaa 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -785,6 +785,10 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { assert(!R.isNull() && "GetTypeForDeclarator() returned null type"); if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) { + // Check that there are no default arguments (C++ only). + if (getLangOptions().CPlusPlus) + CheckExtraCXXDefaultArguments(D); + TypedefDecl *NewTD = ParseTypedefDecl(S, D, R, LastDeclarator); if (!NewTD) return 0; @@ -889,6 +893,10 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { if (getLangOptions().CPlusPlus) CheckCXXDefaultArguments(NewFD); } else { + // Check that there are no default arguments (C++ only). + if (getLangOptions().CPlusPlus) + CheckExtraCXXDefaultArguments(D); + if (R.getTypePtr()->isObjCInterfaceType()) { Diag(D.getIdentifierLoc(), diag::err_statically_allocated_object, D.getIdentifier()->getName()); @@ -1108,7 +1116,11 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { DS.ClearStorageClassSpecs(); } - + // Check that there are no default arguments inside the type of this + // parameter (C++ only). + if (getLangOptions().CPlusPlus) + CheckExtraCXXDefaultArguments(D); + // In this context, we *do not* check D.getInvalidType(). If the declarator // type was invalid, GetTypeForDeclarator() still returns a "valid" type, // though it will not reflect the user specified type. |