#55 Helpful warning when "data" used for variable name

None
closed
None
5
2015-05-12
2004-01-19
Anonymous
No

Despite being a well documented keyword, "data" is
commonly used as a variable name. This feature request
is to add a special check for "data" (and possibly
other memory types) after printing the parse error, and
print an additional message if "data" was seen in the
current or previous tokens, or "data" occurs on the
line shortly before the location of the parse error.

Here is a tiny example:

void test(int c)
{
int data=0;
data += c;
}

test.c:3: parse error: token -> '=' ; column 17
test.c:4: error: code not generated for 'test' due to
previous errors
test.c:4: warning: in function test unreferenced
function argument : 'c'

Adding a special check for "data" (and perhaps the
other non-ansi memory qualifiers) would really save a
lot of confusion and frustration for new users. For
example:

test.c:3: parse error: token -> '=' ; column 17
test.c:3: warning: possible use of reserved keyword
"data" as variable or function name?
test.c:4: error: code not generated for 'test' due to
previous errors
test.c:4: warning: in function test unreferenced
function argument : 'c'

I should mention that there is already a "useless
declaration" warning that covers the case of "data"
declared as an unitialized variable. But it does not
catch the common case of an initialized variable as
shown in this example.

Discussion

    • status: open --> closed
    • assigned_to: Philipp Klaus Krause
    • Group: -->
     
  • data is no longer a keyword.

    Philipp