diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp --- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -1078,6 +1078,11 @@ SymbolRef RootSym = cast(SE)->getOperand(); QualType RT = RootSym->getType().getCanonicalType(); + // FIXME support cast from non-integers. + // E.g (char)(double)(double x) -> (char)(double x) + if (!RT->isIntegralOrEnumerationType()) + return makeNonLoc(SE, T, CastTy); + BasicValueFactory &BVF = getBasicValueFactory(); APSIntType CTy = BVF.getAPSIntType(CastTy); APSIntType TTy = BVF.getAPSIntType(T); diff --git a/clang/test/Analysis/produce-symbolcast_x86.cpp b/clang/test/Analysis/produce-symbolcast_x86.cpp --- a/clang/test/Analysis/produce-symbolcast_x86.cpp +++ b/clang/test/Analysis/produce-symbolcast_x86.cpp @@ -11,6 +11,15 @@ template void clang_analyzer_dump(T); +void test_double(int n) { + double D = n / 30; + clang_analyzer_dump(D); // expected-warning{{(double) ((double) ((reg_$0) / 30))}} + char C = D; + clang_analyzer_dump(C); // expected-warning{{(char) ((double) ((double) ((reg_$0) / 30)))}} + int I = C; // assertion should not fail here! + clang_analyzer_dump(I); // expected-warning{{(int) ((char) ((double) ((double) ((reg_$0) / 30))))}} +} + void test_schar(schar x) { clang_analyzer_dump(x); // expected-warning{{reg_$0}}