GnuCOBOL  2.0
A free COBOL compiler
error.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include "cobc.h"
#include "tree.h"
Include dependency graph for error.c:

Go to the source code of this file.

Functions

static void print_error (const char *file, int line, const char *prefix, const char *fmt, va_list ap)
 
void cb_warning (const char *fmt,...)
 
void cb_error (const char *fmt,...)
 
void cb_plex_warning (const size_t sline, const char *fmt,...)
 
void cb_plex_error (const size_t sline, const char *fmt,...)
 
void configuration_warning (const char *fname, const int line, const char *fmt,...)
 
void configuration_error (const char *fname, const int line, const int finish_error, const char *fmt,...)
 
void cb_warning_x (cb_tree x, const char *fmt,...)
 
void cb_error_x (cb_tree x, const char *fmt,...)
 
unsigned int cb_verify (const enum cb_support tag, const char *feature)
 
void redefinition_error (cb_tree x)
 
void redefinition_warning (cb_tree x, cb_tree y)
 
void undefined_error (cb_tree x)
 
void ambiguous_error (cb_tree x)
 
void group_error (cb_tree x, const char *clause)
 
void level_redundant_error (cb_tree x, const char *clause)
 
void level_require_error (cb_tree x, const char *clause)
 
void level_except_error (cb_tree x, const char *clause)
 

Variables

static char * errnamebuff = ((void*)0)
 
static struct cb_labellast_section = ((void*)0)
 
static struct cb_labellast_paragraph = ((void*)0)
 
static int conf_error_displayed = 0
 
static int last_error_line = 0
 
static const char * last_error_file = "Unknown"
 
size_t cb_msg_style
 

Function Documentation

void ambiguous_error ( cb_tree  x)

Definition at line 341 of file error.c.

References _, CB_CHAIN, cb_error_x(), CB_FIELD, CB_LABEL, cb_name(), CB_NAME, CB_REFERENCE, CB_TAG_FIELD, CB_TAG_LABEL, CB_TREE, CB_TREE_TAG, CB_VALUE, COB_NORMAL_BUFF, COB_NORMAL_MAX, cobc_main_malloc(), errnamebuff, cb_word::error, cb_word::items, cb_label::name, cb_word::name, cb_field::parent, and cb_label::section.

Referenced by cb_ref().

342 {
343  struct cb_word *w;
344  struct cb_field *p;
345  struct cb_label *l2;
346  cb_tree l;
347  cb_tree y;
348 
349  w = CB_REFERENCE (x)->word;
350  if (w->error == 0) {
351  if (!errnamebuff) {
353  }
354  /* Display error the first time */
355  snprintf (errnamebuff, (size_t)COB_NORMAL_MAX, "'%s'", CB_NAME (x));
357  for (l = CB_REFERENCE (x)->chain; l; l = CB_REFERENCE (l)->chain) {
358  strcat (errnamebuff, " in '");
359  strcat (errnamebuff, CB_NAME (l));
360  strcat (errnamebuff, "'");
361  }
362  cb_error_x (x, _("%s ambiguous; need qualification"), errnamebuff);
363  w->error = 1;
364 
365  /* Display all fields with the same name */
366  for (l = w->items; l; l = CB_CHAIN (l)) {
367  y = CB_VALUE (l);
368  snprintf (errnamebuff, (size_t)COB_NORMAL_MAX,
369  "'%s' ", w->name);
371  switch (CB_TREE_TAG (y)) {
372  case CB_TAG_FIELD:
373  for (p = CB_FIELD (y)->parent; p; p = p->parent) {
374  strcat (errnamebuff, "in '");
375  strcat (errnamebuff, cb_name (CB_TREE(p)));
376  strcat (errnamebuff, "' ");
377  }
378  break;
379  case CB_TAG_LABEL:
380  l2 = CB_LABEL (y);
381  if (l2->section) {
382  strcat (errnamebuff, "in '");
383  strcat (errnamebuff,
384  (const char *)(l2->section->name));
385  strcat (errnamebuff, "' ");
386  }
387  break;
388  default:
389  break;
390  }
391  strcat (errnamebuff, _("defined here"));
392  cb_error_x (y, errnamebuff);
393  }
394  }
395 }
#define CB_TREE(x)
Definition: tree.h:440
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_LABEL(x)
Definition: tree.h:801
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
const char * name
Definition: tree.h:766
#define COB_NORMAL_BUFF
Definition: common.h:541
char * cb_name(cb_tree x)
Definition: tree.c:735
#define CB_VALUE(x)
Definition: tree.h:1193
const char * name
Definition: tree.h:865
struct cb_label * section
Definition: tree.h:768
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643
#define CB_CHAIN(x)
Definition: tree.h:1194
#define CB_TREE_TAG(x)
Definition: tree.h:441
int error
Definition: tree.h:868
#define CB_NAME(x)
Definition: tree.h:904
#define CB_REFERENCE(x)
Definition: tree.h:901
#define COB_NORMAL_MAX
Definition: common.h:547
cb_tree items
Definition: tree.h:866
struct cb_field * parent
Definition: tree.h:651
static char * errnamebuff
Definition: error.c:34
Definition: tree.h:764
Definition: tree.h:863
#define CB_FIELD(x)
Definition: tree.h:740

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_error ( const char *  fmt,
  ... 
)

