Branch: Tag:

2008-07-13

2008-07-13 10:49:36 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed bugs in support for aliasing of external constants.

Rev: src/language.yacc:1.443

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: language.yacc,v 1.442 2008/07/08 19:19:33 grubba Exp $ + || $Id: language.yacc,v 1.443 2008/07/13 10:49:36 grubba Exp $   */      %pure_parser
609:    Pike_compiler->compiler_pass=tmp;    }    -  if ((Pike_compiler->current_modifiers & ID_EXTERN) && -  (Pike_compiler->compiler_pass == 1)) { -  yywarning("Extern declared constant."); -  } -  -  if(!is_const($3)) -  { -  /* FIXME: Adding symbols in the second pass is not a good idea. */ -  if(Pike_compiler->compiler_pass==2) { +  if (!TEST_COMPAT(7, 6) && (Pike_compiler->current_modifiers & ID_EXTERN)) {    int depth = 0;    struct program_state *state = Pike_compiler;    node *n = $3;
639:    define_alias($1->u.sval.u.string, n->type,    Pike_compiler->current_modifiers & ~ID_EXTERN,    depth, id); +  } else if (Pike_compiler->compiler_pass == 1) { +  yyerror("Invalid extern declared constant."); +  add_constant($1->u.sval.u.string, &svalue_undefined, +  Pike_compiler->current_modifiers & ~ID_EXTERN); +  }    } else { -  yyerror("Constant definition is not constant."); +  if (TEST_COMPAT(7, 6) && +  (Pike_compiler->current_modifiers & ID_EXTERN) && +  (Pike_compiler->compiler_pass == 1)) { +  yyerror("Extern declared constant.");    } -  } else -  add_constant($1->u.sval.u.string, 0, +  if(!is_const($3)) { +  yyerror("Constant definition is not constant."); +  add_constant($1->u.sval.u.string, &svalue_undefined,    Pike_compiler->current_modifiers & ~ID_EXTERN);    } else {    if(!Pike_compiler->num_parse_error)
663:    Pike_compiler->current_modifiers & ~ID_EXTERN);    pop_stack();    } +  } +  const_def_ok:    if($3) free_node($3);    free_node($1);    }