diff options
author | Chris Lattner <sabre@nondot.org> | 2010-07-11 22:24:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-07-11 22:24:20 +0000 |
commit | dbb1e93a9fc79d136ffbaea0dbe5342785ab9d2e (patch) | |
tree | 56f62f9834d405d4654541e6fecc884ce0741eba /clang/lib | |
parent | 2c52b7997c5a748ed8251ca40dd0e28db28f99fa (diff) | |
download | bcm5719-llvm-dbb1e93a9fc79d136ffbaea0dbe5342785ab9d2e.tar.gz bcm5719-llvm-dbb1e93a9fc79d136ffbaea0dbe5342785ab9d2e.zip |
add a const qualifier, refactor some code.
llvm-svn: 108104
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index df02f95d675..0334209f504 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -395,12 +395,14 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, return DeclGroupPtrTy(); } - if (AllowFunctionDefinitions && D.isFunctionDeclarator()) { - if (isDeclarationAfterDeclarator()) { - // Fall though. We have to check this first, though, because - // __attribute__ might be the start of a function definition in - // (extended) K&R C. - } else if (isStartOfFunctionDefinition()) { + // Check to see if we have a function *definition* which must have a body. + if (AllowFunctionDefinitions && D.isFunctionDeclarator() && + // Look at the next token to make sure that this isn't a function + // declaration. We have to check this because __attribute__ might be the + // start of a function definition in GCC-extended K&R C. + !isDeclarationAfterDeclarator()) { + + if (isStartOfFunctionDefinition()) { if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { Diag(Tok, diag::err_function_declared_typedef); diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index b4118fbd0a5..b51dd26e825 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -509,7 +509,7 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr) /// \brief Determine whether the current token, if it occurs after a /// declarator, continues a declaration or declaration list. -bool Parser::isDeclarationAfterDeclarator() { +bool Parser::isDeclarationAfterDeclarator() const { return Tok.is(tok::equal) || // int X()= -> not a function def Tok.is(tok::comma) || // int X(), -> not a function def Tok.is(tok::semi) || // int X(); -> not a function def |