diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-04-26 10:33:10 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-04-26 10:33:10 +0000 |
commit | e78a87f724bc83fa6dab383742ec82f3b28a92eb (patch) | |
tree | d4f07be6bc47beccfe2a18adf7c4fd4762e2865a /gcc/c-family/c-warn.c | |
parent | 4ef8a24ca5416226d82ca272dea88e460ae2ce86 (diff) | |
download | gcc-e78a87f724bc83fa6dab383742ec82f3b28a92eb.zip gcc-e78a87f724bc83fa6dab383742ec82f3b28a92eb.tar.gz gcc-e78a87f724bc83fa6dab383742ec82f3b28a92eb.tar.bz2 |
Fix use of COMPLETE_TYPE_P for -Wstrict-aliasing=1
The handling of -Wstrict-aliasing=1 applied COMPLETE_TYPE_P to the
pointer type rather than the pointer target, so missed the warnings
for "struct incomplete" in the testcase.
I couldn't find any existing C tests for -Wstrict-aliasing=1,
so I added a few extra tests besides the ones fixed by the patch.
I'm sure there's lots more we could test -- this is just supposed
to be better than the status quo (i.e. nothing).
2019-04-26 Richard Sandiford <richard.sandiford@arm.com>
gcc/c-family/
* c-warn.c (strict_aliasing_warning): Apply COMPLETE_TYPE_P to
the pointer target rather than the pointer itself.
gcc/testsuite/
* gcc.dg/alias-16.c: New test.
From-SVN: r270594
Diffstat (limited to 'gcc/c-family/c-warn.c')
-rw-r--r-- | gcc/c-family/c-warn.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 322cf98..f95eba9 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -746,7 +746,7 @@ strict_aliasing_warning (location_t loc, tree type, tree expr) are not revealed at higher levels. */ alias_set_type set1 = get_alias_set (TREE_TYPE (otype)); alias_set_type set2 = get_alias_set (TREE_TYPE (type)); - if (!COMPLETE_TYPE_P (type) + if (!COMPLETE_TYPE_P (TREE_TYPE (type)) || !alias_sets_must_conflict_p (set1, set2)) { warning_at (loc, OPT_Wstrict_aliasing, |