[PR36008] Avoid -Wsign-compare warning for enum constants in typeof expressions
ClosedPublic

Authored by arphaman on Jan 25 2018, 4:32 PM.

Details

Summary

This patch looks through typeof type at the original expression when diagnosing -Wsign-compare to avoid an unfriendly diagnostic.

Fixes PR36008

Diff Detail

Repository
rL LLVM
arphaman created this revision.Jan 25 2018, 4:32 PM
lebedev.ri edited the summary of this revision. (Show Details)Jan 26 2018, 2:33 AM
lebedev.ri added a project: Restricted Project.
lebedev.ri added inline comments.
lib/Sema/SemaChecking.cpp
8959 ↗(On Diff #131522)

Please also add a comment what this is trying to solve.

test/Sema/compare.c
404 ↗(On Diff #131522)

Can you also add the swapped test:

if (y == x) x = y; // no warning
aaron.ballman added inline comments.Jan 26 2018, 8:02 AM
lib/Sema/SemaChecking.cpp
8959 ↗(On Diff #131522)

const auto *

test/Sema/compare.c
398 ↗(On Diff #131522)

Formatting looks off here.

arphaman updated this revision to Diff 132901.Feb 5 2018, 3:58 PM
arphaman marked 4 inline comments as done.

Address review comments and fix the inverted check case.

aaron.ballman accepted this revision.Feb 6 2018, 4:49 AM

LGTM, aside from a minor commenting nit.

lib/Sema/SemaChecking.cpp
8960 ↗(On Diff #132901)

to the sign -> from the sign

This revision is now accepted and ready to land.Feb 6 2018, 4:49 AM
arphaman marked an inline comment as done.Feb 7 2018, 12:47 PM
This revision was automatically updated to reflect the committed changes.