This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. yaxunl marked an inline comment as done. Closed by commit rG8cda128c1eff: [clang]Fix warning for signed conversion on LP64 (authored by yaxunl). Herald added a project: clang.
Changed prior to commit: https://reviews.llvm.org/D144011?vs=497703&id=499215#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144011/new/ https://reviews.llvm.org/D144011 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/sign-conversion.c Index: clang/test/Sema/sign-conversion.c =================================================================== --- clang/test/Sema/sign-conversion.c +++ clang/test/Sema/sign-conversion.c @@ -1,8 +1,14 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify -Wsign-conversion %s +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsyntax-only -verify -Wsign-conversion %s // PR9345: make a subgroup of -Wconversion for signedness changes void test(int x) { unsigned t0 = x; // expected-warning {{implicit conversion changes signedness}} unsigned t1 = (t0 == 5 ? x : 0); // expected-warning {{operand of ? changes signedness}} + + // Clang has special treatment for left shift of literal '1'. + // Make sure there is no diagnostics. + long t2 = 1LL << x; } Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -14316,6 +14316,12 @@ if (S.SourceMgr.isInSystemMacro(CC)) return; + if (SourceBT && SourceBT->isInteger() && TargetBT && + TargetBT->isInteger() && + Source->isSignedIntegerType() == Target->isSignedIntegerType()) { + return; + } + unsigned DiagID = diag::warn_impcast_integer_sign; // Traditionally, gcc has warned about this under -Wsign-compare.
Index: clang/test/Sema/sign-conversion.c =================================================================== --- clang/test/Sema/sign-conversion.c +++ clang/test/Sema/sign-conversion.c @@ -1,8 +1,14 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify -Wsign-conversion %s +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsyntax-only -verify -Wsign-conversion %s // PR9345: make a subgroup of -Wconversion for signedness changes void test(int x) { unsigned t0 = x; // expected-warning {{implicit conversion changes signedness}} unsigned t1 = (t0 == 5 ? x : 0); // expected-warning {{operand of ? changes signedness}} + + // Clang has special treatment for left shift of literal '1'. + // Make sure there is no diagnostics. + long t2 = 1LL << x; } Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -14316,6 +14316,12 @@ if (S.SourceMgr.isInSystemMacro(CC)) return; + if (SourceBT && SourceBT->isInteger() && TargetBT && + TargetBT->isInteger() && + Source->isSignedIntegerType() == Target->isSignedIntegerType()) { + return; + } + unsigned DiagID = diag::warn_impcast_integer_sign; // Traditionally, gcc has warned about this under -Wsign-compare.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits