aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-11 22:24:20 +0000
committerChris Lattner <sabre@nondot.org>2010-07-11 22:24:20 +0000
commitc82daefa3062721e98947e08193cd81b4e9df915 (patch)
treeec36729bbacd5a31756904e7cf366eb9668c9d2a
parent1bdb5a68912ff114fcf681bfb823fff0d1c25a84 (diff)
add a const qualifier, refactor some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108104 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Parse/Parser.h2
-rw-r--r--lib/Parse/ParseDecl.cpp14
-rw-r--r--lib/Parse/Parser.cpp2
3 files changed, 10 insertions, 8 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index 91050fd790..74293a4ba8 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -833,7 +833,7 @@ private:
//===--------------------------------------------------------------------===//
// C99 6.9: External Definitions.
DeclGroupPtrTy ParseExternalDeclaration(CXX0XAttributeList Attr);
- bool isDeclarationAfterDeclarator();
+ bool isDeclarationAfterDeclarator() const;
bool isStartOfFunctionDefinition();
DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(AttributeList *Attr,
AccessSpecifier AS = AS_none);
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index df02f95d67..0334209f50 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/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/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index b4118fbd0a..b51dd26e82 100644
--- a/lib/Parse/Parser.cpp
+++ b/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