Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365498

Summary: Strange warning placement for defaulted constructor
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-parserAssignee: Nathan Ridge <zeratul976>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse.sprigogin, malaperle, yevshif
Version: 8.0.1   
Target Milestone: 8.1.2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch that fixes the issue, including tests cdtdoug: iplog-

Description Nathan Ridge CLA 2011-12-02 19:15:08 EST
When codan gives a gives a warning about a defaulted constructor, such as the following:

// some comment                  <-- WARNING HERE

struct S
{
    int i;
    
    S() = default;
};

The warning is always on the first line of the file rather than the line with the defaulted constructor, regardless of what the first line of the file is.
Comment 1 Nathan Ridge CLA 2012-11-15 04:07:06 EST
Created attachment 223589 [details]
patch that fixes the issue, including tests

The problem was that the parser was not setting the begin offset of the ASTNode representing the defaulted function definition, so the offset was 0, and so Codan placed the warning on the first line of the file.

Attached is a patch that fixes the problem, with tests.
Comment 2 Nathan Ridge CLA 2012-12-05 22:36:42 EST
Patch is now on gerrit: https://git.eclipse.org/r/#/c/9065/
Comment 4 CDT Genie CLA 2013-02-27 11:57:39 EST
*** cdt git genie on behalf of Nathan Ridge ***

    Bug 365498 - Strange warning placement for defaulted constructor
    Change-Id: Ia80fbd9694310aff0900e80cb9175e101c653604
    Reviewed-on: <a  href="https://git.eclipse.org/r/9065">https://git.eclipse.org/r/9065</a>
    Reviewed-by: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;
    IP-Clean: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;
    Tested-by: Sergey Prigogin &lt;eclipse.sprigogin@xxxxxxxxx&gt;

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=1289cc3a6e98b216ce687901dbc9fcca1c441e30
Comment 5 Doug Schaefer CLA 2013-05-24 10:48:34 EDT
Comment on attachment 223589 [details]
patch that fixes the issue, including tests

Captured with git commit.