Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / ast / ast_check.cpp
blobe42960855fe16384f8bff055302b9257cac0d268
1 /*
3 COPYRIGHT
5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in which
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
49 52.227-19.
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
54 SunSoft, Inc.
55 2550 Garcia Avenue
56 Mountain View, California 94043
58 NOTE:
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
65 // The check ensures that for every forward declared struct or union we also
66 // saw a full definition.
68 #include "global_extern.h"
69 #include "utl_err.h"
71 #include "utl_scope.h"
73 // Static storage for remembering nodes.
74 static AST_Type **ast_fwds = 0;
75 static long ast_n_fwds_used = 0;
76 static long ast_n_fwds_alloc = 0;
78 #undef INCREMENT
79 #define INCREMENT 64
81 // Store a node representing a forward declared struct or union.
82 void
83 AST_record_fwd_decl (AST_Type *n)
85 AST_Type **o_ast_fwds = 0;
86 long o_ast_n_fwds_alloc = 0;
88 // Make sure there's space to store one more.
89 if (ast_n_fwds_used == ast_n_fwds_alloc)
91 if (ast_n_fwds_alloc == 0)
93 ast_n_fwds_alloc = INCREMENT;
94 ACE_NEW (ast_fwds,
95 AST_Type *[ast_n_fwds_alloc]);
97 else
99 o_ast_fwds = ast_fwds;
100 o_ast_n_fwds_alloc = ast_n_fwds_alloc;
102 ast_n_fwds_alloc += INCREMENT;
103 ACE_NEW (ast_fwds,
104 AST_Type *[ast_n_fwds_alloc]);
106 for (long i = 0; i < o_ast_n_fwds_alloc; i++)
108 ast_fwds[i] = o_ast_fwds[i];
111 delete o_ast_fwds;
115 // Insert new node.
116 ast_fwds[ast_n_fwds_used++] = n;
119 // Check that all forward declared structs and unions were also defined.
120 TAO_IDL_FE_Export void
121 AST_check_fwd_decls (void)
123 AST_Type *d = 0;
125 for (long i = 0; i < ast_n_fwds_used; ++i)
127 d = ast_fwds[i];
129 if (!d->is_defined ())
131 // The member pd_full_definition is no longer set for
132 // every fwd decl, if there is more than one. So if
133 // is_defined() fails, we try to look up the fwd decl
134 // that has the full def, and emit an error only if
135 // this lookup fails.
136 AST_Decl *f =
137 d->defined_in ()->lookup_by_name_local (d->local_name (),
138 true);
140 if (f == 0)
142 idl_global->err ()->fwd_decl_not_defined (d);
147 // This method is called once per file in the command line,
148 // in between which the elements of ast_fwds are destroyed,
149 // so we have to clean up.
150 delete [] ast_fwds;
151 ast_fwds = 0;
152 ast_n_fwds_alloc = 0;
153 ast_n_fwds_used = 0;