File: returnst.c

package info (click to toggle)
icmake 7.18.00-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,840 kB
  • sloc: ansic: 7,784; makefile: 3,811; sh: 319; cpp: 83
file content (49 lines) | stat: -rw-r--r-- 1,262 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
                            R E T U R N S T . C
*/

#include "iccomp.h"

ESTRUC_ *return_stmnt(op, e)
    E_TYPE_
        op;
    ESTRUC_
        *e;
{
    SYMBOL_
        *last;

    if (!test_type(e, e_code))
        etoc(e);

    last = &funtab.symbol[funtab.n_defined - 1];

    if ((OPCODE_)op == op_ret)              /* return opcode received */
    {
        if
        (
            !
            (
                (                           /* void if the union of */
                    last->var.type          /* the type of the function */
                    |                       /* and the */
                    e->type                 /* type of the expression */
                )
                &                           /* intersected with */
                ALLTYPES                    /* all types */
            )                               /* is empty. */
        )
        {
            gencode(e, op);                 /* generate the 'ret' opcode */
            return (e);                     /* done */
        }

        if (!(test_type(e, last->var.type & ALLTYPES)))
            semantic("Incorrect returntype for function '%s()'", last->name);
    }

    gencode(e, op_pop_reg);
    gencode(e, op);

    return (e);
}