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,20 +474,28 @@ 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))
20 #ifndef INLINER_FOR_JAVA
23 #endif /* not INLINER_FOR_JAVA */
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;
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);
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
46 /* Initialize the parameters. */
47 arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn);
48 + if (arg_inits == error_mark_node)
51 + splay_tree_delete (id->decl_map);
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
62 +// { dg-do compile { target i?86-*-* } }
65 +typedef unsigned int u4;
66 +typedef unsigned long long u8;
67 +typedef u8 (*u8tou8)(u8);
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);
77 +inline u8 C::a(u4 x, u4 y) {
81 +u8 n = 0x123456789abcdef;
85 + B() { e = (unsigned char *) &n; }