]> granicus.if.org Git - clang/commitdiff
add a const qualifier, refactor some code.
authorChris Lattner <sabre@nondot.org>
Sun, 11 Jul 2010 22:24:20 +0000 (22:24 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 11 Jul 2010 22:24:20 +0000 (22:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108104 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Parser.h
lib/Parse/ParseDecl.cpp
lib/Parse/Parser.cpp

index 91050fd790708b24351e2c923dd58566277cdb67..74293a4ba8ddaf7dda0fc818c5c665fea3123a6b 100644 (file)
@@ -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);
index df02f95d67571ea312aba35d8449e1250c90a429..0334209f5044da42fcf82e9b06e0960779cf6d4b 100644 (file)
@@ -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);
 
index b4118fbd0a528bab19c2fb77cf505e063b7d87bc..b51dd26e8259b7aee2b3bb237cd36be0919b84b8 100644 (file)
@@ -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