]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/46401 (very slow compile time with -Wsequence-point)
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Dec 2010 15:06:27 +0000 (16:06 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 7 Dec 2010 15:06:27 +0000 (16:06 +0100)
Backport from mainline
2010-11-16  Jakub Jelinek  <jakub@redhat.com>

PR c++/46401
* c-common.c (warning_candidate_p): Don't track non-const calls
or STRING_CSTs.

* g++.dg/warn/Wsequence-point-3.C: New test.

From-SVN: r167538

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wsequence-point-3.C [new file with mode: 0644]

index 4d52ec8d1e0b10a1c42c4050ed23fdd99491c226..2d2fa0d6d31f2e654733d9750eec819afc7063f2 100644 (file)
@@ -1,3 +1,12 @@
+2010-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       Backport from mainline
+       2010-11-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/46401
+       * c-common.c (warning_candidate_p): Don't track non-const calls
+       or STRING_CSTs.
+
 2010-12-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        Backport from mainline:
index db329cef546bc71a9c9ca7776f081bac2a1e3d29..03e56d28214546103ca7dc7fc8b0fa12b71c6d8e 100644 (file)
@@ -2475,10 +2475,26 @@ warn_for_collisions (struct tlist *list)
 static int
 warning_candidate_p (tree x)
 {
-  /* !VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
+  if (DECL_P (x) && DECL_ARTIFICIAL (x))
+    return 0;
+
+  /* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
      (lvalue_p) crash on TRY/CATCH. */
-  return !(DECL_P (x) && DECL_ARTIFICIAL (x))
-    && TREE_TYPE (x) && !VOID_TYPE_P (TREE_TYPE (x)) && lvalue_p (x);
+  if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x)))
+    return 0;
+
+  if (!lvalue_p (x))
+    return 0;
+
+  /* No point to track non-const calls, they will never satisfy
+     operand_equal_p.  */
+  if (TREE_CODE (x) == CALL_EXPR && (call_expr_flags (x) & ECF_CONST) == 0)
+    return 0;
+
+  if (TREE_CODE (x) == STRING_CST)
+    return 0;
+
+  return 1;
 }
 
 /* Return nonzero if X and Y appear to be the same candidate (or NULL) */
index 3c708befede4776a5c98c03c996280a65f67ba4e..4728ba4220e2b70a8c41192ce316d1d34e8363d0 100644 (file)
@@ -1,3 +1,11 @@
+2010-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       Backport from mainline
+       2010-11-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/46401
+       * g++.dg/warn/Wsequence-point-3.C: New test.
+
 2010-12-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/warn/Wsequence-point-3.C b/gcc/testsuite/g++.dg/warn/Wsequence-point-3.C
new file mode 100644 (file)
index 0000000..5f73ca1
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/46401
+// { dg-do compile }
+// { dg-options "-Wsequence-point" }
+
+struct S
+{
+  S ();
+  S &operator<< (const char *);
+  S (const S &);
+};
+
+#define N1(n) << #n
+#define N2(n) N1(n)
+#define N3(n) N2(n##0) N2(n##1) N2(n##2) N2(n##3) N2(n##4) \
+             N2(n##5) N2(n##6) N2(n##7) N2(n##8) N2(n##9)
+#define N4(n) N3(n##0) N3(n##1) N3(n##2) N3(n##3) N3(n##4) \
+             N3(n##5) N3(n##6) N3(n##7) N3(n##8) N3(n##9)
+#define N5(n) N4(n##0) N4(n##1) N4(n##2) N4(n##3) N4(n##4) \
+             N4(n##5) N4(n##6) N4(n##7) N4(n##8) N4(n##9)
+S s = S () N5(a) N5(b);