diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-### 0.16.6
+### 0.16.7
   * Added mention of Fortran 2003 version support in the help message
   * Improved parsing of `allocate` statements
 
diff --git a/app/Main.hs b/app/Main.hs
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -51,7 +51,7 @@
 programName = "fortran-src"
 
 showVersion :: String
-showVersion = "0.16.6"
+showVersion = "0.16.7"
 
 main :: IO ()
 main = do
diff --git a/fortran-src.cabal b/fortran-src.cabal
--- a/fortran-src.cabal
+++ b/fortran-src.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           fortran-src
-version:        0.16.6
+version:        0.16.7
 synopsis:       Parsers and analyses for Fortran standards 66, 77, 90, 95 and 2003 (partial).
 description:    Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, Fortran 95, Fortran 2003 (partial) and some legacy extensions. Includes data flow and basic block analysis, a renamer, and type analysis. For example usage, see the @<https://hackage.haskell.org/package/camfort CamFort>@ project, which uses fortran-src as its front end.
 category:       Language
diff --git a/src/Language/Fortran/Parser/Free/Lexer.x b/src/Language/Fortran/Parser/Free/Lexer.x
--- a/src/Language/Fortran/Parser/Free/Lexer.x
+++ b/src/Language/Fortran/Parser/Free/Lexer.x
@@ -450,11 +450,20 @@
             | fillConstr TRightPar == toConstr tok = n - 1
             | otherwise                            = n
 
+-- Detect whether the current line is part of an allocate statement
+-- (which may be prepended with other tokens, e.g., if this is an `if` statement
+-- with aan allocate statement inside on a single line).
+allocateStatement :: [Token] -> Maybe [Token]
+allocateStatement (hd1:hd2:rest)
+  | toConstr hd1 `elem` [fillConstr TAllocate, fillConstr TDeallocate]
+  , toConstr hd2 == fillConstr TLeftPar
+  = Just rest
+  | otherwise = allocateStatement (hd2:rest)
+allocateStatement _ = Nothing
+
 allocateP :: User -> AlexInput -> Int -> AlexInput -> Bool
 allocateP _ _ _ ai
-  | alloc:lpar:rest <- prevTokens
-  , toConstr alloc `elem` [fillConstr TAllocate, fillConstr TDeallocate]
-  , fillConstr TLeftPar  == toConstr lpar
+  | Just rest <- allocateStatement (prevTokens)
   = null rest || (followsComma && parenLevel prevTokens == 1)
   | otherwise = False
   where
diff --git a/test/Language/Fortran/Parser/Free/Fortran2003Spec.hs b/test/Language/Fortran/Parser/Free/Fortran2003Spec.hs
--- a/test/Language/Fortran/Parser/Free/Fortran2003Spec.hs
+++ b/test/Language/Fortran/Parser/Free/Fortran2003Spec.hs
@@ -180,4 +180,17 @@
             expBinVars op x1 x2 = ExpBinary () u op (expValVar x1) (expValVar x2)
         bParser text `shouldBe'` expected
 
+    describe "allocate statement" $ do
+      it "parses allocated nested in another statement" $ do
+        let text = "if(y) allocate(x,stat=ierr_allocate)"
+        let expected = StIfLogical () u
+                    (ExpValue () u (ValVariable "y")) (StAllocate () u Nothing
+                        (AList  {alistAnno = (),
+                                 alistSpan = u,
+                                 alistList = [ExpValue () u (ValVariable "x")]})
+                        (Just AList {alistAnno = (),
+                                     alistSpan = u,
+                                     alistList = [AOStat () u (ExpValue () u (ValVariable "ierr_allocate"))]}))
+        sParser text `shouldBe'` expected
+
     specFreeCommon bParser sParser eParser
