* Add tests/TODO for #7950, #9974 * Comment
This commit is contained in:
parent
65c0ef8eb0
commit
ddd84f9b98
|
@ -4627,6 +4627,13 @@ private:
|
|||
" char *p = arr + 20;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic 'arr+20' is out of bounds.\n", errout.str());
|
||||
|
||||
check("char(*g())[1];\n" // #7950
|
||||
"void f() {\n"
|
||||
" int a[2];\n"
|
||||
" int* b = a + sizeof(*g());\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
#define ctu(code) ctu_(code, __FILE__, __LINE__)
|
||||
|
|
|
@ -231,6 +231,7 @@ private:
|
|||
TEST_CASE(doubleMove1);
|
||||
TEST_CASE(doubleMoveMemberInitialization1);
|
||||
TEST_CASE(doubleMoveMemberInitialization2);
|
||||
TEST_CASE(doubleMoveMemberInitialization3); // #9974
|
||||
TEST_CASE(moveAndAssign1);
|
||||
TEST_CASE(moveAndAssign2);
|
||||
TEST_CASE(moveAssignMoveAssign);
|
||||
|
@ -9069,6 +9070,17 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:5]: (warning) Access of moved variable 'b'.\n", errout.str());
|
||||
}
|
||||
|
||||
void doubleMoveMemberInitialization3() { // #9974
|
||||
check("struct A { int i; };\n"
|
||||
"struct B { A a1; A a2; };\n"
|
||||
"B f() {\n"
|
||||
" A a1 = { 1 };\n"
|
||||
" A a2 = { 2 };\n"
|
||||
" return { .a1 = std::move(a1), .a2 = std::move(a2) };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void moveAndAssign1() {
|
||||
check("A g(A a);\n"
|
||||
"void f() {\n"
|
||||
|
|
|
@ -2458,6 +2458,10 @@ private:
|
|||
"sizeof(char[20][3]);\n"
|
||||
"sizeof(char[unknown][3]);";
|
||||
ASSERT_EQUALS("20 ; 60 ; sizeof ( char [ unknown ] [ 3 ] ) ;", tok(code));
|
||||
|
||||
code = "char(*Helper())[1];\n"
|
||||
"sizeof(*Helper());\n";
|
||||
TODO_ASSERT_EQUALS("char ( * Helper ( ) ) [ 1 ] ; 1 ;", "char ( * Helper ( ) ) [ 1 ] ; sizeof ( * Helper ( ) ) ;", tok(code));
|
||||
}
|
||||
|
||||
void sizeof5() {
|
||||
|
|
Loading…
Reference in New Issue