• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision6263dde1ca1907900babb51a45761ababb793def (tree)
l'heure2016-02-20 01:02:51
Auteurjakub <jakub@138b...>
Commiterjakub

Message de Log

PR c++/69850
* init.c (build_vec_delete_1): Set TREE_NO_WARNING on the NE_EXPR
condition.
* cp-gimplify.c (cp_fold): Propagate TREE_NO_WARNING from binary
operators if folding preserved the binop, just with different
arguments.

* g++.dg/warn/Wnonnull-compare-2.C: New test.
* g++.dg/warn/Wnonnull-compare-3.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233561 138bc75d-0d04-0410-961f-82ee72b054a4

Change Summary

Modification

--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
11 2016-02-19 Jakub Jelinek <jakub@redhat.com>
22
3+ PR c++/69850
4+ * init.c (build_vec_delete_1): Set TREE_NO_WARNING on the NE_EXPR
5+ condition.
6+ * cp-gimplify.c (cp_fold): Propagate TREE_NO_WARNING from binary
7+ operators if folding preserved the binop, just with different
8+ arguments.
9+
310 PR c++/67767
411 * parser.c (cp_parser_std_attribute_spec_seq): Don't assume
512 attr_spec is always single element chain, chain all the attributes
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2068,6 +2068,9 @@ cp_fold (tree x)
20682068 else
20692069 x = fold (x);
20702070
2071+ if (TREE_NO_WARNING (org_x)
2072+ && TREE_CODE (x) == TREE_CODE (org_x))
2073+ TREE_NO_WARNING (x) = 1;
20712074 break;
20722075
20732076 case VEC_COND_EXPR:
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3678,12 +3678,15 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
36783678 body = integer_zero_node;
36793679
36803680 /* Outermost wrapper: If pointer is null, punt. */
3681+ tree cond
3682+ = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, base,
3683+ fold_convert (TREE_TYPE (base), nullptr_node));
3684+ /* This is a compiler generated comparison, don't emit
3685+ e.g. -Wnonnull-compare warning for it. */
3686+ if (TREE_CODE (cond) == NE_EXPR)
3687+ TREE_NO_WARNING (cond) = 1;
36813688 body = fold_build3_loc (input_location, COND_EXPR, void_type_node,
3682- fold_build2_loc (input_location,
3683- NE_EXPR, boolean_type_node, base,
3684- fold_convert (TREE_TYPE (base),
3685- nullptr_node)),
3686- body, integer_zero_node);
3689+ cond, body, integer_zero_node);
36873690 body = build1 (NOP_EXPR, void_type_node, body);
36883691
36893692 if (controller)
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
11 2016-02-19 Jakub Jelinek <jakub@redhat.com>
22
3+ PR c++/69850
4+ * g++.dg/warn/Wnonnull-compare-2.C: New test.
5+ * g++.dg/warn/Wnonnull-compare-3.C: New test.
6+
37 PR c++/67767
48 * g++.dg/cpp0x/pr67767.C: New test.
59
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wnonnull-compare-2.C
@@ -0,0 +1,27 @@
1+// PR c++/69850
2+// { dg-do compile }
3+// { dg-options "-Wnonnull-compare" }
4+
5+struct D {
6+ virtual ~D ();
7+ void foo () const { delete this; } // { dg-bogus "nonnull argument" }
8+ template <typename> friend struct A;
9+};
10+template <typename T> struct A {
11+ static void bar (T *x) { x->foo (); }
12+};
13+template <typename T> struct B {
14+ T b;
15+ void baz () { A<T>::bar (&b); }
16+};
17+class C {
18+ class E : public D { ~E (); };
19+ void baz ();
20+ B<E> c;
21+};
22+
23+void
24+C::baz ()
25+{
26+ c.baz ();
27+}
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wnonnull-compare-3.C
@@ -0,0 +1,28 @@
1+// PR c++/69850
2+// { dg-do compile }
3+// { dg-options "-Wnonnull-compare" }
4+
5+template <typename T>
6+struct A {
7+ static void foo (T *x) { x->bar (); }
8+};
9+template <typename T>
10+struct B {
11+ T b;
12+ void operator= (B) { A<T>::foo (&b); }
13+};
14+struct C {
15+ void bar () { delete[] this; } // { dg-bogus "nonnull argument" }
16+};
17+struct D { B<C> d; };
18+struct G {
19+ D g[6];
20+ void baz ();
21+};
22+int a;
23+
24+void
25+G::baz ()
26+{
27+ g[a] = g[1];
28+}