Pelles C forum

Pelles C => Bug reports => Topic started by: leandrojardim on October 01, 2015, 11:13:28 AM

Title: Seems the IDE has a bug with character constants with double quotes
Post by: leandrojardim on October 01, 2015, 11:13:28 AM
I am trying to browse the functions of a project on which I am working by using the function list at right of the IDE, but for some reason Pelle's C doesn't list the functions that come after a macro reference that has the character constant '\"' as the macro content. An use case with a function that uses this macro is shown below. By copying and pasting this snippet on a empty Pelle's C project, you can see that the ISO C main() function isn't listed on the function list. If you change the character constant of the DOUBLE_QUOTE define or remove any references to the DOUBLE_QUOTE define on the source code, the main() function will appear again.

Code: [Select]
#define END_OF_STRING '\0'
#define LINE_FEED '\n'
#define CARRIAGE_RETURN '\r'
#define WHITE_SPACE ' '

// Get attention to this define
#define DOUBLE_QUOTE      '\"'

typedef enum Token {
UNKNOWN_TOKEN = 0, NUMBER_TOKEN, IDENTIFIER_TOKEN, STRING_TOKEN,
DOUBLE_QUOTE_TOKEN, PRINT_TOKEN, START_STATE, WHITE_SPACE_TOKEN, END_OF_LINE_TOKEN, END_OF_STRING_TOKEN
} TOKEN;

TOKEN CharacterTable[256];

void PopulateCharacterTable(void)
{
for (int Index = 'A'; Index <= 'Z'; Index++)
{
CharacterTable[Index] = IDENTIFIER_TOKEN;
};
for (int Index = 'a'; Index <= 'z'; Index++)
{
CharacterTable[Index] = IDENTIFIER_TOKEN;
};
for (int Index = '0'; Index <= '1'; Index++)
{
CharacterTable[Index] = NUMBER_TOKEN;
};
CharacterTable[WHITE_SPACE] = WHITE_SPACE_TOKEN;
CharacterTable[LINE_FEED] = END_OF_LINE_TOKEN;
CharacterTable[END_OF_STRING] = END_OF_STRING_TOKEN;

// From now on any functions declared in the source code will not appear on the function list anymore.
CharacterTable[DOUBLE_QUOTE] = DOUBLE_QUOTE_TOKEN;
};

int main (void)
{
PopulateCharacterTable();
};
Title: Re: Seems the IDE has a bug with character constants with double quotes
Post by: TimoVJL on October 01, 2015, 12:43:23 PM
It isn't in this code :(
Code: [Select]
#define DOUBLE_QUOTE '\"'

typedef enum Token {
UNKNOWN_TOKEN = 0, NUMBER_TOKEN, IDENTIFIER_TOKEN, STRING_TOKEN,
DOUBLE_QUOTE_TOKEN, PRINT_TOKEN, START_STATE, WHITE_SPACE_TOKEN, END_OF_LINE_TOKEN, END_OF_STRING_TOKEN
} TOKEN;

#define WHITE_SPACE_TOKEN 1
#define WHITE_SPACE 1
#define LINE_FEED 2
#define END_OF_STRING 3

int CharacterTable[10];

void PopulateCharacterTable(void)
{
for (int Index = 'A'; Index <= 'Z'; Index++)
{
CharacterTable[Index] = IDENTIFIER_TOKEN;
};
for (int Index = 'a'; Index <= 'z'; Index++)
{
CharacterTable[Index] = IDENTIFIER_TOKEN;
};
for (int Index = '0'; Index <= '1'; Index++)
{
CharacterTable[Index] = NUMBER_TOKEN;
};
CharacterTable[WHITE_SPACE] = WHITE_SPACE_TOKEN;
CharacterTable[DOUBLE_QUOTE] = DOUBLE_QUOTE_TOKEN;
CharacterTable[LINE_FEED] = END_OF_LINE_TOKEN;
CharacterTable[END_OF_STRING] = END_OF_STRING_TOKEN;
}
Title: Re: Seems the IDE has a bug with character constants with double quotes
Post by: leandrojardim on October 01, 2015, 01:55:13 PM
Thanks TimoVJL. I have updated my previous post to append the info that I forgot to write, and which that you, needed to include yourself. Sorry.

But the issue with the IDE and that your example showed off, is that the IDE have some problems to parse macros, like in the code above...

If I change the line:

Code: [Select]
CharacterTable[DOUBLE_QUOTE] = DOUBLE_QUOTE_TOKEN;
to:

Code: [Select]
CharacterTable['\"'] = DOUBLE_QUOTE_TOKEN;
It suddendly works.

EDIT: But this issue is very strange by nature. I dont know very well whats happening with it.
Title: Re: Seems the IDE has a bug with character constants with double quotes
Post by: leandrojardim on December 12, 2016, 04:28:06 AM
I have rewritten my old bug report and it is easier to understand the issue now, to see it please go back to the top of the thread. I ask for a moderator to move the thread to the "Bug reports" section, please.
Title: Re: Seems the IDE has a bug with character constants with double quotes
Post by: TimoVJL on December 12, 2016, 10:55:24 AM
Even in this:
Code: [Select]
#define DOUBLE_QUOTE '\"'

void test1(void)
{
char c = DOUBLE_QUOTE;
}
void test2(void)
{
char c = 0;
}
int main (void)
{
return 0;
}
so the bug is in pobr.dll v.8, not in v.7