Parser; do not remove alignof and alignas in the same way
This commit is contained in:
parent
b18e6f1e10
commit
b798b99777
|
@ -11006,10 +11006,8 @@ void Tokenizer::removeAlignas()
|
|||
return;
|
||||
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "alignas|alignof (")) {
|
||||
Token::eraseTokens(tok, tok->linkAt(1)->next());
|
||||
tok->deleteThis();
|
||||
}
|
||||
if (Token::Match(tok, "[;{}] alignas (") && Token::Match(tok->linkAt(2), ") %name%"))
|
||||
Token::eraseTokens(tok, tok->linkAt(2)->next());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -416,7 +416,8 @@ private:
|
|||
|
||||
TEST_CASE(removeExtraTemplateKeywords);
|
||||
|
||||
TEST_CASE(removeAlignas);
|
||||
TEST_CASE(removeAlignas1);
|
||||
TEST_CASE(removeAlignas2); // Do not remove alignof in the same way
|
||||
|
||||
TEST_CASE(simplifyCoroutines);
|
||||
|
||||
|
@ -6524,12 +6525,18 @@ private:
|
|||
ASSERT_EQUALS(expected2, tokenizeAndStringify(code2));
|
||||
}
|
||||
|
||||
void removeAlignas() {
|
||||
void removeAlignas1() {
|
||||
const char code[] = "alignas(float) unsigned char c[sizeof(float)];";
|
||||
const char expected[] = "unsigned char c [ sizeof ( float ) ] ;";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void removeAlignas2() { // Do not remove alignas and alignof in the same way
|
||||
const char code[] = "static_assert( alignof( VertexC ) == 4 );";
|
||||
const char expected[] = "static_assert ( alignof ( VertexC ) == 4 ) ;";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyCoroutines() {
|
||||
Settings settings;
|
||||
settings.standards.cpp = Standards::CPP20;
|
||||
|
|
Loading…
Reference in New Issue