Definition at line 98 of file error.c.

References _, cobc_cs_check, cobc_in_repository, cobc_too_many_errors(), errorcount, NULL, and print_error().

Referenced by build_evaluate(), cb_build_const_length(), cb_build_locale_name(), cb_build_picture(), cb_expr_finish(), cb_get_int(), cb_get_long_long(), cb_get_u_long_long(), cb_validate_program_data(), cb_verify(), check_not_88_level(), check_not_both(), check_relaxed_syntax(), cobc_error_name(), decrement_depth(), emit_conflicting_clause_message(), emit_default_displays_for_x_list(), emit_duplicate_clause_message(), error_if_no_advancing_in_screen_display(), error_literal(), error_numeric_literal(), finalize_file(), increment_depth(), lookup_reserved_word(), make_intrinsic(), ppcopy(), pplex(), ppopen(), ppp_define_add(), ppparse(), scan_define_options(), set_up_use_file(), valid_format(), valid_screen_pos(), yylex(), and yyparse().

99 {
100  va_list ap;
101 
102  cobc_in_repository = 0;
103 #if 0 /* RXWRXW - Is this right? */
104  cobc_cs_check = 0;
105 #endif
106  va_start (ap, fmt);
107  print_error (NULL, 0, _("Error: "), fmt, ap);
108  va_end (ap);
109  if (++errorcount > 100) {
111  }
112 }
unsigned int cobc_in_repository
Definition: parser.c:180
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
unsigned int cobc_cs_check
Definition: parser.c:182
void cobc_too_many_errors(void)
Definition: cobc.c:599
int errorcount
Definition: cobc.c:173
static void print_error(const char *file, int line, const char *prefix, const char *fmt, va_list ap)
Definition: error.c:46

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_error_x ( cb_tree  x,
const char *  fmt,
  ... 
)

Definition at line 233 of file error.c.

References _, cobc_too_many_errors(), errorcount, print_error(), cb_tree_common::source_file, and cb_tree_common::source_line.

