Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361768 - Use of two sequential macros in C++ code formats incorrectly
Summary: Use of two sequential macros in C++ code formats incorrectly
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 9.8.0   Edit
Assignee: Marco Stornelli CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-24 00:59 EDT by Geoff Alexander CLA
Modified: 2019-04-08 12:54 EDT (History)
5 users (show)

See Also:


Attachments
Eclipse workspace containing small example illustrating the problem (184.77 KB, application/x-compressed-tar)
2011-10-24 01:13 EDT, Geoff Alexander CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Geoff Alexander CLA 2011-10-24 00:59:49 EDT

    
Comment 1 Geoff Alexander CLA 2011-10-24 01:13:42 EDT
Created attachment 205779 [details]
Eclipse workspace containing small example illustrating the problem
Comment 2 Geoff Alexander CLA 2011-10-24 01:19:08 EDT
Build Identifier: 20110916-0149

We sometimes have two sequential macro usages as in the following code:

    public:
      inline bool operator!=(const Term& r) const {
        LLTP_ASSERT1((_type == function) || (_type == variable));
        LLTP_ASSERT1((r._type == function) || (r._type == variable));
        return !(*this == r);
      }

Under Eclipse CDT 8.0 this formats incorrectly on the first format:

    public:
      inline bool operator!=(const Term& r) const {
        LLTP_ASSERT1((_type == function) || (_type == variable)); LLTP_ASSERT1((r._type == function) || (r._type == variable));
        return !(*this == r);
      }

A second format gives

    public:
      inline bool operator!=(const Term& r) const {
        LLTP_ASSERT1((_type == function) || (_type == variable));LLTP_ASSERT1((r._type == function) || (r._type == variable));
        return !(*this == r);
      }

I've attached an Eclipse workspace containing a small example illustrating the problem.
Comment 3 Nathan Ridge CLA 2015-03-31 04:11:38 EDT
Looks like the problem is related to the macro having an empty expansion.
Comment 4 Geoff Alexander CLA 2015-04-03 16:56:21 EDT
Thanks Nathan.  Based on your comment, I'm able to work around the problem by using the # Symbols tab of the C/C++ General -> Paths and Symbols preferences to ensure that the problematic macros aren't empty. However, even though I'm able to work around the problem, I still think that this problem should be fixed.
Comment 5 Nathan Ridge CLA 2015-04-03 17:00:37 EDT
Agreed - this is a bug in the formatter.
Comment 6 Eclipse Genie CLA 2019-03-09 12:07:45 EST
New Gerrit change created: https://git.eclipse.org/r/138425
Comment 8 Jonah Graham CLA 2019-04-08 12:54:46 EDT
Thank you for the fix Marco!