Bug 421522 - wrong ASTMacroParameter offset when there are comments
Summary: wrong ASTMacroParameter offset when there are comments
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-12 06:52 EST by Marco Trudel CLA
Modified: 2020-09-04 15:19 EDT (History)
2 users (show)

See Also:


Attachments
testcase that shows the bug (standalone program) (887 bytes, text/plain)
2014-11-14 05:15 EST, Marco Trudel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Trudel CLA 2013-11-12 06:52:59 EST
In: #define FOO(/*(1)*/ a /*(2)*/, /*(3)*/ b /*(4)*/) a + b
the offset for a points to '/' (from /*(1)*/). b has the same problem.

It's caused by ASTFunctionStyleMacroDefinition.getParameters() working with
   char[] image= getRawSignatureChars();
and only skipping whitespace, but not comments.

This seems to be a bigger problem even. This definition can't be parsed by CDT at all: #define FOO(/*(1)*/ a /*(2)*/, /*(3)*/ b /*(4)*/) "/*(5)*/" a + b
This reports a syntax error.
Comment 1 Nathan Ridge CLA 2014-11-13 04:09:20 EST
(In reply to Marco Trudel from comment #0)
> This seems to be a bigger problem even. This definition can't be parsed by
> CDT at all: #define FOO(/*(1)*/ a /*(2)*/, /*(3)*/ b /*(4)*/) "/*(5)*/" a + b
> This reports a syntax error.

I don't see a syntax error with the latest CDT.
Comment 2 Marco Trudel CLA 2014-11-14 05:15:08 EST
Created attachment 248656 [details]
testcase that shows the bug (standalone program)
Comment 3 Marco Trudel CLA 2014-11-14 05:20:52 EST
Comment on attachment 248656 [details]
testcase that shows the bug (standalone program)

Actual Output
-------------
Parameters of "OK(a,b)=a + b":
- a
- b
Parameters of "FAILS(a,b)=a + b":
- /
- /

Expected Output
---------------
Parameters of "OK(a,b)=a + b":
- a
- b
Parameters of "FAILS(a,b)=a + b":
- a
- b
Comment 4 Marco Trudel CLA 2014-11-14 05:24:36 EST
(In reply to Nathan Ridge from comment #1)
> (In reply to Marco Trudel from comment #0)
> > This seems to be a bigger problem even. This definition can't be parsed by
> > CDT at all: #define FOO(/*(1)*/ a /*(2)*/, /*(3)*/ b /*(4)*/) "/*(5)*/" a + b
> > This reports a syntax error.
> 
> I don't see a syntax error with the latest CDT.

Sorry, there's actually no syntax error. I must have gotten confused when trying to work around that bug for too long.
I now added a small testcase that shows the bug.