diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index c5c01dd66..6474046f4 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2274,7 +2274,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | (RecordDecl _) :: _ -> (* Case for struct *) collect_all_decl trans_state decl_list succ_nodes stmt_info - | (TypedefDecl _) :: _ | (UsingDirectiveDecl _) :: _ -> + | (TypedefDecl _ | UsingDecl _ | UsingDirectiveDecl _) :: _ -> empty_res_trans | decl :: _ -> CFrontend_config.unimplemented "In DeclStmt found an unknown declaration type %s" diff --git a/infer/tests/codetoanalyze/cpp/errors/issues.exp b/infer/tests/codetoanalyze/cpp/errors/issues.exp index 9f1a3dd53..7f4f1b5b4 100644 --- a/infer/tests/codetoanalyze/cpp/errors/issues.exp +++ b/infer/tests/codetoanalyze/cpp/errors/issues.exp @@ -289,6 +289,7 @@ codetoanalyze/cpp/shared/methods/virtual_methods.cpp, tri_area, 5, DIVIDE_BY_ZER codetoanalyze/cpp/shared/methods/virtual_methods.cpp, tri_not_virtual_area, 5, DIVIDE_BY_ZERO, [start of procedure tri_not_virtual_area(),start of procedure Triangle,start of procedure Polygon,return from a call to Polygon_Polygon,return from a call to Triangle_Triangle,start of procedure Polygon,return from a call to Polygon_Polygon,start of procedure set_values,return from a call to Polygon_set_values,start of procedure area,return from a call to Polygon_area] codetoanalyze/cpp/shared/namespace/function.cpp, div0_namespace_resolution, 0, DIVIDE_BY_ZERO, [start of procedure div0_namespace_resolution(),start of procedure f1::get(),return from a call to f1::get,start of procedure f2::get(),return from a call to f2::get] codetoanalyze/cpp/shared/namespace/function.cpp, div0_using, 2, DIVIDE_BY_ZERO, [start of procedure div0_using(),start of procedure f1::get0(),return from a call to f1::get0] +codetoanalyze/cpp/shared/namespace/function.cpp, using_div0, 2, DIVIDE_BY_ZERO, [start of procedure using_div0(),start of procedure ret_zero,return from a call to f3::C_ret_zero] codetoanalyze/cpp/shared/namespace/global_variable.cpp, div0_namepace_res, 3, DIVIDE_BY_ZERO, [start of procedure div0_namepace_res()] codetoanalyze/cpp/shared/namespace/global_variable.cpp, div0_static_field, 3, DIVIDE_BY_ZERO, [start of procedure div0_static_field()] codetoanalyze/cpp/shared/namespace/global_variable.cpp, div0_static_field_member_access, 3, DIVIDE_BY_ZERO, [start of procedure div0_static_field_member_access()] diff --git a/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp b/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp index 7f7ff9928..0ede84e73 100644 --- a/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp +++ b/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp @@ -22,3 +22,15 @@ int div0_using() { } int div0_namespace_resolution() { return 1 / (f1::get() + f2::get()); } + +namespace f3 { +class C { + public: + static int ret_zero() { return 0; } +}; +} // namespace f3 + +int using_div0() { + using f3::C; + return 1 / C::ret_zero(); +} diff --git a/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp.dot index fa0a4e1c4..66f5b5b4d 100644 --- a/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/namespace/function.cpp.dot @@ -55,4 +55,26 @@ digraph iCFG { "div0_namespace_resolution#14165120127941064123.2433829c6d52c7e69a43e89e30e4c7fc_3" -> "div0_namespace_resolution#14165120127941064123.2433829c6d52c7e69a43e89e30e4c7fc_2" ; +"using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_1" [label="1: Start using_div0\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 33, column 1]\n " color=yellow style=filled] + + + "using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_1" -> "using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_3" ; +"using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_2" [label="2: Exit using_div0 \n " color=yellow style=filled] + + +"using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_3" [label="3: Return Stmt \n n$0=_fun_f3::C_ret_zero() [line 35, column 14]\n *&return:int=(1 / n$0) [line 35, column 3]\n " shape="box"] + + + "using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_3" -> "using_div0#15267107907897398237.0f32134dc9668df527885e12e16348fe_2" ; +"ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_1" [label="1: Start f3::C_ret_zero\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 29, column 3]\n " color=yellow style=filled] + + + "ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_1" -> "ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_3" ; +"ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_2" [label="2: Exit f3::C_ret_zero \n " color=yellow style=filled] + + +"ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_3" [label="3: Return Stmt \n *&return:int=0 [line 29, column 27]\n " shape="box"] + + + "ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_3" -> "ret_zero#C#f3#(14815103288805165028).4dbfdc84a3e84f15300709ed03f3f5c1_2" ; }