[all-commits] [llvm/llvm-project] 8cda12: [clang]Fix warning for signed conversion on LP64

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Tue Feb 21 09:44:13 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8cda128c1eff8556505ff27117a68ad8cecaa228
      https://github.com/llvm/llvm-project/commit/8cda128c1eff8556505ff27117a68ad8cecaa228
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2023-02-21 (Tue, 21 Feb 2023)

  Changed paths:
    M clang/lib/Sema/SemaChecking.cpp
    M clang/test/Sema/sign-conversion.c

  Log Message:
  -----------
  [clang]Fix warning for signed conversion on LP64

Currently clang emits warning with -Wconversion for the following code
on LP64 system e.g. x86_64-unknown-linux-gnu:

long foo(long x) {
  return 1LL<<x;
}
warning: implicit conversion changes signedness: 'long long' to 'long' [-Wsign-conversion]

return 1ll << x;
~~~~~~ ~~~~^~~~
This does not make sense since all operands are signed.

This patch fixes that to match -m32 and GCC behaviour.

Reviewed by: Fangrui Song

Differential Revision: https://reviews.llvm.org/D144011




More information about the All-commits mailing list