]>
Commit | Line | Data |
---|---|---|
5384b728 | 1 | 2001-10-12 Jakub Jelinek <jakub@redhat.com> |
2 | ||
3 | * tree-inline.c (initialize_inlined_parameters): Fail if less | |
4 | arguments are passed than expected. | |
5 | (expand_call_inline): Cleanup if initialize_inlined_parameters | |
6 | fails. | |
7 | ||
8 | * g++.dg/other/inline1.C: New test. | |
9 | ||
10 | --- gcc/tree-inline.c.jj Tue Oct 9 16:03:13 2001 | |
11 | +++ gcc/tree-inline.c Fri Oct 12 17:08:23 2001 | |
18ccd915 | 12 | @@ -474,20 +474,28 @@ initialize_inlined_parameters (id, args, |
5384b728 | 13 | |
14 | /* Loop through the parameter declarations, replacing each with an | |
15 | equivalent VAR_DECL, appropriately initialized. */ | |
16 | - for (p = parms, a = args; p; | |
17 | - a = a ? TREE_CHAIN (a) : a, p = TREE_CHAIN (p)) | |
18 | + for (p = parms, a = args; p; a = TREE_CHAIN (a), p = TREE_CHAIN (p)) | |
19 | { | |
18ccd915 | 20 | #ifndef INLINER_FOR_JAVA |
5384b728 | 21 | tree init_stmt; |
18ccd915 JB |
22 | tree cleanup; |
23 | #endif /* not INLINER_FOR_JAVA */ | |
5384b728 | 24 | tree var; |
25 | tree value; | |
18ccd915 | 26 | tree var_sub; |
5384b728 | 27 | |
28 | + if (a == NULL_TREE) | |
29 | + { | |
30 | + pop_srcloc (); | |
31 | + /* If less arguments were passed than actually required, | |
32 | + issue warning and avoid inlining. */ | |
33 | + warning ("too few arguments passed to inline function, suppressing inlining"); | |
34 | + return error_mark_node; | |
35 | + } | |
36 | + | |
37 | /* Find the initializer. */ | |
38 | value = (*lang_hooks.tree_inlining.convert_parm_for_inlining) | |
39 | - (p, a ? TREE_VALUE (a) : NULL_TREE, fn); | |
40 | + (p, TREE_VALUE (a), fn); | |
41 | ||
42 | /* If the parameter is never assigned to, we may not need to | |
43 | create a new variable here at all. Instead, we may be able | |
44 | @@ -863,6 +871,14 @@ expand_call_inline (tp, walk_subtrees, d | |
45 | ||
46 | /* Initialize the parameters. */ | |
47 | arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn); | |
48 | + if (arg_inits == error_mark_node) | |
49 | + { | |
50 | + /* Clean up. */ | |
51 | + splay_tree_delete (id->decl_map); | |
52 | + id->decl_map = st; | |
53 | + return NULL_TREE; | |
54 | + } | |
55 | + | |
56 | /* Expand any inlined calls in the initializers. Do this before we | |
57 | push FN on the stack of functions we are inlining; we want to | |
58 | inline calls to FN that appear in the initializers for the | |
59 | --- gcc/testsuite/g++.dg/other/inline1.C.jj Fri Oct 12 16:54:05 2001 | |
60 | +++ gcc/testsuite/g++.dg/other/inline1.C Fri Oct 12 17:14:35 2001 | |
61 | @@ -0,0 +1,38 @@ | |
62 | +// { dg-do compile { target i?86-*-* } } | |
63 | +// { dg-options -O } | |
64 | + | |
65 | +typedef unsigned int u4; | |
66 | +typedef unsigned long long u8; | |
67 | +typedef u8 (*u8tou8)(u8); | |
68 | + | |
69 | +struct C { | |
70 | + static inline u8 a(u4 x, u4 y); | |
71 | + static inline u8 b(unsigned char *p) { return c(*(u8 *)p); } | |
72 | + static inline u8 c(u8 x) { // { dg-warning "too few arguments" "too few" } | |
73 | + return ((u8tou8)a)(x); | |
74 | + } | |
75 | +}; | |
76 | + | |
77 | +inline u8 C::a(u4 x, u4 y) { | |
78 | + return x + y; | |
79 | +} | |
80 | + | |
81 | +u8 n = 0x123456789abcdef; | |
82 | + | |
83 | +struct B { | |
84 | + unsigned char *e; | |
85 | + B() { e = (unsigned char *) &n; } | |
86 | + u8 f() { | |
87 | + return C::b(e); | |
88 | + } | |
89 | +}; | |
90 | + | |
91 | +struct A { | |
92 | + B *g; | |
93 | + void foo (); | |
94 | +}; | |
95 | + | |
96 | +void A::foo () | |
97 | +{ | |
98 | + g->f(); | |
99 | +} |