[llvm-branch-commits] [cfe-branch] r324602 - Merging r324514:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 8 05:19:38 PST 2018
Author: hans
Date: Thu Feb 8 05:19:38 2018
New Revision: 324602
URL: http://llvm.org/viewvc/llvm-project?rev=324602&view=rev
Log:
Merging r324514:
------------------------------------------------------------------------
r324514 | arphaman | 2018-02-07 21:45:39 +0100 (Wed, 07 Feb 2018) | 10 lines
[PR36008] Avoid -Wsign-compare warning for enum constants in
typeof expressions
This commit looks through typeof type at the original expression when diagnosing
-Wsign-compare to avoid an unfriendly diagnostic.
rdar://36588828
Differential Revision: https://reviews.llvm.org/D42561
------------------------------------------------------------------------
Modified:
cfe/branches/release_60/ (props changed)
cfe/branches/release_60/lib/Sema/SemaChecking.cpp
cfe/branches/release_60/test/Sema/compare.c
Propchange: cfe/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 8 05:19:38 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:321754,321771,321777,321779,321933,322018,322236,322245-322246,322350,322390,322405,322420,322518,322593,322813,322901,322904,322984,323008,323123,323155,323360,323485,323904,323935,324059,324134,324246,324419,324439
+/cfe/trunk:321754,321771,321777,321779,321933,322018,322236,322245-322246,322350,322390,322405,322420,322518,322593,322813,322901,322904,322984,323008,323123,323155,323360,323485,323904,323935,324059,324134,324246,324419,324439,324514
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_60/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/lib/Sema/SemaChecking.cpp?rev=324602&r1=324601&r2=324602&view=diff
==============================================================================
--- cfe/branches/release_60/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/release_60/lib/Sema/SemaChecking.cpp Thu Feb 8 05:19:38 2018
@@ -8972,6 +8972,16 @@ static void AnalyzeComparison(Sema &S, B
LHS = LHS->IgnoreParenImpCasts();
RHS = RHS->IgnoreParenImpCasts();
+ if (!S.getLangOpts().CPlusPlus) {
+ // Avoid warning about comparison of integers with different signs when
+ // RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+ // the type of `E`.
+ if (const auto *TET = dyn_cast<TypeOfExprType>(LHS->getType()))
+ LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+ if (const auto *TET = dyn_cast<TypeOfExprType>(RHS->getType()))
+ RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+ }
+
// Check to see if one of the (unmodified) operands is of different
// signedness.
Expr *signedOperand, *unsignedOperand;
Modified: cfe/branches/release_60/test/Sema/compare.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/test/Sema/compare.c?rev=324602&r1=324601&r2=324602&view=diff
==============================================================================
--- cfe/branches/release_60/test/Sema/compare.c (original)
+++ cfe/branches/release_60/test/Sema/compare.c Thu Feb 8 05:19:38 2018
@@ -391,3 +391,16 @@ typedef char two_chars[2];
void test12(unsigned a) {
if (0 && -1 > a) { }
}
+
+// PR36008
+
+enum PR36008EnumTest {
+ kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+ __typeof__(lhs) x = lhs;
+ __typeof__(kPR36008Value) y = (kPR36008Value);
+ if (x == y) x = y; // no warning
+ if (y == x) y = x; // no warning
+}
More information about the llvm-branch-commits
mailing list