Referenced by ambiguous_error(), begin_scope_of_program_name(), cb_build_address(), cb_build_binary_op(), cb_build_cond(), cb_build_display_mnemonic(), cb_build_display_name(), cb_build_field_tree(), cb_build_identifier(), cb_build_intrinsic(), cb_build_replacing_characters(), cb_build_tallying_all(), cb_build_tallying_characters(), cb_build_tallying_leading(), cb_build_tallying_trailing(), cb_build_tallying_value(), cb_build_write_advancing_mnemonic(), cb_check_group_name(), cb_check_integer_value(), cb_check_numeric_edited_name(), cb_check_numeric_name(), cb_check_numeric_value(), cb_concat_literals(), cb_define_switch_name(), cb_emit_accept(), cb_emit_accept_mnemonic(), cb_emit_accept_name(), cb_emit_allocate(), cb_emit_call(), cb_emit_close(), cb_emit_delete(), cb_emit_delete_file(), cb_emit_display(), cb_emit_free(), cb_emit_goto(), cb_emit_initialize(), cb_emit_inspect(), cb_emit_move(), cb_emit_open(), cb_emit_read(), cb_emit_release(), cb_emit_rewrite(), cb_emit_set_attribute(), cb_emit_set_false(), cb_emit_set_to(), cb_emit_set_true(), cb_emit_sort_giving(), cb_emit_sort_init(), cb_emit_sort_using(), cb_emit_start(), cb_emit_write(), cb_expr_finish(), cb_get_level(), cb_resolve_redefines(), cb_validate_88_item(), cb_validate_collating(), cb_validate_one(), cb_validate_program_body(), cb_validate_program_data(), cb_validate_program_environment(), check_for_duplicate_prototype(), check_picture_item(), check_valid_key(), compute_size(), emit_entry(), evaluate_test(), file_error(), group_error(), level_except_error(), level_redundant_error(), level_require_error(), redefinition_error(), search_set_keys(), terminator_error(), undefined_error(), valid_const_date_time_args(), validate_field_1(), validate_field_clauses(), validate_inspect(), validate_move(), warn_cannot_get_utc(), and yyparse().

234 {
235  va_list ap;
236 
237  va_start (ap, fmt);
238  print_error (x->source_file, x->source_line, _("Error: "), fmt, ap);
239  va_end (ap);
240  if (++errorcount > 100) {
242  }
243 }
const char * source_file
Definition: tree.h:431
int source_line
Definition: tree.h:432
#define _(s)
Definition: cobcrun.c:59
void cobc_too_many_errors(void)
Definition: cobc.c:599
int errorcount
Definition: cobc.c:173
static void print_error(const char *file, int line, const char *prefix, const char *fmt, va_list ap)
Definition: error.c:46

Here is the call graph for this function:

void cb_plex_error ( const size_t  sline,
const char *  fmt,
  ... 
)

Definition at line 130 of file error.c.

References _, cb_source_line, cobc_too_many_errors(), errorcount, NULL, and print_error().

Referenced by plex_action_directive(), ppinput(), and ppparse_error().

131 {
132  va_list ap;
133 
134  va_start (ap, fmt);
135  print_error (NULL, (int)(cb_source_line + sline), _("Error: "), fmt, ap);
136  va_end (ap);
137  if (++errorcount > 100) {
139  }
140 }
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
int cb_source_line
Definition: cobc.c:178
void cobc_too_many_errors(void)
Definition: cobc.c:599
int errorcount
Definition: cobc.c:173
static void print_error(const char *file, int line, const char *prefix, const char *fmt, va_list ap)
Definition: error.c:46

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_plex_warning ( const size_t  sline,
const char *  fmt,
  ... 
)

Definition at line 119 of file error.c.

References _, cb_source_line, NULL, print_error(), and warningcount.

Referenced by ppinput(), and pplex().

120 {
121  va_list ap;
122 
123  va_start (ap, fmt);
124  print_error (NULL, (int)(cb_source_line + sline), _("Warning: "), fmt, ap);
125  va_end (ap);
126  warningcount++;
127 }
int warningcount
Definition: cobc.c:174
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
int cb_source_line
Definition: cobc.c:178
static void print_error(const char *file, int line, const char *prefix, const char *fmt, va_list ap)
Definition: error.c:46

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int cb_verify ( const enum cb_support  tag,
const char *  feature 
)

Definition at line 246 of file error.c.

References _, CB_ARCHAIC, cb_error(), CB_ERROR, CB_IGNORE, CB_OBSOLETE, CB_OK, CB_SKIP, CB_UNCONFORMABLE, cb_warning(), CB_WARNING, and warningopt.

Referenced by cb_emit_goto(), check_comments(), compute_size(), ppinput(), pplex(), scan_b(), scan_h(), scan_o(), validate_field_1(), and yyparse().

