abs.fail.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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. #include <cmath>
  9. #include "test_macros.h"
  10. int main(int, char**)
  11. {
  12. unsigned int ui = -5;
  13. ui = std::abs(ui); // expected-error {{call to 'abs' is ambiguous}}
  14. unsigned char uc = -5;
  15. uc = std::abs(uc); // expected-error {{taking the absolute value of unsigned type 'unsigned char' has no effect}}
  16. unsigned short us = -5;
  17. us = std::abs(us); // expected-error {{taking the absolute value of unsigned type 'unsigned short' has no effect}}
  18. unsigned long ul = -5;
  19. ul = std::abs(ul); // expected-error {{call to 'abs' is ambiguous}}
  20. unsigned long long ull = -5;
  21. ull = ::abs(ull); // expected-error {{call to 'abs' is ambiguous}}
  22. return 0;
  23. }