File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -555,7 +555,7 @@ class CPPCHECKLIB Token {
555
555
setFlag (fIsAttributeMaybeUnused , value);
556
556
}
557
557
std::vector<std::string> getAttributeAlignas () const {
558
- return ! mImpl ->mAttributeAlignas ? std::vector<std::string>() : * mImpl -> mAttributeAlignas ;
558
+ return mImpl ->mAttributeAlignas ? * mImpl -> mAttributeAlignas : std::vector<std::string>();
559
559
}
560
560
bool hasAttributeAlignas () const {
561
561
return !!mImpl ->mAttributeAlignas ;
Original file line number Diff line number Diff line change @@ -6048,6 +6048,7 @@ void Tokenizer::dump(std::ostream &out) const
6048
6048
const std::vector<std::string>& a = tok->getAttributeAlignas();
6049
6049
outs += " alignas=\"" + ErrorLogger::toxml(a[0]) + "\"";
6050
6050
if (a.size() > 1)
6051
+ // we could write all alignas expressions but currently we only need 2
6051
6052
outs += " alignas2=\"" + ErrorLogger::toxml(a[1]) + "\"";
6052
6053
}
6053
6054
if (tok->link()) {
Original file line number Diff line number Diff line change @@ -439,6 +439,7 @@ class TestTokenizer : public TestFixture {
439
439
440
440
TEST_CASE (removeAlignas1);
441
441
TEST_CASE (removeAlignas2); // Do not remove alignof in the same way
442
+ TEST_CASE (dumpAlignas);
442
443
443
444
TEST_CASE (simplifyCoroutines);
444
445
@@ -7850,6 +7851,17 @@ class TestTokenizer : public TestFixture {
7850
7851
ASSERT_EQUALS (expected, tokenizeAndStringify (code));
7851
7852
}
7852
7853
7854
+ void dumpAlignas () {
7855
+ Settings settings;
7856
+ SimpleTokenizer tokenizer (settings, *this );
7857
+ tokenizer.tokenize (" int alignas(8) alignas(16) x;" , false );
7858
+ ASSERT (Token::simpleMatch (tokenizer.tokens (), " int x ;" ));
7859
+ std::ostringstream ostr;
7860
+ tokenizer.dump (ostr);
7861
+ const std::string dump = ostr.str ();
7862
+ ASSERT (dump.find (" alignas=\" 8\" alignas2=\" 16\" " ) != std::string::npos);
7863
+ }
7864
+
7853
7865
void simplifyCoroutines () {
7854
7866
const Settings settings = settingsBuilder ().cpp (Standards::CPP20).build ();
7855
7867
You can’t perform that action at this time.
0 commit comments