247 {
248  switch (tag) {
249  case CB_OK:
250  return 1;
251  case CB_WARNING:
252  cb_warning (_("%s used"), feature);
253  return 1;
254  case CB_ARCHAIC:
255  if (cb_warn_archaic) {
256  cb_warning (_("%s is archaic in %s"), feature, cb_config_name);
257  }
258  return 1;
259  case CB_OBSOLETE:
260  if (cb_warn_obsolete) {
261  cb_warning (_("%s is obsolete in %s"), feature, cb_config_name);
262  }
263  return 1;
264  case CB_SKIP:
265  return 0;
266  case CB_IGNORE:
267  if (warningopt) {
268  cb_warning (_("%s ignored"), feature);
269  }
270  return 0;
271  case CB_ERROR:
272  cb_error (_("%s used"), feature);
273  return 0;
274  case CB_UNCONFORMABLE:
275  cb_error (_("%s does not conform to %s"), feature, cb_config_name);
276  return 0;
277  default:
278  break;
279  }
280  return 0;
281 }
Definition: cobc.h:139
Definition: cobc.h:141
int warningopt
Definition: cobc.c:176
Definition: cobc.h:135
#define _(s)
Definition: cobcrun.c:59
void cb_error(const char *fmt,...)
Definition: error.c:98
void cb_warning(const char *fmt,...)
Definition: error.c:87

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_warning ( const char *  fmt,
  ... 
)

Definition at line 87 of file error.c.

References _, NULL, print_error(), and warningcount.

Referenced by begin_statement(), cb_build_assignment_name(), cb_emit_call(), cb_emit_read(), cb_validate_program_data(), cb_verify(), check_relaxed_syntax(), emit_conflicting_clause_message(), emit_duplicate_clause_message(), emit_entry(), expr_reduce(), ppp_compare_vals(), ppparse(), read_literal(), warning_destination(), yylex(), and yyparse().

88 {
89  va_list ap;
90 
91  va_start (ap, fmt);
92  print_error (NULL, 0, _("Warning: "), fmt, ap);
93  va_end (ap);
94  warningcount++;
95 }
int warningcount
Definition: cobc.c:174
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static void print_error(const char *file, int line, const char *prefix, const char *fmt, va_list ap)
Definition: error.c:46

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_warning_x ( cb_tree  x,
const char *  fmt,
  ... 
)

Definition at line 222 of file error.c.

References _, print_error(), cb_tree_common::source_file, cb_tree_common::source_line, and warningcount.

Referenced by cb_build_address(), cb_build_display_name(), cb_build_field_tree(), cb_build_identifier(), cb_check_overlapping(), cb_emit_accept_name(), cb_emit_call(), cb_emit_corresponding(), cb_emit_move_corresponding(), cb_validate_program_body(), cb_validate_program_environment(), check_for_duplicate_prototype(), check_picture_item(), check_prototype_redefines_current_func(), check_prototype_seen(), compute_size(), move_warning(), redefinition_warning(), terminator_warning(), undefined_error(), valid_const_date_time_args(), validate_field_1(), validate_move(), warn_cannot_get_utc(), warning_destination(), and yyparse().

223 {
224  va_list ap;
225 
226  va_start (ap, fmt);
227  print_error (x->source_file, x->source_line, _("Warning: "), fmt, ap);
228  va_end (ap);
229  warningcount++;
230 }
int warningcount
Definition: cobc.c:174
const char * source_file
Definition: tree.h:431
int source_line
Definition: tree.h:432
#define _(s)
Definition: cobcrun.c:59
static void print_error(const char *file, int line, const char *prefix, const char *fmt, va_list ap)
Definition: error.c:46

Here is the call graph for this function:

Here is the caller graph for this function:

void configuration_error ( const char *  fname,
const int  line,
const int  finish_error,
const char *  fmt,
  ... 
)

Definition at line 178 of file error.c.

References _, conf_error_displayed, last_error_file, last_error_line, and line.

Referenced by cb_config_entry(), cb_load_conf(), cb_load_conf_file(), get_user_specified_reserved_word(), invalid_value(), and unsupported_value().

