This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Improve a -Warray-bounds diagnostic
ClosedPublic

Authored by erik.pilkington on Jan 22 2019, 12:43 PM.

Details

Summary

Fix a bug where we would compare array sizes with incompatible element types, and look through explicit casts.

rdar://44800168

Thanks for taking a look!

Diff Detail

Event Timeline

aaron.ballman accepted this revision.Jan 23 2019, 5:53 AM

LGTM with a testing request and some small nits.

clang/include/clang/AST/ASTContext.h
2092

Can you add a dependent type test as well?

clang/test/Sema/static-array.c
25

Add an extra space after expected-warning and the { for the second warning.

29

Same here.

This revision is now accepted and ready to land.Jan 23 2019, 5:53 AM
erik.pilkington marked an inline comment as done.Jan 24 2019, 3:49 PM
erik.pilkington added inline comments.
clang/include/clang/AST/ASTContext.h
2092

I don't think its possible to get a dependent type here, since this feature is only supported in C mode.

aaron.ballman added inline comments.Jan 25 2019, 7:19 AM
clang/include/clang/AST/ASTContext.h
2092

That makes sense; I couldn't figure out a way to trigger it either. It seems sensible to leave it in should we ever need this for C++, though.

This revision was automatically updated to reflect the committed changes.