MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / functionAttributeBefore1

Method functionAttributeBefore1

test/testtokenize.cpp:4075–4104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4073 }
4074
4075 void functionAttributeBefore1() {
4076 const char code[] = "void __attribute__((pure)) __attribute__((nothrow)) __attribute__((const)) func1();\n"
4077 "void __attribute__((__pure__)) __attribute__((__nothrow__)) __attribute__((__const__)) func2();\n"
4078 "void __attribute__((nothrow)) __attribute__((pure)) __attribute__((const)) func3();\n"
4079 "void __attribute__((__nothrow__)) __attribute__((__pure__)) __attribute__((__const__)) func4();\n"
4080 "void __attribute__((noreturn)) func5();\n"
4081 "void __attribute__((__visibility__(\"default\"))) func6();";
4082 const char expected[] = "void func1 ( ) ; void func2 ( ) ; void func3 ( ) ; void func4 ( ) ; void func5 ( ) ; void func6 ( ) ;";
4083
4084 // tokenize..
4085 SimpleTokenizer tokenizer(settingsDefault, *this);
4086 ASSERT(tokenizer.tokenize(code));
4087
4088 // Expected result..
4089 ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false));
4090
4091 const Token * func1 = Token::findsimplematch(tokenizer.tokens(), "func1");
4092 const Token * func2 = Token::findsimplematch(tokenizer.tokens(), "func2");
4093 const Token * func3 = Token::findsimplematch(tokenizer.tokens(), "func3");
4094 const Token * func4 = Token::findsimplematch(tokenizer.tokens(), "func4");
4095 const Token * func5 = Token::findsimplematch(tokenizer.tokens(), "func5");
4096 const Token * func6 = Token::findsimplematch(tokenizer.tokens(), "func6");
4097
4098 ASSERT(func1 && func1->isAttributePure() && func1->isAttributeNothrow() && func1->isAttributeConst() && !func1->isAttributeExport());
4099 ASSERT(func2 && func2->isAttributePure() && func2->isAttributeNothrow() && func2->isAttributeConst() && !func2->isAttributeExport());
4100 ASSERT(func3 && func3->isAttributePure() && func3->isAttributeNothrow() && func3->isAttributeConst() && !func3->isAttributeExport());
4101 ASSERT(func4 && func4->isAttributePure() && func4->isAttributeNothrow() && func4->isAttributeConst() && !func4->isAttributeExport());
4102 ASSERT(func5 && func5->isAttributeNoreturn());
4103 ASSERT(func6 && func6->isAttributeExport());
4104 }
4105
4106 void functionAttributeBefore2() {
4107 const char code[] = "extern vas_f *VAS_Fail __attribute__((__noreturn__));";

Callers

nothing calls this directly

Calls 3

findsimplematchFunction · 0.85
tokenizeMethod · 0.80
stringifyListMethod · 0.80

Tested by

no test coverage detected