179 {
180  va_list args;
181 
182  if (!conf_error_displayed) {
184  fputs (_("Configuration Error"), stderr);
185  putc ('\n', stderr);
186  }
187 
188 
189  /* Prefix */
190  if (fname != last_error_file
191  || line != last_error_line) {
192  last_error_file = fname;
194  if (fname) {
195  fprintf (stderr, "%s: ", fname);
196  } else {
197  fputs ("cb_conf: ", stderr);
198  }
199  if (line) {
200  fprintf (stderr, "%d: ", line);
201  }
202  }
203 
204  /* Body */
205  va_start(args, fmt);
206  vfprintf (stderr, fmt, args);
207  va_end(args);
208 
209  /* Postfix */
210  if (!finish_error) {
211  putc(';', stderr);
212  putc('\n', stderr);
213  putc('\t', stderr);
214  } else {
215  putc('\n', stderr);
216  fflush(stderr);
217  }
218 }
static int conf_error_displayed
Definition: error.c:38
#define _(s)
Definition: cobcrun.c:59
static int last_error_line
Definition: error.c:39
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
static const char * last_error_file
Definition: error.c:40

Here is the caller graph for this function:

void configuration_warning ( const char *  fname,
const int  line,
const char *  fmt,
  ... 
)

Definition at line 144 of file error.c.

References _, conf_error_displayed, last_error_file, last_error_line, and line.

Referenced by cb_load_conf(), and initialize_alias_for().

145 {
146  va_list args;
147 
149  fputs (_("Configuration Warning"), stderr);
150  fputs (": ", stderr);
151 
152 
153  /* Prefix */
154  if (fname != last_error_file
155  || line != last_error_line) {
156  last_error_file = fname;
158  if (fname) {
159  fprintf (stderr, "%s: ", fname);
160  } else {
161  fputs ("cb_conf: ", stderr);
162  }
163  if (line) {
164  fprintf (stderr, "%d: ", line);
165  }
166  }
167 
168  /* Body */
169  va_start(args, fmt);
170  vfprintf (stderr, fmt, args);
171  va_end(args);
172 
173  /* Postfix */
174  putc('\n', stderr);
175  fflush(stderr);
176 }
static int conf_error_displayed
Definition: error.c:38
#define _(s)
Definition: cobcrun.c:59
static int last_error_line
Definition: error.c:39
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
static const char * last_error_file
Definition: error.c:40

Here is the caller graph for this function:

void group_error ( cb_tree  x,
const char *  clause 
)

Definition at line 398 of file error.c.

References _, cb_error_x(), and cb_name().

Referenced by validate_field_1().

