From def098bcbd3006563129168b9e6e8d6c5e58ab7e Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 10 Jul 2009 17:07:47 +0200 Subject: [PATCH] Return the right type for the literal. --- src/libs/cplusplus/ResolveExpression.cpp | 29 ++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 7f53de1ed5f..51bfef0443f 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -343,9 +343,34 @@ bool ResolveExpression::visit(SizeofExpressionAST *) return false; } -bool ResolveExpression::visit(NumericLiteralAST *) +bool ResolveExpression::visit(NumericLiteralAST *ast) { - FullySpecifiedType ty(control()->integerType(IntegerType::Int)); + Type *type = 0; + NumericLiteral *literal = numericLiteral(ast->literal_token); + + if (literal->isChar()) + type = control()->integerType(IntegerType::Char); + else if (literal->isWideChar()) + type = control()->integerType(IntegerType::WideChar); + else if (literal->isInt()) + type = control()->integerType(IntegerType::Int); + else if (literal->isLong()) + type = control()->integerType(IntegerType::Long); + else if (literal->isLongLong()) + type = control()->integerType(IntegerType::LongLong); + else if (literal->isFloat()) + type = control()->floatType(FloatType::Float); + else if (literal->isDouble()) + type = control()->floatType(FloatType::Double); + else if (literal->isLongDouble()) + type = control()->floatType(FloatType::LongDouble); + else + type = control()->integerType(IntegerType::Int); + + FullySpecifiedType ty(type); + if (literal->isUnsigned()) + ty.setUnsigned(true); + addResult(ty); return false; }