ASSERT_THROW(checkCode("void f() { if MACRO(); }"), InternalError);
// #4668 - note there is no semicolon after MACRO()
ASSERT_THROW(checkCode("void f() { if (x) MACRO() {} }"), InternalError);
// #4810 - note there is no semicolon after MACRO()
ASSERT_THROW(checkCode("void f() { if (x) MACRO() else ; }"), InternalError);
}
voidwrong_syntax_class_x_y() {
// #3585
constchar code[] = "class x y { };";
{
errout.str("");
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.c");
tokenizer.simplifyTokenList2();
ASSERT_EQUALS("", errout.str());
}
{
errout.str("");
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList2();
ASSERT_EQUALS("[test.cpp:1]: (information) The code 'class x y {' is not handled. You can use -I or --include to add handling of this code.\n", errout.str());
checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"); // do not crash
checkCode("{ { void foo() { struct }; template <typename> struct S { Used x; void bar() } auto f = [this] { }; } };");
}
voidgarbageCode120() { // #4927
checkCode("int main() {\n"
" return 0\n"
"}");
ASSERT_EQUALS("", errout.str());
}
voidgarbageCode121() { // #2585
ASSERT_THROW(checkCode("abcdef?""?<"
"123456?""?>"
"+?""?="), InternalError);
}
voidgarbageCode122() { // #6303
checkCode("void foo() {\n"
"char *a = malloc(10);\n"
"a[0]\n"
"}");
}
voidgarbageCode123() {
ASSERT_THROW(checkCode("namespace pr16989 {\n"
" class C {\n"
" C tpl_mem(T *) { return }\n"
" };\n"
"}"), InternalError);
}
voidgarbageCode124() {
checkCode("+---+");
}
voidgarbageCode125() {
ASSERT_THROW(checkCode("{ T struct B : T valueA_AA ; } T : [ T > ( ) { B } template < T > struct A < > : ] { ( ) { return valueA_AC struct { : } } b A < int > AC ( ) a_aa.M ; ( ) ( ) }"),
InternalError);
ASSERT_THROW(checkCode("template < Types > struct S :{ ( S < ) S >} { ( ) { } } ( ) { return S < void > ( ) }"),
InternalError);
}
voidgarbageCode126() {
ASSERT_THROW(checkCode("{ } float __ieee754_sinhf ( float x ) { float t , , do { gf_u ( jx ) { } ( 0 ) return ; ( ) { } t } ( 0x42b17180 ) { } }"),