Fix abbreviation of channel ends in the C backend.
I'm pretty sure this test used to fail and got fixed, but I think the test was fixed to match the incorrect code rather than the other way around. What it's testing is the abbreviation of a channel end as an identically-typed channel end, which (since they're both pointers) should look something like: Channel *c; Channel *d = c; Instead it was generating "d = &c", which broke cgtest87. The change made to GenerateC to fix this feels a bit awkward to me -- it's very simple, but it's yet another special case in genVariableAM. All of the genVariable code could really use reworking (again), perhaps to use some internal representation of the C expression...
This commit is contained in:
parent
19484ec72e
commit
ad875bd477
|
@ -1133,6 +1133,7 @@ cgenVariableAM v am
|
|||
case (indirectedType t, t) of
|
||||
(True, _) -> return ()
|
||||
(False, A.Array {}) -> return ()
|
||||
(False, A.Chan {}) -> return ()
|
||||
_ -> tell ["&"]
|
||||
call genVariable v
|
||||
|
||||
|
|
|
@ -623,7 +623,7 @@ testSpec = TestList
|
|||
,testAllSameForTypes 610 (\t -> ("$(" ++ show t ++ ")*const foo=(&bar);","")) (\t -> A.Is emptyMeta A.Abbrev t (variable "bar")) [chanInt,A.Record foo]
|
||||
--Abbreviations of channel-ends in C++ should just copy the channel-end, rather than trying to take the address of the temporary returned by writer()/reader()
|
||||
--C abbreviations will be of type Channel*, so they can just copy the channel address.
|
||||
,testAllForTypes 620 (\t -> ("$(" ++ show t ++ ") foo=&bar;","")) (\t -> ("$(" ++ show t ++ ") foo=bar;",""))
|
||||
,testAllForTypes 620 (\t -> ("$(" ++ show t ++ ") foo=bar;","")) (\t -> ("$(" ++ show t ++ ") foo=bar;",""))
|
||||
(\t -> A.Is emptyMeta A.Abbrev t (variable "bar")) [chanIntIn,chanIntOut]
|
||||
|
||||
,testAllSameForTypes 700 (\t -> ("const $(" ++ show t ++ ") foo=bar;","")) (\t -> A.Is emptyMeta A.ValAbbrev t (variable "bar")) [A.Int,A.Time]
|
||||
|
|
Loading…
Reference in New Issue
Block a user