Fix lack of declaration decorations for dynamic arrays in Pas2C 1.0.0
authorunc0rr
Tue, 20 Oct 2020 20:09:44 +0200
branch1.0.0
changeset 15864 c63d0ea4907d
parent 15863 d04f4a0af0fe
child 15865 6b10b0cdbeab
Fix lack of declaration decorations for dynamic arrays in Pas2C
tools/pas2c/Pas2C.hs
--- a/tools/pas2c/Pas2C.hs	Mon Sep 12 18:23:24 2022 -0400
+++ b/tools/pas2c/Pas2C.hs	Tue Oct 20 20:09:44 2020 +0200
@@ -574,10 +574,7 @@
     liftM (map(\i -> t' i)) $ mapM (id2CTyped2 (Just $ t' empty) (VarParamType t)) ids
 
 tvar2C _ externVar includeType ignoreInit (VarDeclaration _ isConst (ids, t) mInitExpr) = do
-    t' <- liftM (((if isConst then text "static const" else if externVar
-                                                                then text "extern"
-                                                                else empty)
-                   <+>) . ) $ type2C t
+    t' <- liftM ((declDetails <+>) . ) $ type2C t
     ie <- initExpr mInitExpr
     lt <- gets lastType
     case (isConst, lt, ids, mInitExpr) of
@@ -602,12 +599,15 @@
                     where
                         arrayDimStr = show $ arrayDimension t
                         arrayDimInitExp = text ("={" ++ ".dim = " ++ arrayDimStr ++ ", .a = {0, 0, 0, 0}}")
-                        dimDecl = varDeclDecision isConst includeType (text "fpcrtl_dimension_t" <+>  i' <> text "_dimension_info") arrayDimInitExp
+                        dimDecl = varDeclDecision isConst includeType (declDetails <+> text "fpcrtl_dimension_t" <+>  i' <> text "_dimension_info") arrayDimInitExp
 
                 (_, _) -> return result
 
          _ -> liftM (map(\i -> varDeclDecision isConst includeType (t' i) ie)) $ mapM (id2CTyped2 (Just $ t' empty) t) ids
     where
+    declDetails = if isConst then text "static const" else if externVar
+                                                            then text "extern"
+                                                            else empty
     initExpr Nothing = return $ empty
     initExpr (Just e) = liftM (text "=" <+>) (initExpr2C e)
     varDeclDecision True True varStr expStr = varStr <+> expStr