aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/pr61004.C11
4 files changed, 25 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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c43536f..5073054e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-05 Richard Biener <rguenther@suse.de>
+
+ PR c++/61004
+ * g++.dg/diagnostic/pr61004.C: New testcase.
+
2014-06-05 Yuri Rumyantsev <ysrumyan@gmail.com>
* gcc.dg/torture/pr61319.c: New test.
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr61004.C b/gcc/testsuite/g++.dg/diagnostic/pr61004.C
new file mode 100644
index 0000000..3bf66be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr61004.C
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-O2 -Wall" }
+
+struct A{ };
+struct B:A{};
+void f(A const&);
+int main()
+{
+ B b;
+ f(b); // { dg-bogus "strict-aliasing" }
+}