Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / TAO_IDL / include / utl_err.h
blob4fc0afe033e9e3561314659e28b5cf7955a485be
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 #ifndef _UTL_ERR_UTL_ERR_HH
66 #define _UTL_ERR_UTL_ERR_HH
68 #include "ast_expression.h"
69 #include "idl_global.h"
70 #include "utl_scoped_name.h"
72 class AST_Decl;
73 class AST_Interface;
74 class AST_Enum;
75 class AST_Fixed;
76 class AST_Union;
77 class AST_UnionLabel;
78 class UTL_String;
79 class AST_Annotation_Decl;
80 class AST_Annotation_Member;
82 class TAO_IDL_FE_Export UTL_Error
84 public:
85 UTL_Error();
87 enum ErrorCode {
88 EIDL_SYNTAX_ERROR, // Syntax error in IDL input
89 // More details will be gleaned from examining
90 // idl_global->parse_state()
91 EIDL_REDEF, // Redefinition
92 EIDL_REDEF_SCOPE, // Redefinition inside defining scope
93 EIDL_DEF_USE, // Definition after use
94 EIDL_MULTIPLE_BRANCH, // More than one union branch with this label
95 EIDL_COERCION_FAILURE, // Coercion failure
96 EIDL_SCOPE_CONFLICT, // Between fwd declare and full declare
97 EIDL_ONEWAY_CONFLICT, // Between op decl and argument direction
98 EIDL_PREFIX_CONFLICT, // Between prefixes at declaration and use
99 EIDL_ILLEGAL_VERSION, // Bad number in #pragma version statement
100 EIDL_VERSION_RESET, // Can't reset version, even to same number
101 EIDL_ID_RESET, // Tried to set id to a different string
102 EIDL_TYPEID_RESET, // Can't set repo id with 'typeid' twice
103 EIDL_INVALID_TYPEID, // Can't use 'typeid' on this type.
104 EIDL_INVALID_TYPEPREFIX, // Can't use 'typeprefix on this type
105 EIDL_DISC_TYPE, // Illegal discriminator type in union
106 EIDL_LABEL_TYPE, // Mismatch with discriminator type in union
107 EIDL_ILLEGAL_ADD, // Illegal add action
108 EIDL_ILLEGAL_USE, // Illegal type used in expression
109 EIDL_ILLEGAL_RAISES, // Error in "raises" clause
110 EIDL_ILLEGAL_CONTEXT, // Error in "context" clause
111 EIDL_CANT_INHERIT, // Cannot inherit from non-interface
112 EIDL_CANT_SUPPORT, // Cannot support a non-interface
113 EIDL_LOOKUP_ERROR, // Identifier not found
114 EIDL_INHERIT_FWD_ERROR, // Cannot inherit from fwd decl interface
115 EIDL_SUPPORTS_FWD_ERROR, // Cannot support a fwd decl interface
116 EIDL_PRIMARY_KEY_ERROR, // Does not inherit from primaryKeyBase
117 EIDL_CONSTANT_EXPECTED, // We got something else..
118 EIDL_INTERFACE_EXPECTED, // We got something else..
119 EIDL_VALUETYPE_EXPECTED, // We got something else..
120 EIDL_CONCRETE_VT_EXPECTED, // We got something else..
121 EIDL_ABSTRACT_EXPECTED, // We got something else..
122 EIDL_EVENTTYPE_EXPECTED, // We got something else..
123 EIDL_TMPL_MODULE_EXPECTED, // We got something else..
124 EIDL_PORTTYPE_EXPECTED, // We got something else..
125 EIDL_CONNECTOR_EXPECTED, // We got something else..
126 EIDL_TYPEDEF_EXPECTED, // We got something else..
127 EIDL_NAME_CASE_ERROR, // Identifier spellings differ only in case
128 EIDL_NAME_CASE_WARNING, // Same as above, but only a warning
129 EIDL_KEYWORD_ERROR, // Case-insensitive clash with IDL keyword
130 EIDL_KEYWORD_WARNING, // Same as above, but only a warning
131 EIDL_ANONYMOUS_ERROR, // Anonymous types are deprecated by spec
132 EIDL_ANONYMOUS_WARNING, // Same as above, but only a warning
133 EIDL_ANONYMOUS_EXPLICIT_ERROR, // Anonymous types have been explicitly disabled
134 EIDL_ENUM_VAL_EXPECTED, // Expected an enumerator
135 EIDL_ENUM_VAL_NOT_FOUND, // Didnt find an enumerator with that name
136 EIDL_EVAL_ERROR, // Error in evaluating expression
137 EIDL_INCOMPATIBLE_TYPE, // Assign floating pt. to int or vice versa
138 EIDL_AMBIGUOUS, // Ambiguous name definition
139 EIDL_DECL_NOT_DEFINED, // Forward declared but never defined
140 EIDL_FWD_DECL_LOOKUP, // Tried to lookup in fwd declared intf
141 EIDL_RECURSIVE_TYPE, // Illegal recursive use of type
142 EIDL_NONVOID_ONEWAY, // Non-void return type in oneway operation
143 EIDL_NOT_A_TYPE, // Not a type
144 EIDL_UNDERSCORE, // More than one leading underscore
145 EIDL_EMPTY_MODULE, // Empty modules not allowed in IDL.
146 EIDL_BACK_END, // Back end error
147 EIDL_ILLEGAL_INFIX, // Illegal infix operator in expression
148 EIDL_LOCAL_REMOTE_MISMATCH, // Local type used in remote operation
149 EIDL_IGNORE_IDL3_ERROR, // -Sm option used with component or home decl
150 EIDL_TC_SUPPRESSION_WARNING,// -St option used with exception decl
151 EIDL_ILLEGAL_BOXED_TYPE, // Valuetype not allowed for box value type
152 EIDL_ILLEGAL_PRIMARY_KEY, // Primary key doesn't meet spec constraints
153 EIDL_MISMATCHED_T_PARAM, // Between def'd & ref'd template interfaces
154 EIDL_DUPLICATE_T_PARAM, // A tmpl module's param ids must be unique
155 EIDL_T_ARG_LENGTH, // Wrong # of template args
156 EIDL_MISMATCHED_SEQ_PARAM, // 'sequence<T>' must match a previous param
157 EIDL_TEMPLATE_NOT_ALIASED, // ref to tmpl module scope must be via alias
158 EIDL_FIXED_UNSUPPORTED, // fixed data type is not supported
159 EIDL_IDL_VERSION_ERROR, // An error related to differences in IDL version
160 EIDL_UNSUPPORTED, // Unsupported feature was used in input IDL
161 EIDL_ANNOTATION_PARAM_ERROR, // Error in Annotation Parameters
162 EIDL_MISC, // Very Specific Error or Warning
163 EIDL_OK // No error
166 ErrorCode last_error;
167 long last_error_lineno;
168 ErrorCode last_warning;
169 long last_warning_lineno;
171 // Operations
173 // Report errors with varying numbers of arguments
174 void error0 (ErrorCode e);
175 void error1 (ErrorCode e,
176 AST_Decl *t);
177 void error2 (ErrorCode e,
178 AST_Decl *t1,
179 AST_Decl *t2);
180 void error3 (ErrorCode e,
181 AST_Decl *t1,
182 AST_Decl *t2,
183 AST_Decl *t3);
185 // Report warnings with varying numbers of arguments
186 void warning0 (ErrorCode e);
187 void warning1 (ErrorCode e,
188 AST_Decl *t);
189 void warning2 (ErrorCode e,
190 AST_Decl *t1,
191 AST_Decl *t2);
192 void warning3 (ErrorCode e,
193 AST_Decl *t1,
194 AST_Decl *t2,
195 AST_Decl *t3);
198 * Report an error that can be out of context of IDL parsing.
200 void direct_error (
201 const char *reason, const ACE_CString &filename, long lineno,
202 ErrorCode error_code = EIDL_MISC);
205 * Report an warning that can be out of context of IDL parsing.
207 void direct_warning (
208 const char *reason, const ACE_CString &filename, long lineno,
209 ErrorCode error_code = EIDL_MISC);
211 // Report a syntax error in IDL input
212 void syntax_error (IDL_GlobalData::ParseState ps);
214 // Report clash of declared and referenced identifiers
215 void redef_error (const char *n, const char *t);
217 // Report a name being used with different spellings
218 void name_case_error (char *n,
219 char *t);
221 // Same as above, but doesn't increment the error count.
222 void name_case_warning (char *n,
223 char *t);
225 // Differs from spelling of IDL keyword only by case.
226 void idl_keyword_error (char *n);
228 // Same as above, but doesn't increment the error count.
229 void idl_keyword_warning (char *n);
231 // Report an unsuccessful coercion attempt
232 void coercion_error (AST_Expression *v,
233 AST_Expression::ExprType t);
235 // Report a failed name lookup attempt.
236 void lookup_error (UTL_ScopedName *n);
238 /// Report a failed name lookup attempt as a warning.
239 void lookup_warning (UTL_ScopedName *n);
241 // Report an illegal #pragma version.
242 void version_number_error (char *n);
244 // Report an illegal #pragma version syntax
245 void version_syntax_error (const char *msg);
247 // Repost an attempt to reset the version.
248 void version_reset_error ();
250 // Report an attempt to change the id once set.
251 void id_reset_error (const char *o,
252 const char *n);
254 // Report an attempt to use a forward declared interface which
255 // hasn't been defined yet in an inheritance spec
256 void inheritance_fwd_error (UTL_ScopedName *n,
257 AST_Interface *f);
259 // Report an attempt to inherit from something other than an interface
260 void inheritance_error (UTL_ScopedName *n,
261 AST_Decl *d);
263 // Report an attempt to use a forward declared interface which
264 // hasn't been defined yet in an inheritance spec
265 void supports_fwd_error (UTL_ScopedName *n,
266 AST_Interface *f);
268 // Report an attempt to support something other than an interface
269 void supports_error (UTL_ScopedName *n,
270 AST_Decl *d);
272 // Report an attempt to illegally inherit from an abstract type.
273 void abstract_inheritance_error (UTL_ScopedName *v,
274 UTL_ScopedName *i);
276 // Report an attempt to support more then one concrete type.
277 void abstract_support_error (UTL_ScopedName *v,
278 UTL_ScopedName *i);
280 // Report a situation where a non-local interface was expected but we got
281 // something else instead. This most likely is a case in a supports
282 // or inheritance list.
283 void unconstrained_interface_expected (UTL_ScopedName *c,
284 UTL_ScopedName *i);
286 // A concrete supported interface must inherit from all concrete
287 // interfaces supported by the valuetype's ancestors, and all of
288 // those concrete interfaces' ancestors.
289 void concrete_supported_inheritance_error (UTL_ScopedName *v,
290 UTL_ScopedName *i);
292 // Report an error while evaluating an expression (division by zero, etc.)
293 void eval_error (AST_Expression *d);
295 // Report incompatible types in constant assignment
296 void incompatible_type_error (AST_Expression *d);
298 // Report incompatible types in discriminator vs label.
299 void incompatible_disc_error (AST_Decl *d,
300 AST_Expression *e);
302 // Report a situation where a constant was expected but we got
303 // something else instead. This most likely is a case where a union
304 // label did not evaluate to a constant
305 void constant_expected (UTL_ScopedName *n,
306 AST_Decl *d);
308 // Report a situation where an interface was expected but we got
309 // something else instead. This most likely is a case in a supports
310 // or inheritance list.
311 void interface_expected (AST_Decl *d);
313 // Report a situation where a template module was expected but we got
314 // something else instead. This most likely is a case in a template
315 // module instantiation or alias.
316 void template_module_expected (AST_Decl *d);
318 // Report a situation where a value type was expected but we got
319 // something else instead. This most likely is a case in a primary
320 // key, emits, publishes or consumes declaration.
321 void valuetype_expected (AST_Decl *d);
323 // Report a situation where a concrete value type was expected but we got
324 // something else instead. This most likely is a case where a valuetype
325 // inherits from something other than a concrete valuetype.
326 void concrete_valuetype_expected (AST_Decl *d);
328 // Report a situation where an abstract type was expected but we got
329 // something else instead. This is the case in an inheritance
330 // list where a concrete type appears after an abstract type, or
331 // where a valuetype inherits more than one concrete valuetype.
332 void abstract_expected (AST_Decl *d);
334 // Report a situation where an event type was expected but we got
335 // something else instead. This is the case in an 'emits', 'publishes',
336 // or 'consumes' declaration in a component and it's not an event type.
337 void eventtype_expected (AST_Decl *d);
339 // Report a situation where a valuetype used as a primary key for a
340 // component home does not inherit directly or indirectly from
341 // Components::primaryKeyBase.
342 void primary_key_error (AST_Decl *d);
344 // Report a situation where an enumerator was expected but we got
345 // something else instead. This occurs when a union with an enum
346 // discriminator is being parsed and one of the branch labels is
347 // not an enumerator in that enum
348 void enum_val_expected (AST_Union *t,
349 AST_UnionLabel *l);
351 // Report a failed enumerator lookup in an enum
352 void enum_val_lookup_failure (AST_Union *t,
353 AST_Enum *e,
354 UTL_ScopedName *n);
356 // Report an ambiguous name definition
357 void ambiguous (UTL_Scope *s,
358 AST_Decl *l,
359 AST_Decl *d);
361 // Report a forward declared interface which was never defined
362 void fwd_decl_not_defined (AST_Type *d);
364 // Report attempt to lookup in forward declared interface
365 void fwd_decl_lookup (AST_Interface *d,
366 UTL_ScopedName *n);
368 // Report a redefinition in scope
369 void redefinition_in_scope (AST_Decl *t,
370 AST_Decl *s);
372 // Report not a type error
373 void not_a_type (AST_Decl *d);
375 // Fixed data type is not supported
376 void fixed_unsupported (AST_Fixed *f);
378 // Report back-end error
379 void back_end (long lineno,
380 UTL_String *s);
382 // Report illegal infix operator error (they can be used
383 // only with integer, floating point or fixed point expressions.
384 void illegal_infix ();
386 // Report local type used in remote operation.
387 void local_remote_mismatch (AST_Decl *l,
388 UTL_Scope *s);
390 // Improper use of -Sm option.
391 void ignore_idl3_error (AST_Decl *d);
393 // Valuetype violates a spec-defined constraint on a
394 // valuetype used as a primary key.
395 void illegal_primary_key (AST_Decl *d);
397 // Template parameter was repeated.
398 void duplicate_param_id (UTL_ScopedName *n);
400 // Referenced template parameter not matched in param list.
401 void mismatched_template_param (const char *name);
403 // Given a template param of the form 'sequence<T>', the
404 // 'T' must match a previous param in the list.
405 void mismatch_seq_of_param (const char *param_id);
407 // Informative message when a lookup fails because a
408 // masking scope has not been correctly differentiated
409 // in the scoped name from the scope it masks.
410 void scope_masking_error (AST_Decl *masked,
411 AST_Decl *loc);
413 // Error (default) or warning (set by command line option).
414 void anonymous_type_diagnostic ();
416 // Reference to an item in the scope of a template
417 // module was not via an alias.
418 void template_scope_ref_not_aliased (AST_Decl *d);
421 * Report IDL version error, with a given reason.
423 void idl_version_error (const char *reason);
426 * Warn about an unsupported feature in the input IDL that can be ignored for
427 * the most part.
429 void unsupported_warning (const char *reason);
432 * Report an unsupported feature in the input IDL that can't be ignored.
434 void unsupported_error (const char *reason);
437 * Report a error for a specific situation
439 * If node is not defined the current file and line are reported.
441 void misc_error (const char *reason, AST_Decl *node = 0);
444 * Report a warning for a specific situation
446 * If node is not defined the current file and line are reported.
448 void misc_warning (const char *reason, AST_Decl *node = 0);
451 * Report that an invalid annotation parameter was passed
453 void invalid_annotation_param_error (
454 AST_Annotation_Appl *appl, AST_Annotation_Decl *decl,
455 Identifier *invalid_id);
458 * Report that an annotation parameter has an invalid type
460 void invalid_annotation_param_type (
461 AST_Annotation_Appl *appl, AST_Annotation_Member *member,
462 AST_Expression *offending_value);
465 * Report that an annotation parameter needs to be defined
467 void annotation_param_missing_error (
468 AST_Annotation_Appl *appl, AST_Annotation_Member *member);
470 /// Reset recent warning and error information
471 void reset_last_error_and_warning ();
474 #endif // _UTL_ERR_UTL_ERR_HH