@@ -65,13 +65,15 @@ void test() {
65
65
void * other_ptr = null_val ;
66
66
67
67
// Can it be used in all the places a scalar can be used?
68
- if (null_val ) {}
69
- if (!null_val ) {}
70
- for (;null_val ;) {}
71
- while (nullptr ) {}
72
- null_val && nullptr ;
73
- nullptr || null_val ;
74
- null_val ? 0 : 1 ;
68
+ if (null_val ) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
69
+ if (!null_val ) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
70
+ for (;null_val ;) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
71
+ while (nullptr ) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
72
+ null_val && nullptr ; // expected-warning {{implicit conversion of nullptr constant to 'bool'}} \
73
+ expected-warning {{implicit conversion of nullptr constant to 'bool'}}
74
+ nullptr || null_val ; // expected-warning {{implicit conversion of nullptr constant to 'bool'}} \
75
+ expected-warning {{implicit conversion of nullptr constant to 'bool'}}
76
+ null_val ? 0 : 1 ; // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
75
77
sizeof (null_val );
76
78
alignas(nullptr_t ) int aligned ;
77
79
@@ -95,12 +97,12 @@ void test() {
95
97
// Can it be converted to bool with the result false (this relies on Clang
96
98
// accepting additional kinds of constant expressions where an ICE is
97
99
// required)?
98
- static_assert (!nullptr );
99
- static_assert (!null_val );
100
- static_assert (nullptr ); // expected-error {{static assertion failed due to requirement 'nullptr'}} \
101
- expected-warning {{implicit conversion of nullptr constant to 'bool'}}
102
- static_assert (null_val ); // expected-error {{static assertion failed due to requirement 'null_val'}} \
103
- expected-warning {{implicit conversion of nullptr constant to 'bool'}}
100
+ static_assert (!nullptr ); // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
101
+ static_assert (!null_val ); // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
102
+ static_assert (nullptr ); // expected-error {{static assertion failed due to requirement 'nullptr'}} \
103
+ expected-warning {{implicit conversion of nullptr constant to 'bool'}}
104
+ static_assert (null_val ); // expected-error {{static assertion failed due to requirement 'null_val'}} \
105
+ expected-warning {{implicit conversion of nullptr constant to 'bool'}}
104
106
105
107
// Do equality operators work as expected with it?
106
108
static_assert (nullptr == nullptr );
@@ -142,11 +144,11 @@ void test() {
142
144
_Generic(1 ? typed_ptr : nullptr , typeof (typed_ptr ) : 0 );
143
145
144
146
// Same for GNU conditional operators?
145
- _Generic(nullptr ?: nullptr , nullptr_t : 0 );
146
- _Generic(null_val ?: null_val , nullptr_t : 0 );
147
+ _Generic(nullptr ?: nullptr , nullptr_t : 0 ); // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
148
+ _Generic(null_val ?: null_val , nullptr_t : 0 ); // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
147
149
_Generic(typed_ptr ?: null_val , typeof (typed_ptr ) : 0 );
148
- _Generic(null_val ?: typed_ptr , typeof (typed_ptr ) : 0 );
149
- _Generic(nullptr ?: typed_ptr , typeof (typed_ptr ) : 0 );
150
+ _Generic(null_val ?: typed_ptr , typeof (typed_ptr ) : 0 ); // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
151
+ _Generic(nullptr ?: typed_ptr , typeof (typed_ptr ) : 0 ); // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
150
152
_Generic(typed_ptr ?: nullptr , typeof (typed_ptr ) : 0 );
151
153
152
154
// Do we correctly issue type incompatibility diagnostics?
0 commit comments