diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 3f145979f3b8c5517a2e7144497168b28073f6eb..aadc1f5273a09f7290584f6493283b465b0d6a37 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -254,32 +254,36 @@ bool ResolveExpression::visit(SizeofExpressionAST *) bool ResolveExpression::visit(NumericLiteralAST *ast) { + const Token &tk = tokenAt(ast->literal_token); + Type *type = 0; - const NumericLiteral *literal = numericLiteral(ast->literal_token); + bool isUnsigned = false; - if (literal->isChar()) + if (tk.is(T_CHAR_LITERAL)) type = control()->integerType(IntegerType::Char); - else if (literal->isWideChar()) + else if (tk.is(T_WIDE_CHAR_LITERAL)) 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); + else if (const NumericLiteral *literal = numericLiteral(ast->literal_token)) { + isUnsigned = literal->isUnsigned(); + + 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); - + ty.setUnsigned(isUnsigned); addResult(ty, _scope); return false; } diff --git a/src/shared/cplusplus/Literals.cpp b/src/shared/cplusplus/Literals.cpp index a90d82572b50df88f7dba9932bf34408302c5646..d56f937c4820e00e8e701d379894ab18b4bef273 100644 --- a/src/shared/cplusplus/Literals.cpp +++ b/src/shared/cplusplus/Literals.cpp @@ -118,8 +118,6 @@ StringLiteral::~StringLiteral() //////////////////////////////////////////////////////////////////////////////// enum { - NumericLiteralIsChar, - NumericLiteralIsWideChar, NumericLiteralIsInt, NumericLiteralIsFloat, NumericLiteralIsDouble, @@ -133,11 +131,7 @@ NumericLiteral::NumericLiteral(const char *chars, unsigned size) { f._type = NumericLiteralIsInt; - if (chars[0] == '\'') { - f._type = NumericLiteralIsChar; - } else if (size > 1 && chars[0] == 'L' && chars[1] == '\'') { - f._type = NumericLiteralIsWideChar; - } else if (size > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) { + if (size > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) { f._isHex = true; } else { const char *begin = chars; @@ -192,12 +186,6 @@ bool NumericLiteral::isHex() const bool NumericLiteral::isUnsigned() const { return f._isUnsigned; } -bool NumericLiteral::isChar() const -{ return f._type == NumericLiteralIsChar; } - -bool NumericLiteral::isWideChar() const -{ return f._type == NumericLiteralIsWideChar; } - bool NumericLiteral::isInt() const { return f._type == NumericLiteralIsInt; } diff --git a/src/shared/cplusplus/Literals.h b/src/shared/cplusplus/Literals.h index f9653b8ca25cbbdd5418940776cd2e0e41945b8e..afe9bae2e16a1d213f93abe1eff9ec97010993bf 100644 --- a/src/shared/cplusplus/Literals.h +++ b/src/shared/cplusplus/Literals.h @@ -104,8 +104,6 @@ public: NumericLiteral(const char *chars, unsigned size); virtual ~NumericLiteral(); - bool isChar() const; - bool isWideChar() const; bool isInt() const; bool isFloat() const; bool isDouble() const;