Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed to correctly diagnose expressions with NPC #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mycoboco
Copy link

This commit lets lcc correctly diagnose the following code:

typedef void (*fp_t)(void);

fp_t func(fp_t param)
{
    return (void *)0;          /* line A */
}

int main(void)
{
    fp_t t = (void *)0;       /* line B */
    t = (void *)0;            /* line C */
    return func((void *)0)    /* line D */
               == (void *)0;
}

According to the Standard, the commented lines above should not be considered non-portable while lcc says:

5: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
10: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
11: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
12: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent

EDIT: an example regarding a conditional expression and NPC has been removed because it was wrong; constant expressions can be or have conditional expressions. No problem with them in lcc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant