File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero -std=c++20 -verify %s
2+
3+ namespace GH148875 {
4+ struct A {
5+ int x;
6+ A (int v) : x(v) {}
7+ };
8+
9+ struct B {
10+ int x;
11+ B () : x(0 ) {}
12+ };
13+
14+ struct C {
15+ int x, y;
16+ C (int a, int b) : x(a), y(b) {}
17+ };
18+
19+ struct D {
20+ int x;
21+ };
22+
23+ struct E {
24+ D d;
25+ E (int a) : d(a) {}
26+ };
27+
28+ int t1 () {
29+ A a (42 );
30+ return 1 / (a.x - 42 ); // expected-warning {{Division by zero}}
31+ }
32+
33+ int t2 () {
34+ B b;
35+ return 1 / b.x ; // expected-warning {{Division by zero}}
36+ }
37+
38+ int t3 () {
39+ C c1 (1 , -1 );
40+ return 1 / (c1.x + c1.y ); // expected-warning {{Division by zero}}
41+ }
42+
43+ int t4 () {
44+ C c2 (0 , 0 );
45+ return 1 / (c2.x + c2.y ); // expected-warning {{Division by zero}}
46+ }
47+
48+ int t5 () {
49+ E e = 32 ;
50+ return 1 / (e.d .x - 32 ); // expected-warning {{Division by zero}}
51+ }
52+ } // namespace GH148875
You can’t perform that action at this time.
0 commit comments