1- // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify -std=c11 -Wno-unused-value -Wno-unused-but-set-variable -Wbitfield-width -Wbitfield-enum-conversion
1+ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=expected,preferrednotes -std=c11 -Wno-unused-value -Wno-unused-but-set-variable
2+ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=expected,bitfieldwarning,preferrednotes -std=c11 -Wno-unused-value -Wno-unused-but-set-variable -Wbitfield-width -Wbitfield-enum-conversion
3+ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=noerror,preferrednotes -std=c11 -Wno-unused-value -Wno-unused-but-set-variable -Wno-error=preferred-type-bitfield-enum-conversion -Wno-error=preferred-type-bitfield-width
24
35enum A {
46 A_a ,
@@ -40,21 +42,21 @@ void read_enum(struct S *s) {
4042
4143void write_enum (struct S * s , enum A x ) {
4244 s -> a1 = x ;
43- // expected -warning@-1 {{bit-field 'a1' is not wide enough to store all enumerators of 'A'}}
44- // expected -note@#S_a1_decl {{widen this field to 2 bits to store all values of 'A'}}
45+ // bitfieldwarning -warning@-1 {{bit-field 'a1' is not wide enough to store all enumerators of 'A'}}
46+ // bitfieldwarning -note@#S_a1_decl {{widen this field to 2 bits to store all values of 'A'}}
4547 s -> a2 = x ;
4648 s -> a3 = x ;
4749 s -> a4 = x ;
48- // expected -warning@-1 {{bit-field 'a4' is not wide enough to store all enumerators of 'A'}}
49- // expected -note@#S_a4_decl {{widen this field to 2 bits to store all values of 'A'}}
50+ // bitfieldwarning -warning@-1 {{bit-field 'a4' is not wide enough to store all enumerators of 'A'}}
51+ // bitfieldwarning -note@#S_a4_decl {{widen this field to 2 bits to store all values of 'A'}}
5052 s -> a5 = x ;
5153 s -> a6 = x ;
5254 s -> a7 = x ;
53- // expected -warning@-1 {{bit-field 'a7' is not wide enough to store all enumerators of 'A'}}
54- // expected -note@#S_a7_decl {{widen this field to 2 bits to store all values of 'A'}}
55+ // bitfieldwarning -warning@-1 {{bit-field 'a7' is not wide enough to store all enumerators of 'A'}}
56+ // bitfieldwarning -note@#S_a7_decl {{widen this field to 2 bits to store all values of 'A'}}
5557 s -> a8 = x ;
56- // expected -warning@-1 {{signed bit-field 'a8' needs an extra bit to represent the largest positive enumerators of 'A'}}
57- // expected -note@#S_a8_decl {{consider making the bitfield type unsigned}}
58+ // bitfieldwarning -warning@-1 {{signed bit-field 'a8' needs an extra bit to represent the largest positive enumerators of 'A'}}
59+ // bitfieldwarning -note@#S_a8_decl {{consider making the bit-field type unsigned}}
5860 s -> a9 = x ;
5961}
6062
@@ -63,19 +65,22 @@ void write_enum_int(struct S *s, int x) {
6365 s -> a2 = x ;
6466 s -> a3 = x ;
6567 s -> a4 = x ;
66- // expected-warning@-1 {{bit-field 'a4' is not wide enough to store all enumerators of preferred type 'A'}}
67- // expected-note@#S_a4_decl {{widen this field to 2 bits to store all values of 'A'}}
68- // expected-note@#preferred_S_a4 {{preferred type for bitfield 'A' specified here}}
68+ // expected-error@-1 {{bit-field 'a4' is not wide enough to store all enumerators of preferred type 'A'}}
69+ // noerror-warning@-2 {{bit-field 'a4' is not wide enough to store all enumerators of preferred type 'A'}}
70+ // preferrednotes-note@#S_a4_decl {{widen this field to 2 bits to store all values of 'A'}}
71+ // preferrednotes-note@#preferred_S_a4 {{preferred type for bit-field 'A' specified here}}
6972 s -> a5 = x ;
7073 s -> a6 = x ;
7174 s -> a7 = x ;
72- // expected-warning@-1 {{bit-field 'a7' is not wide enough to store all enumerators of preferred type 'A'}}
73- // expected-note@#S_a7_decl {{widen this field to 2 bits to store all values of 'A'}}
74- // expected-note@#preferred_S_a7 {{preferred type for bitfield 'A' specified here}}
75+ // expected-error@-1 {{bit-field 'a7' is not wide enough to store all enumerators of preferred type 'A'}}
76+ // noerror-warning@-2 {{bit-field 'a7' is not wide enough to store all enumerators of preferred type 'A'}}
77+ // preferrednotes-note@#S_a7_decl {{widen this field to 2 bits to store all values of 'A'}}
78+ // preferrednotes-note@#preferred_S_a7 {{preferred type for bit-field 'A' specified here}}
7579 s -> a8 = x ;
76- // expected-warning@-1 {{signed bit-field 'a8' needs an extra bit to represent the largest positive enumerators of preferred type 'A'}}
77- // expected-note@#S_a8_decl {{consider making the bitfield type unsigned}}
78- // expected-note@#preferred_S_a8 {{preferred type for bitfield 'A' specified here}}
80+ // expected-error@-1 {{signed bit-field 'a8' needs an extra bit to represent the largest positive enumerators of preferred type 'A'}}
81+ // noerror-warning@-2 {{signed bit-field 'a8' needs an extra bit to represent the largest positive enumerators of preferred type 'A'}}
82+ // preferrednotes-note@#S_a8_decl {{consider making the bit-field type unsigned}}
83+ // preferrednotes-note@#preferred_S_a8 {{preferred type for bit-field 'A' specified here}}
7984 s -> a9 = x ;
8085}
8186
@@ -93,16 +98,16 @@ void write_low_constant(struct S *s) {
9398
9499void write_high_constant (struct S * s ) {
95100 s -> a1 = A_d ;
96- // expected -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to 1}}
101+ // preferrednotes -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to 1}}
97102 s -> a2 = A_d ;
98103 s -> a3 = A_d ;
99104 s -> a4 = A_d ;
100- // expected -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to 1}}
105+ // preferrednotes -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to 1}}
101106 s -> a5 = A_d ;
102107 s -> a6 = A_d ;
103108 s -> a7 = A_d ;
104- // expected -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to -1}}
109+ // preferrednotes -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to -1}}
105110 s -> a8 = A_d ;
106- // expected -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to -1}}
111+ // preferrednotes -warning@-1 {{implicit truncation from 'int' to bit-field changes value from 3 to -1}}
107112 s -> a9 = A_d ;
108113};
0 commit comments