Bug 529299 - CDT C++ formatting incorrectly indents lines following methods with noexcept
Summary: CDT C++ formatting incorrectly indents lines following methods with noexcept
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 9.4.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 9.4.1   Edit
Assignee: Davin McCall CLA Friend
QA Contact: Doug Schaefer CLA Friend
URL:
Whiteboard:
Keywords:
: 491296 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-12-29 12:22 EST by Davin McCall CLA Friend
Modified: 2018-01-23 13:39 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Davin McCall CLA Friend 2017-12-29 12:22:59 EST
My code format is specified to align opening braces after function declarations at the same column, i.e.:

    int my_function()
    {
        return 0;
    }

This works fine, except when the 'noexcept' specifier is added:

    int my_function() noexcept
            {
        return 0;
            }

Possibly related to bug 443042.
Comment 1 Nathan Ridge CLA Friend 2017-12-30 13:17:33 EST
Works fine for me with Oxygen.2 / CDT 9.4, and the BSD/Allman formatting profile which has the brace behaviour you describe.
Comment 2 Nathan Ridge CLA Friend 2017-12-30 13:22:26 EST
(In reply to Davin McCall from comment #0)
> Possibly related to bug 443042.

Nor can I reproduce the issue in that bug with CDT 9.4.
Comment 3 Davin McCall CLA Friend 2017-12-30 15:35:39 EST
Perhaps I should clarify: the format is correct if I run the formatter manually. It is the automatic as-you-type formatting that goes wrong.
Comment 4 Davin McCall CLA Friend 2017-12-30 15:36:28 EST
(This is with Oxygen.2 and CDT 9.4).
Comment 5 Nathan Ridge CLA Friend 2017-12-30 16:02:08 EST
Ah, I see. In that case, I can confirm that I see the same problem.

There is a similar problem with 'override' (bug 491296).
Comment 6 Davin McCall CLA Friend 2017-12-30 18:11:41 EST
Also: seems to happen only with method declarations after some other statement. The first method in a source file (after #include's) is not affected, if nothing precedes it. If I have a "using namespace std;" then a function declaration immediately after that *is* affected.
Comment 7 Davin McCall CLA Friend 2017-12-30 19:40:33 EST
I've pushed a fix to Gerrit for review: https://git.eclipse.org/r/114832
Comment 8 Nathan Ridge CLA Friend 2018-01-03 15:41:19 EST
Fixed for CDT 9.5 (http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=fc053e612491385bbd788c216936865b660bb9be). Thanks, Davin!
Comment 9 Nathan Ridge CLA Friend 2018-01-03 15:41:54 EST
*** Bug 491296 has been marked as a duplicate of this bug. ***
Comment 10 Davin McCall CLA Friend 2018-01-03 17:09:54 EST
(In reply to Nathan Ridge from comment #8)
> Fixed for CDT 9.5
> (http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/
> ?id=fc053e612491385bbd788c216936865b660bb9be). Thanks, Davin!

Great! Thanks for your help in pushing this through.
Comment 11 Nathan Ridge CLA Friend 2018-01-10 00:09:59 EST
We should uplift this to the 9.4 branch as well, so the fix appears in Oxygen.3 (the current plan is that Oxygen.3 will contain CDT 9.4.1, and Photon will contain CDT 9.5).
Comment 13 Nathan Ridge CLA Friend 2018-01-23 13:39:13 EST
(In reply to Nathan Ridge from comment #11)
> the current plan is that Oxygen.3 will contain CDT 9.4.1

Correction: 9.4.1 was actually released out-of-band a few days ago, and Oxygen.3 will ship with 9.4.2.

The fix for this bug did make it into 9.4.1, so you can get it without waiting for Oxygen.3 by doing "Check for updates" in an Oxygen.2 installation.