25 lines · cpp
1// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \2// RUN: -analyzer-config support-symbolic-integer-casts=false \3// RUN: -verify %s4 5// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \6// RUN: -analyzer-config support-symbolic-integer-casts=true \7// RUN: -verify %s8 9template <typename T>10void clang_analyzer_dump(T);11 12void test_no_redundant_floating_point_cast(int n) {13 14 double D = n / 30;15 clang_analyzer_dump(D); // expected-warning{{(double) ((reg_$0<int n>) / 30)}}16 17 // There are two cast operations evaluated above:18 // 1. (n / 30) is cast to a double during the store of `D`.19 // 2. Then in the next line, in RegionStore::getBinding during the load of `D`.20 //21 // We should not see in the dump of the SVal any redundant casts like22 // (double) ((double) $n / 30)23 24}25