399 {
400  cb_error_x (x, _("Group item '%s' cannot have %s clause"),
401  cb_name (x), clause);
402 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
char * cb_name(cb_tree x)
Definition: tree.c:735
#define _(s)
Definition: cobcrun.c:59

Here is the call graph for this function:

Here is the caller graph for this function:

void level_except_error ( cb_tree  x,
const char *  clause 
)

Definition at line 441 of file error.c.

References _, cb_error_x(), CB_FIELD_PTR, cb_name(), cb_field::flag_item_78, and cb_field::level.

Referenced by cb_validate_78_item(), cb_validate_88_item(), and validate_field_1().

442 {
443  const char *s;
444  const struct cb_field *f;
445 
446  s = cb_name (x);
447  f = CB_FIELD_PTR (x);
448  if (f->flag_item_78) {
449  cb_error_x (x, _("Constant item '%s' can only have a %s clause"),
450  s, clause);
451  } else {
452  cb_error_x (x, _("Level %02d item '%s' can only have a %s clause"),
453  f->level,
454  s, clause);
455  }
456 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_FIELD_PTR(x)
Definition: tree.h:745
char * cb_name(cb_tree x)
Definition: tree.c:735
int level
Definition: tree.h:673
unsigned int flag_item_78
Definition: tree.h:711
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643

Here is the call graph for this function:

Here is the caller graph for this function:

void level_redundant_error ( cb_tree  x,
const char *  clause 
)

Definition at line 405 of file error.c.

References _, cb_error_x(), CB_FIELD_PTR, cb_name(), cb_field::flag_item_78, and cb_field::level.

Referenced by validate_field_1().

406 {
407  const char *s;
408  const struct cb_field *f;
409 
410  s = cb_name (x);
411  f = CB_FIELD_PTR (x);
412  if (f->flag_item_78) {
413  cb_error_x (x, _("Constant item '%s' cannot have a %s clause"),
414  s, clause);
415  } else {
416  cb_error_x (x, _("Level %02d item '%s' cannot have a %s clause"),
417  f->level,
418  s, clause);
419  }
420 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_FIELD_PTR(x)
Definition: tree.h:745
char * cb_name(cb_tree x)
Definition: tree.c:735
int level
Definition: tree.h:673
unsigned int flag_item_78
Definition: tree.h:711
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643

Here is the call graph for this function:

Here is the caller graph for this function:

void level_require_error ( cb_tree  x,
const char *  clause 
)

Definition at line 423 of file error.c.

References _, cb_error_x(), CB_FIELD_PTR, cb_name(), cb_field::flag_item_78, and cb_field::level.

Referenced by cb_validate_78_item(), cb_validate_88_item(), check_picture_item(), and validate_field_1().

424 {
425  const char *s;
426  const struct cb_field *f;
427 
428  s = cb_name (x);
429  f = CB_FIELD_PTR (x);
430  if (f->flag_item_78) {
431  cb_error_x (x, _("Constant item '%s' requires a %s clause"),
432  s, clause);
433  } else {
434  cb_error_x (x, _("Level %02d item '%s' requires a %s clause"),
435  f->level,
436  s, clause);
437  }
438 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_FIELD_PTR(x)
Definition: tree.h:745
char * cb_name(cb_tree x)
Definition: tree.c:735
int level
Definition: tree.h:673
unsigned int flag_item_78
Definition: tree.h:711
#define _(s)
Definition: cobcrun.c:59
Definition: tree.h:643

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_error ( const char *  file,
int  line,
const char *  prefix,
const char *  fmt,
va_list  ap 
)
static

Definition at line 46 of file error.c.

References _, cb_msg_style, CB_MSG_STYLE_MSC, cb_source_file, cb_source_line, current_paragraph, current_section, cb_label::flag_dummy_paragraph, cb_label::flag_dummy_section, and cb_label::name.

Referenced by cb_error(), cb_error_x(), cb_plex_error(), cb_plex_warning(), cb_warning(), and cb_warning_x().

48 {
49  if (!file) {
51  }
52  if (!line) {
54  }
55 
56  /* Print section and/or paragraph name */
59  fprintf (stderr, "%s: ", file);
60  fputs (_("In section"), stderr);
61  fprintf (stderr, " '%s':\n",
62  (char *)current_section->name);
63  }
65  }
68  fprintf (stderr, "%s: ", file);
69  fputs (_("In paragraph"), stderr);
70  fprintf (stderr, " '%s':\n",
71  (char *)current_paragraph->name);
72  }
74  }
75 
76  /* Print the error */
78  fprintf (stderr, "%s (%d): %s", file, line, prefix);
79  } else {
80  fprintf (stderr, "%s: %d: %s", file, line, prefix);
81  }
82  vfprintf (stderr, fmt, ap);
83  putc ('\n', stderr);
84 }
const char * name
Definition: tree.h:766
const char * cb_source_file
Definition: cobc.c:145
static struct cb_label * last_section
Definition: error.c:35
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax write single recursive relax optional file
Definition: flag.def:129
unsigned int flag_dummy_paragraph
Definition: tree.h:788
#define _(s)
Definition: cobcrun.c:59
static const char *const prefix[]
Definition: fileio.c:262
#define CB_MSG_STYLE_MSC
Definition: cobc.h:436
static struct cb_label * last_paragraph
Definition: error.c:36
struct cb_label * current_paragraph
Definition: parser.c:171
size_t cb_msg_style
Definition: error.c:43
if fold fold static computed alternate extra correct stack on syntax debugging line
Definition: flag.def:90
int cb_source_line
Definition: cobc.c:178
struct cb_label * current_section
Definition: parser.c:170
unsigned int flag_dummy_section
Definition: tree.h:787

Here is the caller graph for this function:

void redefinition_error ( cb_tree  x)

Definition at line 284 of file error.c.

References _, cb_error_x(), CB_REFERENCE, CB_VALUE, cb_word::items, and cb_word::name.

Referenced by cb_build_section_name(), cb_validate_program_data(), check_for_duplicate_prototype(), and yyparse().

