xref: /minix3/external/bsd/llvm/dist/clang/test/FixIt/fixit-uninit.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
3*f4a2713aSLionel Sambuc 
test_bool_no_false()4*f4a2713aSLionel Sambuc _Bool test_bool_no_false() {
5*f4a2713aSLionel Sambuc   _Bool var; // expected-note {{initialize}}
6*f4a2713aSLionel Sambuc   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:12-[[@LINE-1]]:12}:" = 0"
7*f4a2713aSLionel Sambuc   return var; // expected-warning {{uninitialized}}
8*f4a2713aSLionel Sambuc }
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc #define bool _Bool
11*f4a2713aSLionel Sambuc #define false (bool)0
12*f4a2713aSLionel Sambuc #define true (bool)1
test_bool_with_false()13*f4a2713aSLionel Sambuc bool test_bool_with_false() {
14*f4a2713aSLionel Sambuc   bool var; // expected-note {{initialize}}
15*f4a2713aSLionel Sambuc   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:11}:" = false"
16*f4a2713aSLionel Sambuc   return var; // expected-warning {{uninitialized}}
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
test_bool_with_false_undefined()19*f4a2713aSLionel Sambuc bool test_bool_with_false_undefined() {
20*f4a2713aSLionel Sambuc   bool
21*f4a2713aSLionel Sambuc #undef false
22*f4a2713aSLionel Sambuc       var; // expected-note {{initialize}}
23*f4a2713aSLionel Sambuc   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:10}:" = 0"
24*f4a2713aSLionel Sambuc   return var; // expected-warning {{uninitialized}}
25*f4a2713aSLionel Sambuc }
26