Zoe Carver | 6585f01 | 2019-08-20 15:43:25 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include <cmath> |
| 10 | |
| 11 | #include "test_macros.h" |
| 12 | |
| 13 | int main(int, char**) |
| 14 | { |
| 15 | unsigned int ui = -5; |
| 16 | ui = std::abs(ui); // expected-error {{call to 'abs' is ambiguous}} |
| 17 | |
| 18 | unsigned char uc = -5; |
Louis Dionne | a5fa5f7 | 2020-03-17 12:27:10 -0400 | [diff] [blame] | 19 | uc = std::abs(uc); // expected-warning {{taking the absolute value of unsigned type 'unsigned char' has no effect}} |
Zoe Carver | 6585f01 | 2019-08-20 15:43:25 +0000 | [diff] [blame] | 20 | |
| 21 | unsigned short us = -5; |
Louis Dionne | a5fa5f7 | 2020-03-17 12:27:10 -0400 | [diff] [blame] | 22 | us = std::abs(us); // expected-warning {{taking the absolute value of unsigned type 'unsigned short' has no effect}} |
Zoe Carver | 6585f01 | 2019-08-20 15:43:25 +0000 | [diff] [blame] | 23 | |
| 24 | unsigned long ul = -5; |
| 25 | ul = std::abs(ul); // expected-error {{call to 'abs' is ambiguous}} |
| 26 | |
| 27 | unsigned long long ull = -5; |
| 28 | ull = ::abs(ull); // expected-error {{call to 'abs' is ambiguous}} |
| 29 | |
| 30 | return 0; |
| 31 | } |