This commit is contained in:
chrchr-github 2023-01-18 17:30:22 +01:00 committed by GitHub
parent 0b62c73ff0
commit 7515305581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -1724,7 +1724,7 @@ private:
errout.str()); errout.str());
} }
void array_index_59() void array_index_59() // #10413
{ {
check("long f(long b) {\n" check("long f(long b) {\n"
" const long a[] = { 0, 1, };\n" " const long a[] = { 0, 1, };\n"
@ -1734,6 +1734,22 @@ private:
" return a[b];\n" " return a[b];\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f(int a, int b) {\n"
" const int S[2] = {};\n"
" if (a < 0) {}\n"
" else {\n"
" if (b < 0) {}\n"
" else if (S[b] > S[a]) {}\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("int a[2] = {};\n"
"void f(int i) {\n"
" g(i < 0 ? 0 : a[i]);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void array_index_60() void array_index_60()

View File

@ -2790,7 +2790,7 @@ private:
"struct D : public B { int f() override; };\n" "struct D : public B { int f() override; };\n"
"int g(B* p) {\n" "int g(B* p) {\n"
" if (p) {\n" " if (p) {\n"
" auto d = dynamic_cast<B*>(p);\n" " auto d = dynamic_cast<D*>(p);\n"
" return d ? d->f() : 0;\n" " return d ? d->f() : 0;\n"
" }\n" " }\n"
" return 0;\n" " return 0;\n"