diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-02-09 19:31:10 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-02-09 19:31:10 +0000 |
commit | 0444aa9c0a3357707624263ec2fd13d8f156016e (patch) | |
tree | dfe37130c665a88b85c0d08c740c2ba447b3cedc /gcc/cp | |
parent | dd2799cc2212a72a1b31828918f9bb9287ab9780 (diff) | |
download | gcc-0444aa9c0a3357707624263ec2fd13d8f156016e.zip gcc-0444aa9c0a3357707624263ec2fd13d8f156016e.tar.gz gcc-0444aa9c0a3357707624263ec2fd13d8f156016e.tar.bz2 |
[PR c/84293] Unexpected strict-alias warning
https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00510.html
PR c/84293
gcc/c/
* c-typeck.c (build_indirect_ref, build_c_cast): Pass expr location
to strict_aliasing_warning.
gcc/c-family/
* c-common.h (strict_aliasing_warning): Drop OTYPE arg, insert LOC
arg.
* c-warn.c (strict_aliasing_warning): Drop OTYPE arg, require LOC
arg. Adjust.
gcc/cp/
* typeck.c (cp_build_indirect_ref_1, build_reinterpret_cast_1):
Pass expr location to strict_aliasing_warning.
gcc/testsuite/
* c-c++-common/pr84293.h: New.
* c-c++-common/pr84293.c: New.
From-SVN: r257539
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa66e1b..cea51ff 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-09 Nathan Sidwell <nathan@acm.org> + + PR c/84293 + * typeck.c (cp_build_indirect_ref_1, build_reinterpret_cast_1): + Pass expr location to strict_aliasing_warning. + 2018-02-09 Jason Merrill <jason@redhat.com> PR c++/84296 - ICE with qualified-id in template. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index fe18ea9..dfcf716 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3136,7 +3136,7 @@ cp_build_indirect_ref_1 (tree ptr, ref_operator errorstring, the backend. This only needs to be done at warn_strict_aliasing > 2. */ if (warn_strict_aliasing > 2) - if (strict_aliasing_warning (TREE_TYPE (TREE_OPERAND (ptr, 0)), + if (strict_aliasing_warning (EXPR_LOCATION (ptr), type, TREE_OPERAND (ptr, 0))) TREE_NO_WARNING (ptr) = 1; } @@ -7334,7 +7334,7 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, expr = cp_build_addr_expr (expr, complain); if (warn_strict_aliasing > 2) - strict_aliasing_warning (TREE_TYPE (expr), type, expr); + strict_aliasing_warning (EXPR_LOCATION (expr), type, expr); if (expr != error_mark_node) expr = build_reinterpret_cast_1 @@ -7428,8 +7428,6 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, else if ((TYPE_PTRDATAMEM_P (type) && TYPE_PTRDATAMEM_P (intype)) || (TYPE_PTROBV_P (type) && TYPE_PTROBV_P (intype))) { - tree sexpr = expr; - if (!c_cast_p && check_for_casting_away_constness (intype, type, REINTERPRET_CAST_EXPR, @@ -7447,11 +7445,9 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, warning (OPT_Wcast_align, "cast from %qH to %qI " "increases required alignment of target type", intype, type); - /* We need to strip nops here, because the front end likes to - create (int *)&a for array-to-pointer decay, instead of &a[0]. */ - STRIP_NOPS (sexpr); if (warn_strict_aliasing <= 2) - strict_aliasing_warning (intype, type, sexpr); + /* strict_aliasing_warning STRIP_NOPs its expr. */ + strict_aliasing_warning (EXPR_LOCATION (expr), type, expr); return build_nop (type, expr); } |