aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-06-05 12:42:29 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-06-05 12:42:29 +0000
commit5ae98e828d779eaada3d1a8a3ee2f17ecac401de (patch)
tree25a0f2d0c609d6fea9e87e7d55c8f9fb91015a7c /gcc/cp
parent97826595b521a73a5557d110c366e3df78c57f69 (diff)
downloadgcc-5ae98e828d779eaada3d1a8a3ee2f17ecac401de.zip
gcc-5ae98e828d779eaada3d1a8a3ee2f17ecac401de.tar.gz
gcc-5ae98e828d779eaada3d1a8a3ee2f17ecac401de.tar.bz2
re PR c++/61004 (Spurious warning: dereferencing type-punned pointer)
2014-06-05 Richard Biener <rguenther@suse.de> PR c++/61004 * typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing warnings for accessing empty classes. * g++.dg/diagnostic/pr61004.C: New testcase. From-SVN: r211272
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a4dcdb2..fd51940 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-05 Richard Biener <rguenther@suse.de>
+
+ PR c++/61004
+ * typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
+ warnings for accessing empty classes.
+
2014-06-05 Marek Polacek <polacek@redhat.com>
PR c/49706
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 4a876f9..fa90475 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2935,8 +2935,9 @@ cp_build_indirect_ref (tree ptr, ref_operator errorstring,
of the result is "T." */
tree t = TREE_TYPE (type);
- if (CONVERT_EXPR_P (ptr)
- || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
+ if ((CONVERT_EXPR_P (ptr)
+ || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
+ && (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
{
/* If a warning is issued, mark it to avoid duplicates from
the backend. This only needs to be done at