summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/cplusplus/ResolveExpression.cpp44
-rw-r--r--src/shared/cplusplus/Literals.cpp14
-rw-r--r--src/shared/cplusplus/Literals.h2
3 files changed, 25 insertions, 35 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index 3f145979f3..aadc1f5273 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 a90d82572b..d56f937c48 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 f9653b8ca2..afe9bae2e1 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;