aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-02-09 19:31:10 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-02-09 19:31:10 +0000
commit0444aa9c0a3357707624263ec2fd13d8f156016e (patch)
treedfe37130c665a88b85c0d08c740c2ba447b3cedc /gcc/c
parentdd2799cc2212a72a1b31828918f9bb9287ab9780 (diff)
downloadgcc-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/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-typeck.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 97ae43c..bca7268 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-09 Nathan Sidwell <nathan@acm.org>
+
+ PR c/84293
+ * c-typeck.c (build_indirect_ref, build_c_cast): Pass expr location
+ to strict_aliasing_warning.
+
2018-02-02 Paolo Carlini <paolo.carlini@oracle.com>
* c-typeck.c (really_start_incremental_init, push_init_level,
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index b35c2c0..1eae4ea 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2524,7 +2524,7 @@ build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
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 (pointer, 0)),
+ if (strict_aliasing_warning (EXPR_LOCATION (pointer),
type, TREE_OPERAND (pointer, 0)))
TREE_NO_WARNING (pointer) = 1;
}
@@ -5696,7 +5696,7 @@ build_c_cast (location_t loc, tree type, tree expr)
"of different size");
if (warn_strict_aliasing <= 2)
- strict_aliasing_warning (otype, type, expr);
+ strict_aliasing_warning (EXPR_LOCATION (value), type, expr);
/* If pedantic, warn for conversions between function and object
pointer types, except for converting a null pointer constant