Simplify complex/_Complex types (#6939)

This commit is contained in:
PKEuS 2015-08-26 13:13:45 +02:00
parent c8c59aa92b
commit 37aec52399
3 changed files with 18 additions and 1 deletions

View File

@ -381,6 +381,12 @@ public:
void isOperatorKeyword(bool value) { void isOperatorKeyword(bool value) {
setFlag(fIsOperatorKeyword, value); setFlag(fIsOperatorKeyword, value);
} }
bool isComplex() const {
return getFlag(fIsComplex);
}
void isComplex(bool value) {
setFlag(fIsComplex, value);
}
static const Token *findsimplematch(const Token *tok, const char pattern[]); static const Token *findsimplematch(const Token *tok, const char pattern[]);
static const Token *findsimplematch(const Token *tok, const char pattern[], const Token *end); static const Token *findsimplematch(const Token *tok, const char pattern[], const Token *end);
@ -802,7 +808,8 @@ private:
fIsAttributeNoreturn = (1 << 12), // __attribute__((noreturn)), __declspec(noreturn) fIsAttributeNoreturn = (1 << 12), // __attribute__((noreturn)), __declspec(noreturn)
fIsAttributeNothrow = (1 << 13), // __attribute__((nothrow)), __declspec(nothrow) fIsAttributeNothrow = (1 << 13), // __attribute__((nothrow)), __declspec(nothrow)
fIsAttributeUsed = (1 << 14), // __attribute__((used)) fIsAttributeUsed = (1 << 14), // __attribute__((used))
fIsOperatorKeyword = (1 << 15) // operator=, etc fIsOperatorKeyword = (1 << 15), // operator=, etc
fIsComplex = (1 << 16) // complex/_Complex type
}; };
unsigned int _flags; unsigned int _flags;

View File

@ -5652,6 +5652,11 @@ void Tokenizer::simplifyStdType()
tok->isSigned(!isUnsigned); tok->isSigned(!isUnsigned);
} }
else if (Token::Match(tok, "float|double complex|_Complex")) {
tok->deleteNext();
tok->isComplex(true);
}
else if (!Token::Match(tok, "unsigned|signed|char|short|int|long")) else if (!Token::Match(tok, "unsigned|signed|char|short|int|long"))
continue; continue;

View File

@ -4590,6 +4590,11 @@ private:
const char expected[] = "signed short x ;"; const char expected[] = "signed short x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code)); ASSERT_EQUALS(expected, tokenizeAndStringify(code));
} }
{
const char code[] = "float complex x;";
const char expected[] = "float x ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
} }
void createLinks() { void createLinks() {