PR c++/89973 - -Waddress-of-packed-member ICE with invalid conversion.
authorMarek Polacek <polacek@redhat.com>
Fri, 5 Apr 2019 14:56:53 +0000 (14:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 5 Apr 2019 14:56:53 +0000 (14:56 +0000)
PR c++/89973 - -Waddress-of-packed-member ICE with invalid conversion.
* c-warn.c (check_address_or_pointer_of_packed_member): Check the type
of RHS.

* g++.dg/warn/Waddress-of-packed-member2.C: New test.

From-SVN: r270166

gcc/c-family/ChangeLog
gcc/c-family/c-warn.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Waddress-of-packed-member2.C [new file with mode: 0644]

index ae6b8a7094d016033a937b5ed6d06821a1463a6b..5cce5de1d2818270662b5e1f2c52059d65107d02 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-05  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89973 - -Waddress-of-packed-member ICE with invalid conversion. 
+       * c-warn.c (check_address_or_pointer_of_packed_member): Check the type
+       of RHS.
+
 2019-04-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/86586 - -fcompare-debug=-Wsign-compare.
index 4785887c1de508333d2090ed776b613662e0c115..05ea2bf87199f8f0308fee8ce3af381874728ec1 100644 (file)
@@ -2769,7 +2769,7 @@ check_address_or_pointer_of_packed_member (tree type, tree rhs)
          rhs = TREE_TYPE (rhs);        /* Pointer type.  */
          rhs = TREE_TYPE (rhs);        /* Function type.  */
          rhstype = TREE_TYPE (rhs);
-         if (!POINTER_TYPE_P (rhstype))
+         if (!rhstype || !POINTER_TYPE_P (rhstype))
            return NULL_TREE;
          rvalue = true;
        }
index e19a1b824e9307bba252b3cee5e0e61e9cda8db6..4a9fd96ea3615e352a49d91d22f73b59e436a61a 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-05  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89973 - -Waddress-of-packed-member ICE with invalid conversion. 
+       * g++.dg/warn/Waddress-of-packed-member2.C: New test.
+
 2019-04-05  Richard Biener  <rguenther@suse.de>
 
        PR debug/89892
diff --git a/gcc/testsuite/g++.dg/warn/Waddress-of-packed-member2.C b/gcc/testsuite/g++.dg/warn/Waddress-of-packed-member2.C
new file mode 100644 (file)
index 0000000..e9bf7ca
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/89973
+// { dg-do compile { target c++14 } }
+
+constexpr int a(); // { dg-warning "used but never defined" }
+
+template <typename>
+constexpr void *b = a(); // { dg-error "invalid conversion" }