Commit eb120371 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

there is no such thing as a negative line number in a file (warning reduction).


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent 3ee686ff
......@@ -78,7 +78,7 @@ namespace Common {
yyloc.last_column = 0;
}
void Location::set_location(const char *p_filename, int p_lineno)
void Location::set_location(const char *p_filename, size_t p_lineno)
{
filename = p_filename;
yyloc.first_line = p_lineno;
......@@ -103,8 +103,8 @@ namespace Common {
yyloc.last_column = p_lastloc.last_column;
}
void Location::set_location(const char *p_filename, int p_first_line,
int p_first_column, int p_last_line, int p_last_column)
void Location::set_location(const char *p_filename, size_t p_first_line,
size_t p_first_column, size_t p_last_line, size_t p_last_column)
{
filename = p_filename;
yyloc.first_line = p_first_line;
......
......@@ -39,10 +39,10 @@
#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
size_t first_line;
size_t first_column;
size_t last_line;
size_t last_column;
} YYLTYPE;
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
......@@ -134,7 +134,7 @@ namespace Common {
/** Constructor with filename and just a line number.
* Sets \c yyloc.first_line and \c yyloc.last_line to \p p_lineno,
* and the columns to zero. */
Location(const char *p_filename, int p_lineno=0)
Location(const char *p_filename, size_t p_lineno=0)
{ set_location(p_filename, p_lineno); }
/** Constructor with filename and full location information.
......@@ -162,15 +162,15 @@ namespace Common {
* Stores the filename, and the line/column info in the appropriate
* members of \c yyloc.
*/
Location(const char *p_filename, int p_first_line, int p_first_column,
int p_last_line, int p_last_column)
Location(const char *p_filename, size_t p_first_line, size_t p_first_column,
size_t p_last_line, size_t p_last_column)
{ set_location(p_filename, p_first_line, p_first_column,
p_last_line, p_last_column); }
/** Setter with filename and full location information.
* Copies \p p_yyloc into \p yyloc.
*/
void set_location(const char *p_filename, int p_lineno=0);
void set_location(const char *p_filename, size_t p_lineno=0);
/** Setter with filename and full location information.
* Copies \p p_yyloc into \p yyloc.
*/
......@@ -192,8 +192,8 @@ namespace Common {
* Stores the filename, and the line/column info in the appropriate
* members of \c yyloc.
*/
void set_location(const char *p_filename, int p_first_line,
int p_first_column, int p_last_line, int p_last_column);
void set_location(const char *p_filename, size_t p_first_line,
size_t p_first_column, size_t p_last_line, size_t p_last_column);
/** Copies the stored location information from \a p. */
void set_location(const Location& p) { *this = p; }
......@@ -204,15 +204,15 @@ namespace Common {
/** Returns the attribute filename. */
const char *get_filename() const { return filename; }
/** Returns the line number, for backward compatibility */
int get_lineno() const { return yyloc.first_line; }
size_t get_lineno() const { return yyloc.first_line; }
/** Returns the first line attribute */
int get_first_line() const { return yyloc.first_line; }
size_t get_first_line() const { return yyloc.first_line; }
/** Returns the last line attribute */
int get_last_line() const { return yyloc.last_line; }
size_t get_last_line() const { return yyloc.last_line; }
/** Returns the first column attribute */
int get_first_column() const { return yyloc.first_column; }
size_t get_first_column() const { return yyloc.first_column; }
/** Returns the last column attribute */
int get_last_column() const { return yyloc.last_column; }
size_t get_last_column() const { return yyloc.last_column; }
private:
/** Prints the line/column information stored in \a this into file \a fp.
......
......@@ -9401,14 +9401,14 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
Free(t_filepath);
break; }
case MACRO_LINENUMBER: {
int t_lineno = get_first_line();
size_t t_lineno = get_first_line();
if (t_lineno <= 0)
FATAL_ERROR("Value::evaluate_macro(): line number is not set");
set_val_str(new string(Int2string(t_lineno)));
valuetype = V_CSTR;
break; }
case MACRO_LINENUMBER_C: {
int t_lineno = get_first_line();
size_t t_lineno = get_first_line();
if (t_lineno <= 0)
FATAL_ERROR("Value::evaluate_macro(): line number is not set");
u.val_Int = new int_val_t(t_lineno);
......
......@@ -27,7 +27,7 @@ extern int asn1_yylex();
extern const char *asn1_infile;
extern int asn1_yylineno;
#define yylineno asn1_yylineno
extern int asn1_plineno;
extern size_t asn1_plineno;
#define plineno asn1_plineno
extern YYLTYPE asn1_yylloc;
#define yylloc asn1_yylloc
......
......@@ -66,7 +66,7 @@ extern FILE *asn1_yyin;
#define yyin asn1_yyin
extern int asn1_yylineno;
#define yylineno asn1_yylineno
int asn1_plineno;
size_t asn1_plineno;
#define plineno asn1_plineno
/* copy-paste from xxxxx.yy.cc */
#define YY_BUF_SIZE 16384
......
......@@ -201,7 +201,7 @@ namespace Ttcn {
str = mputstr(str, "TTCN_error(\"None of the branches can be chosen in the "
"interleave statement in file ");
str = Code::translate_string(str, il->get_filename());
int first_line = il->get_first_line(), last_line = il->get_last_line();
size_t first_line = il->get_first_line(), last_line = il->get_last_line();
if (first_line < last_line) str = mputprintf(str,
" between lines %d and %d", first_line, last_line);
else str = mputprintf(str, ", line %d", first_line);
......
......@@ -6755,7 +6755,7 @@ error:
str = mputprintf(str, "if (alt_flag == ALT_NO && default_flag == ALT_NO) "
"TTCN_error(\"Stand-alone %s statement failed in file ", get_stmt_name());
str = Code::translate_string(str, get_filename());
int first_line = get_first_line(), last_line = get_last_line();
size_t first_line = get_first_line(), last_line = get_last_line();
if (first_line < last_line) str = mputprintf(str,
" between lines %d and %d", first_line, last_line);
else str = mputprintf(str, ", line %d", first_line);
......@@ -13572,7 +13572,7 @@ error:
"TTCN_error(\"None of the branches can be chosen in the alt "
"statement in file ", label_str);
str = Code::translate_string(str, loc.get_filename());
int first_line = loc.get_first_line(), last_line = loc.get_last_line();
size_t first_line = loc.get_first_line(), last_line = loc.get_last_line();
if (first_line < last_line) str = mputprintf(str,
" between lines %d and %d", first_line, last_line);
else str = mputprintf(str, ", line %d", first_line);
......@@ -13803,7 +13803,7 @@ error:
str = mputstr(str, ") TTCN_error(\"None of the branches can be chosen in "
"the response and exception handling part of call statement in file ");
str = Code::translate_string(str, loc.get_filename());
int first_line = loc.get_first_line(), last_line = loc.get_last_line();
size_t first_line = loc.get_first_line(), last_line = loc.get_last_line();
if (first_line < last_line) str = mputprintf(str,
" between lines %d and %d", first_line, last_line);
else str = mputprintf(str, ", line %d", first_line);
......
......@@ -1082,7 +1082,7 @@ namespace Ttcn {
}
}
void ParsedActualParameters::set_location(const char *p_filename, int p_lineno)
void ParsedActualParameters::set_location(const char *p_filename, size_t p_lineno)
{
Location ::set_location(p_filename, p_lineno);
if (namedpart)
......@@ -1109,8 +1109,8 @@ namespace Ttcn {
unnamedpart->set_location(p_filename, p_firstloc, p_lastloc);
}
void ParsedActualParameters::set_location(const char *p_filename, int p_first_line,
int p_first_column, int p_last_line, int p_last_column)
void ParsedActualParameters::set_location(const char *p_filename, size_t p_first_line,
size_t p_first_column, size_t p_last_line, size_t p_last_column)
{
Location ::set_location(p_filename, p_first_line, p_first_column,
p_last_line, p_last_column);
......
......@@ -388,12 +388,12 @@ namespace Ttcn {
virtual void set_fullname(const string& p_fullname);
virtual void set_my_scope(Scope *p_scope);
Scope* get_my_scope() const { return my_scope; }
void set_location(const char *p_filename, int p_lineno=0);
void set_location(const char *p_filename, size_t p_lineno=0);
void set_location(const char *p_filename, const YYLTYPE& p_yyloc);
void set_location(const char *p_filename, const YYLTYPE& p_firstloc,
const YYLTYPE& p_lastloc);
void set_location(const char *p_filename, int p_first_line,
int p_first_column, int p_last_line, int p_last_column);
void set_location(const char *p_filename, size_t p_first_line,
size_t p_first_column, size_t p_last_line, size_t p_last_column);
virtual void dump(unsigned int level) const;
// @}
......
......@@ -44,7 +44,7 @@ static void add_char(char*& string_ptr, size_t& string_len,
#define ADD_CHAR(c) add_char(string_ptr, string_len, string_size, c)
#define YY_DECL static string *yylex(const char *current_file, \
int current_line, int current_column)
size_t current_line, size_t current_column)
%}
......
......@@ -48,7 +48,7 @@ extern YYLTYPE yylloc;
const char *coding_attrib_infile;
/** always points to the first character of the regexp to be recognized */
static int current_line, current_column;
static size_t current_line, current_column;
/** the actual size of state condition stack */
static size_t stack_size = 0;
......
......@@ -78,7 +78,7 @@ extern YYLTYPE yylloc;
extern bool is_erroneous_parsed;
/* always points to the first character of the regexp to be recognized */
static int current_line, current_column;
static size_t current_line, current_column;
/* when reporting an error in linemarker or preprocessor
* directive the real file name and line number is needed */
......@@ -204,9 +204,9 @@ TITAN "$#&&&(#TITANERRONEOUS$#&&^#% "
%%
/* local variables of yylex() */
int start_line = 0, start_column = 0; /**< used by block comments and
size_t start_line = 0, start_column = 0; /**< used by block comments and
string literals */
int dot_line = 0, dot_column = 0; /**< location of the previous '.' token */
size_t dot_line = 0, dot_column = 0; /**< location of the previous '.' token */
/* variables used when processing binary strings */
expstring_t binstr = NULL; /**< the string itself */
bool valid_bit = false, /**< binstr is valid bitstring */
......@@ -1162,7 +1162,7 @@ void init_ttcn3_lex()
MD5_Init(&md5_ctx);
}
void init_erroneous_lex(const char* p_infile, int p_line, int p_column)
void init_erroneous_lex(const char* p_infile, size_t p_line, size_t p_column)
{
infile = p_infile;
current_line = p_line;
......
......@@ -99,7 +99,7 @@ extern void init_ttcn3_lex();
extern void free_ttcn3_lex();
extern void set_md5_checksum(Ttcn::Module *m);
extern void init_erroneous_lex(const char* p_infile, int p_line, int p_column);
extern void init_erroneous_lex(const char* p_infile, size_t p_line, size_t p_column);
struct yy_buffer_state;
extern int ttcn3_lex_destroy(void);
extern yy_buffer_state *ttcn3__scan_string(const char *yy_str);
......@@ -11285,7 +11285,7 @@ Ttcn::ErroneousAttributeSpec* ttcn3_parse_erroneous_attr_spec_string(
is_erroneous_parsed = true;
act_ttcn3_erroneous_attr_spec = NULL;
string titan_err_str("$#&&&(#TITANERRONEOUS$#&&^#% ");
int hack_str_len = static_cast<int>(titan_err_str.size());
size_t hack_str_len = titan_err_str.size();
string *parsed_string = parse_charstring_value(p_str, str_loc);
titan_err_str += *parsed_string;
delete parsed_string;
......
......@@ -40,7 +40,7 @@ enum extension_attr_parser_state_t {
};
#define YY_DECL static int yylex(Common::CompTypeRefList*& attr_comp_refs, \
int current_line, int current_column, const char *current_file)
size_t current_line, size_t current_column, const char *current_file)
#define FATAL_ERROR_INVALID_STATE \
FATAL_ERROR("comptype_attr.l: invalid parser state");
......@@ -89,8 +89,8 @@ LINECOMMENT "//"[^\r\n]*{NEWLINE}
%%
Common::Identifier *id=0;
YYLTYPE id_loc;
int start_line = 0;
int start_column = 0;
size_t start_line = 0;
size_t start_column = 0;
extension_attr_parser_state_t parser_state = INITIAL_STATE;
BEGIN(INITIAL);
......
......@@ -123,14 +123,14 @@ if (in_set) {
bool error = false;
Ttcn::Reference *ref = 0;
size_t last = 0; // last "consumed" index into yytext
int old_column = 0, old_line = 0; // the beginning of the entire reference
size_t old_column = 0, old_line = 0; // the beginning of the entire reference
for (size_t i = 0; i < num_id; ++i) {
const string & id_str = *identifiers[i];
const size_t & id_beg = *beginnings [i];
if (Identifier::is_reserved_word(id_str, Identifier::ID_TTCN)) {
UPDATE_LOCATION(last, id_beg); // consume before identifier
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(id_beg, id_beg+id_str.size()); // consume identifier
Location loc(current_file, first_line, first_column, current_line,
current_column); // location covers the identifier
......@@ -199,7 +199,7 @@ if (in_set) {
}
"{"[^}]*"}" {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -218,7 +218,7 @@ if (in_set) {
Identifier::ID_TTCN, id_str));
ps->addRef(ref, TRUE);
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -241,7 +241,7 @@ if (in_set) {
Identifier::ID_TTCN, id_str));
ps->addRef(ref, TRUE);
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -253,7 +253,7 @@ if (in_set) {
}
"\\N"{WS}"{"[^}]*"}" {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -390,7 +390,7 @@ if (in_set) {
}
"\\q"({WS}"{"[^}]*"}")? {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -462,7 +462,7 @@ if (in_set) {
}
"\\"(.|{NEWLINE}) {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -474,7 +474,7 @@ if (in_set) {
}
"#"{WS}[0-9] {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
if (in_set) {
Location loc(current_file, first_line, first_column, current_line,
......@@ -489,7 +489,7 @@ if (in_set) {
"#"{WS}"("{WS}{NUMBER}{WS}")" {
if (in_set) {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -514,7 +514,7 @@ if (in_set) {
}
"#"{WS}"("{WS}{NUMBER}{WS}","{WS}{NUMBER}{WS}")" {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
if (in_set) {
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
......@@ -569,7 +569,7 @@ if (in_set) {
"#"{WS}"("{WS}{NUMBER}{WS}","{WS}")" {
if (in_set) {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -597,7 +597,7 @@ if (in_set) {
"#"{WS}"("{WS}","{WS}{NUMBER}{WS}")" {
if (in_set) {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......@@ -623,7 +623,7 @@ if (in_set) {
}
"#"{WS}"("{WS}","{WS}")" {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
if (in_set) {
Location loc(current_file, first_line, first_column, current_line,
......@@ -634,7 +634,7 @@ if (in_set) {
}
"#"{WS}"("[^)]*")" {
int first_line = current_line, first_column = current_column;
size_t first_line = current_line, first_column = current_column;
UPDATE_LOCATION(0, yyleng);
Location loc(current_file, first_line, first_column, current_line,
current_column);
......
......@@ -75,7 +75,7 @@ extern int rawAST_debug;
extern YYLTYPE yylloc;
/* always points to the first character of the regexp to be recognized */
static int current_line, current_column;
static size_t current_line, current_column;
static void update_lloc()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment