summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-05-07 04:49:29 +0000
committerDouglas Gregor <dgregor@apple.com>2008-05-07 04:49:29 +0000
commitcaa8acebe738aaa17fcbaa99b3f39da7874a6063 (patch)
tree3783ae6afce1b29c8f024d726bb41ca7951f57a7 /clang/lib/Sema/SemaDecl.cpp
parent9930bd8c4f778145c97a8baa2e6d0311cfa89e2e (diff)
downloadbcm5719-llvm-caa8acebe738aaa17fcbaa99b3f39da7874a6063.tar.gz
bcm5719-llvm-caa8acebe738aaa17fcbaa99b3f39da7874a6063.zip
Diagnose attempts to use C++ default arguments outside of a function declaration
llvm-svn: 50799
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2624f5019db..9e9509adaa8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud