]> git.pld-linux.org Git - packages/gcc.git/blob - gcc32-bogus-inline.patch
- fixed files for ppc
[packages/gcc.git] / gcc32-bogus-inline.patch
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
12 @@ -474,17 +474,25 @@ initialize_inlined_parameters (id, args,
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      {
20        tree init_stmt;
21        tree var;
22        tree value;
23        tree cleanup;
24  
25 +      if (a == NULL_TREE)
26 +       {
27 +         pop_srcloc ();
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;
32 +       }
33 +
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);
38  
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
42  
43    /* Initialize the parameters.  */
44    arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn);
45 +  if (arg_inits == error_mark_node)
46 +    {
47 +      /* Clean up.  */
48 +      splay_tree_delete (id->decl_map);
49 +      id->decl_map = st;
50 +      return NULL_TREE;
51 +    }
52 +
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
58 @@ -0,0 +1,38 @@
59 +// { dg-do compile { target i?86-*-* } }
60 +// { dg-options -O }
61 +
62 +typedef unsigned int u4;
63 +typedef unsigned long long u8;
64 +typedef u8 (*u8tou8)(u8);
65 +
66 +struct C {
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);
71 +  }
72 +};
73 +
74 +inline u8 C::a(u4 x, u4 y) {
75 +  return x + y;
76 +}
77 +
78 +u8 n = 0x123456789abcdef;
79 +
80 +struct B {
81 +  unsigned char *e;
82 +  B() { e = (unsigned char *) &n; }
83 +  u8 f() {
84 +    return C::b(e);
85 +  }
86 +};
87 +
88 +struct A {
89 +  B *g;
90 +  void foo ();
91 +};
92 +
93 +void A::foo ()
94 +{
95 +  g->f();
96 +}
This page took 0.041012 seconds and 3 git commands to generate.