parent
6c54e7363d
commit
67f4fe575f
|
@ -10978,7 +10978,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
syntaxError(tok);
|
syntaxError(tok);
|
||||||
|
|
||||||
Token *functok = nullptr;
|
Token *functok = nullptr;
|
||||||
if (Token::Match(after, "%name%|*")) {
|
if (Token::Match(after, "%name%|*|(")) {
|
||||||
Token *ftok = after;
|
Token *ftok = after;
|
||||||
while (Token::Match(ftok, "%name%|::|<|* !!(")) {
|
while (Token::Match(ftok, "%name%|::|<|* !!(")) {
|
||||||
if (ftok->str() == "<") {
|
if (ftok->str() == "<") {
|
||||||
|
@ -10988,7 +10988,9 @@ void Tokenizer::simplifyAttribute()
|
||||||
}
|
}
|
||||||
ftok = ftok->next();
|
ftok = ftok->next();
|
||||||
}
|
}
|
||||||
if (Token::Match(ftok, "%name% ("))
|
if (Token::simpleMatch(ftok, "( *"))
|
||||||
|
ftok = ftok->tokAt(2);
|
||||||
|
if (Token::Match(ftok, "%name% (|)"))
|
||||||
functok = ftok;
|
functok = ftok;
|
||||||
} else if (Token::Match(after, "[;{=:]")) {
|
} else if (Token::Match(after, "[;{=:]")) {
|
||||||
Token *prev = tok->previous();
|
Token *prev = tok->previous();
|
||||||
|
|
|
@ -263,6 +263,7 @@ private:
|
||||||
TEST_CASE(removeattribute);
|
TEST_CASE(removeattribute);
|
||||||
TEST_CASE(functionAttributeBefore1);
|
TEST_CASE(functionAttributeBefore1);
|
||||||
TEST_CASE(functionAttributeBefore2);
|
TEST_CASE(functionAttributeBefore2);
|
||||||
|
TEST_CASE(functionAttributeBefore3);
|
||||||
TEST_CASE(functionAttributeAfter);
|
TEST_CASE(functionAttributeAfter);
|
||||||
TEST_CASE(functionAttributeListBefore);
|
TEST_CASE(functionAttributeListBefore);
|
||||||
TEST_CASE(functionAttributeListAfter);
|
TEST_CASE(functionAttributeListAfter);
|
||||||
|
@ -3653,6 +3654,22 @@ private:
|
||||||
ASSERT(VAS_Fail && VAS_Fail->isAttributeNoreturn());
|
ASSERT(VAS_Fail && VAS_Fail->isAttributeNoreturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void functionAttributeBefore3() { // #10978
|
||||||
|
const char code[] = "void __attribute__((__noreturn__)) (*func_notret)(void);";
|
||||||
|
const char expected[] = "void ( * func_notret ) ( ) ;";
|
||||||
|
|
||||||
|
errout.str("");
|
||||||
|
|
||||||
|
// tokenize..
|
||||||
|
Tokenizer tokenizer(&settings0, this);
|
||||||
|
std::istringstream istr(code);
|
||||||
|
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
|
||||||
|
ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false));
|
||||||
|
|
||||||
|
const Token* func_notret = Token::findsimplematch(tokenizer.tokens(), "func_notret");
|
||||||
|
ASSERT(func_notret && func_notret->isAttributeNoreturn());
|
||||||
|
}
|
||||||
|
|
||||||
void functionAttributeAfter() {
|
void functionAttributeAfter() {
|
||||||
const char code[] = "void func1() __attribute__((pure)) __attribute__((nothrow)) __attribute__((const));\n"
|
const char code[] = "void func1() __attribute__((pure)) __attribute__((nothrow)) __attribute__((const));\n"
|
||||||
"void func2() __attribute__((__pure__)) __attribute__((__nothrow__)) __attribute__((__const__));\n"
|
"void func2() __attribute__((__pure__)) __attribute__((__nothrow__)) __attribute__((__const__));\n"
|
||||||
|
|
Loading…
Reference in New Issue