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

Line number in #line directive after enum YYCONDTYPE is 0-based #152

Closed
sirzooro opened this issue Jun 28, 2016 · 8 comments

Comments

@sirzooro
Copy link

commented Jun 28, 2016

As in title. Other #line directives seems to be correct, except that one - its value should be increased by one.

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Jun 28, 2016

Please point at the wrong #line directive in the following example:

/*!types:re2c*/

/*!re2c
    <a> "a" { return 1; }
*/

Compile with ./re2c 1.re -c:

/* Generated by re2c 0.16 on Tue Jun 28 18:55:41 2016 */
#line 1 "1.re"
#line 4 "<stdout>"

enum YYCONDTYPE {
        yyca,
};

#line 1 "1.re"


#line 13 "<stdout>"
{
        YYCTYPE yych;
        switch (YYGETCONDITION()) {
        case yyca: goto yyc_a;
        }
/* *********************************** */
yyc_a:
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
        switch (yych) {
        case 'a':       goto yy4;
        default:        goto yy3;
        }
yy3:
yy4:
        ++YYCURSOR;
#line 4 "1.re"
        { return 1; }
#line 32 "<stdout>"
}
#line 5 "1.re"
@sirzooro

This comment has been minimized.

Copy link
Author

commented Jun 28, 2016

Instead of #line 1 "1.re" after enum should be #line 2 "1.re". This is line 9 in pasted code.

Please insert some C code between /*!types:re2c*/ and /*!re2c block which will trigger warning or error during compilation, and compare line number in message with actual line number in .re file.

@skvadrik

This comment has been minimized.

Copy link
Owner

commented Jun 28, 2016

The bug you're talking about is probably fixed in HEAD (I have no way to confirm it since I don't have a faulty example). There is at least one related fix in devel branch (HEAD) which is not in master yet.

@sirzooro

This comment has been minimized.

Copy link
Author

commented Jun 28, 2016

/*!types:re2c*/

#warning this is line 3

void f()
{
/*!re2c
    <*> * {}
*/
}

When you will generate code and compile it, you will get:

linebug.re:2:2: warning: #warning this is line 3 [-Wcpp]

But it should be:

linebug.re:3:2: warning: #warning this is line 3 [-Wcpp]
@skvadrik

This comment has been minimized.

Copy link
Owner

commented Jun 28, 2016

Yep, fixed in HEAD. I'll add your example to test suite. :)

@sirzooro

This comment has been minimized.

Copy link
Author

commented Jun 28, 2016

Good to hear :)

BTW, keep in mind that warning message will vary between compilers and their versions, so check generated code only. Also to avoid warnings during compilation change #warning to something else, e.g. int x;

skvadrik added a commit that referenced this issue Jun 28, 2016

Added test fot bug #152 "Line number in #line directive after enum
YYCONDTYPE is 0-based".

(thanks to sirzooro for reporting)
@skvadrik

This comment has been minimized.

Copy link
Owner

commented Jun 28, 2016

The good thing about re2c test suite is that we only test re2c-generated output (it should byte-to-byte coincide with reference output). Unlike C/C++ compiler results, re2c output is stable: we need to verify its correctness only once and then monitor all the changes.

@sirzooro

This comment has been minimized.

Copy link
Author

commented Jun 29, 2016

OK, looks good.

@skvadrik skvadrik closed this Jun 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.