1 2001-10-12 Jakub Jelinek <jakub@redhat.com>
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
8 * g++.dg/other/inline1.C: New test.
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
12 @@ -474,17 +474,25 @@ initialize_inlined_parameters (id, args,
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))
28 + /* If less arguments were passed than actually required,
29 + issue warning and avoid inlining. */
30 + warning ("too few arguments passed to inline function, suppressing inlining");
31 + return error_mark_node;
34 /* Find the initializer. */
35 value = (*lang_hooks.tree_inlining.convert_parm_for_inlining)
36 - (p, a ? TREE_VALUE (a) : NULL_TREE, fn);
37 + (p, TREE_VALUE (a), fn);
39 /* If the parameter is never assigned to, we may not need to
40 create a new variable here at all. Instead, we may be able
41 @@ -863,6 +871,14 @@ expand_call_inline (tp, walk_subtrees, d
43 /* Initialize the parameters. */
44 arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn);
45 + if (arg_inits == error_mark_node)
48 + splay_tree_delete (id->decl_map);
53 /* Expand any inlined calls in the initializers. Do this before we
54 push FN on the stack of functions we are inlining; we want to
55 inline calls to FN that appear in the initializers for the
56 --- gcc/testsuite/g++.dg/other/inline1.C.jj Fri Oct 12 16:54:05 2001
57 +++ gcc/testsuite/g++.dg/other/inline1.C Fri Oct 12 17:14:35 2001
59 +// { dg-do compile { target i?86-*-* } }
62 +typedef unsigned int u4;
63 +typedef unsigned long long u8;
64 +typedef u8 (*u8tou8)(u8);
67 + static inline u8 a(u4 x, u4 y);
68 + static inline u8 b(unsigned char *p) { return c(*(u8 *)p); }
69 + static inline u8 c(u8 x) { // { dg-warning "too few arguments" "too few" }
70 + return ((u8tou8)a)(x);
74 +inline u8 C::a(u4 x, u4 y) {
78 +u8 n = 0x123456789abcdef;
82 + B() { e = (unsigned char *) &n; }