From 9712df44580af0d2579dd4b75ae7486962584014 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 27 Feb 2008 14:00:54 +0000 Subject: [PATCH] Added a type annotation (esp. for signed types) for hex literals in the C/C++ backends --- backends/GenerateC.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 245f722..7087b54 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -479,8 +479,13 @@ cgenLiteralRepr (A.IntLiteral m s) t = do genDecimal s genLitSuffix t cgenLiteralRepr (A.HexLiteral m s) t - = do tell ["0x", s] + = do f <- fget getScalarType + ct <- case f t of + Just ct -> return ct + Nothing -> diePC m $ formatCode "Non-scalar type for hex literal: " t + tell ["((",ct,")0x", s] genLitSuffix t + tell [")"] cgenLiteralRepr (A.ByteLiteral m s) _ = tell ["'"] >> genByteLiteral s >> tell ["'"] cgenLiteralRepr (A.ArrayLiteral m aes) _ = do genLeftB