285 {
286  struct cb_word *w;
287 
288  w = CB_REFERENCE (x)->word;
289  cb_error_x (x, _("Redefinition of '%s'"), w->name);
290  if (w->items) {
291  cb_error_x (CB_VALUE (w->items),
292  _("'%s' previously defined here"), w->name);
293  }
294 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
#define CB_VALUE(x)
Definition: tree.h:1193
const char * name
Definition: tree.h:865
#define _(s)
Definition: cobcrun.c:59
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree items
Definition: tree.h:866
Definition: tree.h:863

Here is the call graph for this function:

Here is the caller graph for this function:

void redefinition_warning ( cb_tree  x,
cb_tree  y 
)

Definition at line 297 of file error.c.

References _, CB_REFERENCE, CB_VALUE, cb_warning_x(), cb_word::items, cb_word::name, and NULL.

Referenced by cb_build_field_tree().

298 {
299  struct cb_word *w;
300  cb_tree z;
301 
302  w = CB_REFERENCE (x)->word;
303  cb_warning_x (x, _("Redefinition of '%s'"), w->name);
304  z = NULL;
305  if (y) {
306  z = y;
307  } else if (w->items) {
308  z = CB_VALUE (w->items);
309  }
310 
311  if (z) {
312  cb_warning_x (z, _("'%s' previously defined here"), w->name);
313  }
314 }
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
#define CB_VALUE(x)
Definition: tree.h:1193
const char * name
Definition: tree.h:865
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_REFERENCE(x)
Definition: tree.h:901
cb_tree items
Definition: tree.h:866
Definition: tree.h:863

Here is the call graph for this function:

Here is the caller graph for this function:

void undefined_error ( cb_tree  x)

Definition at line 317 of file error.c.

References _, cb_error_x(), CB_NAME, CB_REFERENCE, cb_warning_x(), cb_reference::chain, COB_NORMAL_BUFF, COB_NORMAL_MAX, cobc_main_malloc(), errnamebuff, and cb_reference::flag_optional.

Referenced by cb_ref(), and cb_resolve_redefines().

318 {
319  struct cb_reference *r;
320  cb_tree c;
321 
322  if (!errnamebuff) {
324  }
325  r = CB_REFERENCE (x);
326  snprintf (errnamebuff, (size_t)COB_NORMAL_MAX, "'%s'", CB_NAME (x));
328  for (c = r->chain; c; c = CB_REFERENCE (c)->chain) {
329  strcat (errnamebuff, " in '");
330  strcat (errnamebuff, CB_NAME (c));
331  strcat (errnamebuff, "'");
332  }
333  if (r->flag_optional) {
334  cb_warning_x (x, _("%s is not defined"), errnamebuff);
335  } else {
336  cb_error_x (x, _("%s is not defined"), errnamebuff);
337  }
338 }
void cb_error_x(cb_tree x, const char *fmt,...)
Definition: error.c:233
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
unsigned int flag_optional
Definition: tree.h:896
void cb_warning_x(cb_tree x, const char *fmt,...)
Definition: error.c:222
#define COB_NORMAL_BUFF
Definition: common.h:541
cb_tree chain
Definition: tree.h:875
#define _(s)
Definition: cobcrun.c:59
#define CB_NAME(x)
Definition: tree.h:904
#define CB_REFERENCE(x)
Definition: tree.h:901
#define COB_NORMAL_MAX
Definition: common.h:547
static char * errnamebuff
Definition: error.c:34

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

size_t cb_msg_style

Definition at line 43 of file error.c.

Referenced by cobc_print_info(), main(), and print_error().

int conf_error_displayed = 0
static

Definition at line 38 of file error.c.

Referenced by configuration_error(), and configuration_warning().

char* errnamebuff = ((void*)0)
static

Definition at line 34 of file error.c.

Referenced by ambiguous_error(), and undefined_error().

const char* last_error_file = "Unknown"
static

Definition at line 40 of file error.c.

Referenced by configuration_error(), and configuration_warning().

int last_error_line = 0
static

Definition at line 39 of file error.c.

Referenced by configuration_error(), and configuration_warning().

struct cb_label* last_paragraph = ((void*)0)
static

Definition at line 36 of file error.c.

struct cb_label* last_section = ((void*)0)
static

Definition at line 35 of file error.c.