Skip to content

Commit 0707866

Browse files
committed
re PR c++/46401 (very slow compile time with -Wsequence-point)
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: r166823
1 parent 18c33e0 commit 0707866

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

gcc/c-family/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2010-11-16 Jakub Jelinek <[email protected]>
2+
3+
PR c++/46401
4+
* c-common.c (warning_candidate_p): Don't track non-const calls
5+
or STRING_CSTs.
6+
17
2010-11-15 Ian Lance Taylor <[email protected]>
28

39
* c-lex.c (init_c_lex): Set macro debug callbacks if

gcc/c-family/c-common.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,10 +2324,26 @@ warn_for_collisions (struct tlist *list)
23242324
static int
23252325
warning_candidate_p (tree x)
23262326
{
2327-
/* !VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
2327+
if (DECL_P (x) && DECL_ARTIFICIAL (x))
2328+
return 0;
2329+
2330+
/* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
23282331
(lvalue_p) crash on TRY/CATCH. */
2329-
return !(DECL_P (x) && DECL_ARTIFICIAL (x))
2330-
&& TREE_TYPE (x) && !VOID_TYPE_P (TREE_TYPE (x)) && lvalue_p (x);
2332+
if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x)))
2333+
return 0;
2334+
2335+
if (!lvalue_p (x))
2336+
return 0;
2337+
2338+
/* No point to track non-const calls, they will never satisfy
2339+
operand_equal_p. */
2340+
if (TREE_CODE (x) == CALL_EXPR && (call_expr_flags (x) & ECF_CONST) == 0)
2341+
return 0;
2342+
2343+
if (TREE_CODE (x) == STRING_CST)
2344+
return 0;
2345+
2346+
return 1;
23312347
}
23322348

23332349
/* Return nonzero if X and Y appear to be the same candidate (or NULL) */

gcc/testsuite/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2010-11-16 Jakub Jelinek <[email protected]>
2+
3+
PR c++/46401
4+
* g++.dg/warn/Wsequence-point-3.C: New test.
5+
16
2010-11-16 Kai Tietz <[email protected]>
27

38
PR preprocessor/17349
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// PR c++/46401
2+
// { dg-do compile }
3+
// { dg-options "-Wsequence-point" }
4+
5+
struct S
6+
{
7+
S ();
8+
S &operator<< (const char *);
9+
S (const S &);
10+
};
11+
12+
#define N1(n) << #n
13+
#define N2(n) N1(n)
14+
#define N3(n) N2(n##0) N2(n##1) N2(n##2) N2(n##3) N2(n##4) \
15+
N2(n##5) N2(n##6) N2(n##7) N2(n##8) N2(n##9)
16+
#define N4(n) N3(n##0) N3(n##1) N3(n##2) N3(n##3) N3(n##4) \
17+
N3(n##5) N3(n##6) N3(n##7) N3(n##8) N3(n##9)
18+
#define N5(n) N4(n##0) N4(n##1) N4(n##2) N4(n##3) N4(n##4) \
19+
N4(n##5) N4(n##6) N4(n##7) N4(n##8) N4(n##9)
20+
S s = S () N5(a) N5(b);

0 commit comments

Comments
 (0)