[Prev][Next][Index]

Re: Problems with SgType::baseType()



>> PS: Did the fix for following typedefs in getTrueType work for  
you?
>> 

>Yes. Thanks. Now getTrueType() is working. 


Good, I'll send Andrew a note; I think getTrueType should be changed  
so that it automatically "or"s BIT_TYPEDEF if DO_FOLLOW_TYPEDEFS is  
specified. 


>The only 'fix' that I
>couldn't get to work was the last unparser fix you sent me. It fixed
>the problems when calling a function with the same name of a  
>structure
>but when the code did something like
>
>			ptr = malloc(10 * sizeof(struct stat));
>
>it was unparsed to
>
>			ptr = malloc(10 * sizeof(stat));

No wonder, since sizeof(struct stat) is represented as a SIZE_OP  
expression that contains CAST_OP expression so that the type is  
unparsed "inside" a CAST_OP expression; and the fix explicitly told  
the unparser _not_ to write "struct" inside CAST_OP expressions.

>Right now I'm using fstat() instead of stat() and I'm not using the
>last patch you sent. I'll just wait for the fix to the parser.

Good, throw away the last patch; below are the diffs for the "real"  
fix to the parser. What the modified code does is to make sure that,  
when two symbols with the same name are defined in the same scope,  
the references to that name will point to the symbol that is not the  
type name, unless the name is proceeded by "struct" (or "class", or  
"union"). This allows the parser to recognize function calls  
correctly. I've checked that. I have not had time however to do any  
extensive testing so if you find that something does not works  
anymore or does not work still, please let me know.  --Beata

PS: In the file pC++2dep/vlex.c; it is only the 830a831,834 addition  
that is of interest to you. The remaining changes have to do with  
"operator ~" in C++ (a fix I did in response to a different bug  
report).


rainier_50:cvs diff pC++2dep/vhash.c
===================================================================
RCS file: /u/sage/src/master/sage/pC++2dep/vhash.c,v
retrieving revision 1.15
diff -r1.15 vhash.c
122c122
<       int     myindex;
---
>       int     myindex, found;
153a154,155
>              PTR_BFND type_scope;
>              type_scope = real_scope(symb_ptr->scope);
157c159,161
<                     if ((symb_ptr->variant ==  
TYPE_NAME)||(is_symbol_an_object(symb_ptr->variant))) {
---
>                     if ((symb_ptr->variant == TYPE_NAME)||
>                         (is_symbol_an_object(symb_ptr->variant))) {
> 

158a163,173
>                         found = 0;
>                         for(symb_ptr = entry->id_attr; symb_ptr &&  
(! found);
>                             symb_ptr = symb_ptr->outer) {
>                             if((real_scope(symb_ptr->scope) ==  
type_scope) &&
>                                ((symb_ptr->variant ==  
VARIABLE_NAME) ||
>                                 (symb_ptr->variant == FIELD_NAME)  
||
>                                 (symb_ptr->variant ==  
FUNCTION_NAME))){
>                                     found = 1;
>                                     *type_status = OTHER;
>                                     }
>                             }
184a200,211
>                                     found = 0;
>                                     for(symb_ptr = entry->id_attr;  
symb_ptr && (! found);
>                                       symb_ptr = symb_ptr->outer) {
>                                        
if((real_scope(symb_ptr->scope) == type_scope) &&
>                                          ((symb_ptr->variant ==  
VARIABLE_NAME) ||
>                                           (symb_ptr->variant ==  
FIELD_NAME) ||
>                                           (symb_ptr->variant ==  
FUNCTION_NAME))){
>                                         found = 1;
>                                         *type_status = OTHER;
>                                         }
>                                     }
> 



rainier_51:cvs diff -r1.30 pC++2dep/vlex.c
===================================================================
RCS file: /u/sage/src/master/sage/pC++2dep/vlex.c,v
retrieving revision 1.30
diff -r1.30 vlex.c
479c479
< #define isanop(d) ((d == '+') || (d == '-') || (d == '&') || (d ==  
'|') || (d == '<') || (d == '>') || (d == '*') || (d == '/') || (d ==  
'%') || (d == '^') || (d == '!') || (d == '=') )
---
> #define isanop(d) ((d == '+') || (d == '-') || (d == '&') || (d ==  
'|') || (d == '<') || (d == '>') || (d == '*') || (d == '/') || (d ==  
'%') || (d == '^') || (d == '!') || (d == '=') || (d == '~'))
764c764
<       while (isalnum(c) || (c == '_') || (c == '~'))
---
>       while (isalnum(c) || (c == '_') /* ||  (c == '~') */)
830a831,834
>              else if(t_status == OTHER &&
>                      (previous_value != CLASS) &&
>                      (previous_value != STRUCT) &&
>                      (previous_value != UNION)) value = IDENTIFIER;
1177a1182
>     case '~':