xref: /llvm-project/libcxx/test/std/numerics/c.math/abs.verify.cpp (revision 1b4c0cb3918a9f2d12f8259407fc8bce053e78bf)
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 
f()11 void f() {
12     unsigned int ui = -5;
13     (void)std::abs(ui); // expected-error {{call to 'abs' is ambiguous}}
14 
15     unsigned char uc = -5;
16     (void)std::abs(uc); // expected-warning {{taking the absolute value of unsigned type 'unsigned char' has no effect}}
17 
18     unsigned short us = -5;
19     (void)std::abs(us); // expected-warning {{taking the absolute value of unsigned type 'unsigned short' has no effect}}
20 
21     unsigned long ul = -5;
22     (void)std::abs(ul); // expected-error {{call to 'abs' is ambiguous}}
23 
24     unsigned long long ull = -5;
25     (void)std::abs(ull); // expected-error {{call to 'abs' is ambiguous}}
26 }
27