xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/div-zero.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core.DivideZero -verify %s
2*f4a2713aSLionel Sambuc 
fooPR10616(int qX)3*f4a2713aSLionel Sambuc int fooPR10616 (int qX ) {
4*f4a2713aSLionel Sambuc   int a, c, d;
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc   d = (qX-1);
7*f4a2713aSLionel Sambuc   while ( d != 0 ) {
8*f4a2713aSLionel Sambuc     d = c - (c/d) * d;
9*f4a2713aSLionel Sambuc   }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc   return (a % (qX-1)); // expected-warning {{Division by zero}}
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc }
14