Fixed a bug involving abbreviation of arrays of channels into arrays of channel-ends in the C++ backend

The array for the channel-ends was not being allocated storage, so the array (a pointer to some random location) was being written to and causing a seg-fault
This commit is contained in:
Neil Brown 2009-01-28 23:16:31 +00:00
parent 6ff8e3b163
commit a4f0e85c72

View File

@ -621,9 +621,15 @@ cppintroduceSpec (A.Specification _ n (A.Proc _ sm fs p))
--A helper function for calling the wrapped functions:
genParamList :: [A.Formal] -> CGen()
genParamList fs = infixComma $ map genParam fs
cppintroduceSpec (A.Specification _ n (A.Is _ am t@(A.Array _ (A.ChanEnd {})) (A.DirectedVariable
cppintroduceSpec (A.Specification _ n (A.Is _ am t@(A.Array ds c@(A.ChanEnd {})) dirV@(A.DirectedVariable
m dir v)))
= do call genDecl am t n
= do t' <- if A.UnknownDimension `elem` ds
then do dirVT <- astTypeOf dirV
case dirVT of
A.Array ds' _ -> return $ A.Array ds' c
_ -> diePC m $ formatCode "Expected variable to be an array type, instead: %" dirVT
else return t
call genDeclaration t' n False
tell [";"]
tell ["tockInitChan",if dir == A.DirInput then "in" else "out","Array("]
call genVariableAM v am