Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2bddc2

Browse files
author
Michael Meskes
committed
Applied Zoltan's patch to make ecpg spit out warnings if a local variable hides a global one with the same name.
1 parent0189c42 commitb2bddc2

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

‎src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* functions needed for descriptor handling
33
*
4-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.32 2010/03/09 11:09:45 meskes Exp $
4+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.33 2010/04/01 08:41:01 meskes Exp $
55
*
66
* since descriptor might be either a string constant or a string var
77
* we need to check for a constant if we expect a constant
@@ -188,7 +188,7 @@ output_get_descr(char *desc_name, char *index)
188188
break;
189189
}
190190
fprintf(yyout,"%s,",get_dtype(results->value));
191-
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL);
191+
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL,v->brace_level,-1);
192192
}
193193
drop_assignments();
194194
fputs("ECPGd_EODT);\n",yyout);
@@ -293,7 +293,7 @@ output_set_descr(char *desc_name, char *index)
293293
caseECPGd_length:
294294
caseECPGd_type:
295295
fprintf(yyout,"%s,",get_dtype(results->value));
296-
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL);
296+
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL,v->brace_level,-1);
297297
break;
298298

299299
default:

‎src/interfaces/ecpg/preproc/type.c

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.88 2010/03/09 11:09:45 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.89 2010/04/01 08:41:01 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -54,7 +54,7 @@ ECPGstruct_member_dup(struct ECPGstruct_member * rm)
5454
* if this array does contain a struct again, we have to
5555
* create the struct too
5656
*/
57-
if (rm->type->u.element->type==ECPGt_struct)
57+
if (rm->type->u.element->type==ECPGt_struct||rm->type->u.element->type==ECPGt_union)
5858
type=ECPGmake_struct_type(rm->type->u.element->u.members,rm->type->u.element->type,rm->type->u.element->type_name,rm->type->u.element->struct_sizeof);
5959
else
6060
type=ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type,rm->type->u.element->size,rm->type->u.element->counter),rm->type->size);
@@ -240,8 +240,44 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
240240
constchar*ind_name,structECPGtype*ind_type,
241241
constchar*prefix,constchar*ind_prefix,
242242
char*arr_str_siz,constchar*struct_sizeof,
243-
constchar*ind_struct_sizeof)
243+
constchar*ind_struct_sizeof,
244+
constintbrace_level,constintind_brace_level)
244245
{
246+
structvariable*var;
247+
248+
if (type->type!=ECPGt_descriptor&&type->type!=ECPGt_sqlda&&
249+
type->type!=ECPGt_char_variable&&
250+
brace_level >=0)
251+
{
252+
char*str;
253+
254+
str=strdup(name);
255+
var=find_variable(str);
256+
free(str);
257+
258+
if ((var->type->type!=type->type)||
259+
(var->type->type_name&& !type->type_name)||
260+
(!var->type->type_name&&type->type_name)||
261+
(var->type->type_name&&type->type_name&&strcmp(var->type->type_name,type->type_name)))
262+
mmerror(PARSE_ERROR,ET_WARNING,"variable (%s) is hidden by a local variable of a different type",name);
263+
elseif (var->brace_level!=brace_level)
264+
mmerror(PARSE_ERROR,ET_WARNING,"variable (%s) is hidden by a local variable",name);
265+
266+
if (ind_name&&ind_type&&ind_type->type!=ECPGt_NO_INDICATOR&&ind_brace_level >=0)
267+
{
268+
str=strdup(ind_name);
269+
var=find_variable(str);
270+
free(str);
271+
if ((var->type->type!=ind_type->type)||
272+
(var->type->type_name&& !ind_type->type_name)||
273+
(!var->type->type_name&&ind_type->type_name)||
274+
(var->type->type_name&&ind_type->type_name&&strcmp(var->type->type_name,ind_type->type_name)))
275+
mmerror(PARSE_ERROR,ET_WARNING,"indicator variable (%s) is hidden by a local variable of a different type",ind_name);
276+
elseif (var->brace_level!=ind_brace_level)
277+
mmerror(PARSE_ERROR,ET_WARNING,"indicator variable (%s) is hidden by a local variable",ind_name);
278+
}
279+
}
280+
245281
switch (type->type)
246282
{
247283
caseECPGt_array:
@@ -503,7 +539,8 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
503539
(ind_p!=NULL) ?ind_p->name :NULL,
504540
(ind_p!=NULL) ?ind_p->type :NULL,
505541
prefix,ind_prefix,arrsiz,type->struct_sizeof,
506-
(ind_p!=NULL) ?ind_type->struct_sizeof :NULL);
542+
(ind_p!=NULL) ?ind_type->struct_sizeof :NULL,
543+
-1,-1);
507544
if (ind_p!=NULL&&ind_p!=&struct_no_indicator)
508545
ind_p=ind_p->next;
509546
}

‎src/interfaces/ecpg/preproc/type.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.54 2010/03/09 11:09:45 meskes Exp $
2+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.55 2010/04/01 08:41:01 meskes Exp $
33
*/
44
#ifndef_ECPG_PREPROC_TYPE_H
55
#define_ECPG_PREPROC_TYPE_H
@@ -57,7 +57,8 @@ voidECPGfree_type(struct ECPGtype *);
5757
*/
5858
voidECPGdump_a_type(FILE*,constchar*,structECPGtype*,
5959
constchar*,structECPGtype*,constchar*,
60-
constchar*,char*,constchar*,constchar*);
60+
constchar*,char*,constchar*,constchar*,
61+
constint,constint);
6162

6263
/* A simple struct to keep a variable and its type. */
6364
structECPGtemp_type

‎src/interfaces/ecpg/preproc/variable.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.54 2010/03/09 11:09:45 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.55 2010/04/01 08:41:01 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -22,7 +22,7 @@ new_variable(const char *name, struct ECPGtype * type, int brace_level)
2222
}
2323

2424
staticstructvariable*
25-
find_struct_member(char*name,char*str,structECPGstruct_member*members,intbrace_level)
25+
find_struct_member(constchar*name,char*str,structECPGstruct_member*members,intbrace_level)
2626
{
2727
char*next=strpbrk(++str,".-["),
2828
*end,
@@ -446,7 +446,8 @@ dump_variables(struct arguments * list, int mode)
446446
/* Then the current element and its indicator */
447447
ECPGdump_a_type(yyout,list->variable->name,list->variable->type,
448448
list->indicator->name,list->indicator->type,
449-
NULL,NULL,make_str("0"),NULL,NULL);
449+
NULL,NULL,make_str("0"),NULL,NULL,
450+
list->variable->brace_level,list->indicator->brace_level);
450451

451452
/* Then release the list element. */
452453
if (mode!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp