1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li
3*67e74705SXin Li #if __has_feature(__builtin_add_overflow)
4*67e74705SXin Li #warning defined as expected
5*67e74705SXin Li // expected-warning@-1 {{defined as expected}}
6*67e74705SXin Li #endif
7*67e74705SXin Li
test(void)8*67e74705SXin Li void test(void) {
9*67e74705SXin Li unsigned r;
10*67e74705SXin Li const char * c;
11*67e74705SXin Li float f;
12*67e74705SXin Li const unsigned q;
13*67e74705SXin Li
14*67e74705SXin Li __builtin_add_overflow(); // expected-error {{too few arguments to function call, expected 3, have 0}}
15*67e74705SXin Li __builtin_add_overflow(1, 1, 1, 1); // expected-error {{too many arguments to function call, expected 3, have 4}}
16*67e74705SXin Li
17*67e74705SXin Li __builtin_add_overflow(c, 1, &r); // expected-error {{operand argument to overflow builtin must be an integer ('const char *' invalid)}}
18*67e74705SXin Li __builtin_add_overflow(1, c, &r); // expected-error {{operand argument to overflow builtin must be an integer ('const char *' invalid)}}
19*67e74705SXin Li __builtin_add_overflow(1, 1, 3); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('int' invalid)}}
20*67e74705SXin Li __builtin_add_overflow(1, 1, &f); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('float *' invalid)}}
21*67e74705SXin Li __builtin_add_overflow(1, 1, &q); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}}
22*67e74705SXin Li }
23