aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2005-11-24 10:48:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2005-11-24 10:48:15 +0000
commitde9c56a4dc72cbf510064de22950ef44835701c7 (patch)
tree2423af056692fa5b5f531ef395833a9a44b629dd /gcc/cp
parent349d23dd85821238f764ac9868dcd32fc50db5a9 (diff)
downloadgcc-de9c56a4dc72cbf510064de22950ef44835701c7.zip
gcc-de9c56a4dc72cbf510064de22950ef44835701c7.tar.gz
gcc-de9c56a4dc72cbf510064de22950ef44835701c7.tar.bz2
re PR c++/14024 (g++ isn't reporting aliasing warnings)
2005-11-24 Richard Guenther <rguenther@suse.de> Dirk Mueller <dmueller@suse.de> PR c++/14024 * c-common.h (strict_aliasing_warning): Declare. * c-common.c (strict_aliasing_warning): New function, split out from ... * c-typeck.c (build_c_cast): ... here. * typeck.c (build_reinterpret_cast_1): Use it. * g++.dg/warn/Wstrict-aliasing-1.C: New testcase. * g++.dg/warn/Wstrict-aliasing-2.C: Likewise. * g++.dg/warn/Wstrict-aliasing-3.C: Likewise. * g++.dg/warn/Wstrict-aliasing-4.C: Likewise. * g++.dg/warn/Wstrict-aliasing-5.C: Likewise. * g++.dg/warn/Wstrict-aliasing-6.C: Likewise. Co-Authored-By: Dirk Mueller <dmueller@suse.de> From-SVN: r107459
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c7
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 046d049..dbf3330 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2005-11-24 Richard Guenther <rguenther@suse.de>
+ Dirk Mueller <dmueller@suse.de>
+
+ PR c++/14024
+ * typeck.c (build_reinterpret_cast_1): Use
+ strict_aliasing_warning.
+
2005-11-23 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR c++/24235
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b3c155a..60ef195 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5011,6 +5011,8 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
else if ((TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
|| (TYPE_PTROBV_P (type) && TYPE_PTROBV_P (intype)))
{
+ tree sexpr = expr;
+
if (!c_cast_p)
check_for_casting_away_constness (intype, type, error,
"reinterpret_cast");
@@ -5025,6 +5027,11 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
"target type",
intype, type);
+ /* We need to strip nops here, because the frontend likes to
+ create (int *)&a for array-to-pointer decay, instead of &a[0]. */
+ STRIP_NOPS (sexpr);
+ strict_aliasing_warning (intype, type, sexpr);
+
return fold_if_not_in_template (build_nop (type, expr));
}
else if ((TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype))