#7490 sizeof('a') should be sizeof(int) in C mode. Previous fix was hardcoding 4 for C.
This commit is contained in:
parent
4816394511
commit
9d1302d523
|
@ -3217,7 +3217,7 @@ bool Tokenizer::simplifySizeof()
|
|||
tok->deleteThis();
|
||||
tok->deleteNext();
|
||||
std::ostringstream sz;
|
||||
sz << ((isC()) ? 4 : 1) ; // #7490 sizeof('a') should be 4 in C mode
|
||||
sz << ((isC()) ? _settings->sizeof_int : 1) ; // #7490 sizeof('a') should be sizeof(int) in C mode
|
||||
tok->str(sz.str());
|
||||
ret = true;
|
||||
continue;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "path.h"
|
||||
#include "preprocessor.h" // usually tests here should not use preprocessor...
|
||||
#include <cstring>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
class TestTokenizer : public TestFixture {
|
||||
public:
|
||||
|
@ -5878,7 +5878,9 @@ private:
|
|||
}
|
||||
|
||||
void sizeOfCharLiteral() { // #7490 sizeof('a') should be 4 in C mode
|
||||
ASSERT_EQUALS("unsigned long a ; a = 4 ;",
|
||||
std::stringstream expected;
|
||||
expected << "unsigned long a ; a = " << settings1.sizeof_int << " ;";
|
||||
ASSERT_EQUALS(expected.str(),
|
||||
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));
|
||||
|
|
Loading…
Reference in New Issue