#7490 sizeof('a') should be 4 in C mode
This commit is contained in:
parent
60efae147f
commit
251fc022fa
|
@ -3215,7 +3215,7 @@ bool Tokenizer::simplifySizeof()
|
|||
tok->deleteThis();
|
||||
tok->deleteNext();
|
||||
std::ostringstream sz;
|
||||
sz << sizeof 'x';
|
||||
sz << ((isC()) ? 4 : 1) ; // #7490 sizeof('a') should be 4 in C mode
|
||||
tok->str(sz.str());
|
||||
ret = true;
|
||||
continue;
|
||||
|
|
|
@ -388,6 +388,7 @@ private:
|
|||
// a = b = 0;
|
||||
TEST_CASE(multipleAssignment);
|
||||
|
||||
TEST_CASE(sizeOfCharLiteral);
|
||||
TEST_CASE(platformWin);
|
||||
TEST_CASE(platformWin32);
|
||||
TEST_CASE(platformWin32A);
|
||||
|
@ -5865,6 +5866,13 @@ private:
|
|||
ASSERT_EQUALS("a = b = 0 ;", tokenizeAndStringify("a=b=0;"));
|
||||
}
|
||||
|
||||
void sizeOfCharLiteral() { // #7490 sizeof('a') should be 4 in C mode
|
||||
ASSERT_EQUALS("unsigned long a ; a = 4 ;",
|
||||
tokenizeAndStringify("unsigned long a = sizeof('x');", true, true, Settings::Native, "test.c", false));
|
||||
ASSERT_EQUALS("unsigned long a ; a = 1 ;",
|
||||
tokenizeAndStringify("unsigned long a = sizeof('x');", true, true, Settings::Native, "test.cpp", true));
|
||||
}
|
||||
|
||||
void platformWin() {
|
||||
const char code[] = "BOOL f;"
|
||||
"BOOLEAN g;"
|
||||
|
|
Loading…
Reference in New Issue