Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329165 - Formatter corrupts code
Summary: Formatter corrupts code
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 7.0   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 7.0.2   Edit
Assignee: Anton Leherbauer CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-31 15:24 EDT by Missing name CLA
Modified: 2010-11-03 07:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Missing name CLA 2010-10-31 15:24:46 EDT
Build Identifier: 20100917-0705

Under certain conditions, the formatter breaks the code because it merges preprocessing tokens that should not be merged.

This source file is not properly formatted (yes, I know the code is technically invalid).

//#define throws /* */

struct Foo {

	void foo() const throws
	{
	}

	void bar() const throws
	{
	}

};


Once I press CTRL-SHIFT-F this is the code that results:
//#define throws /* */

struct Foo {

	void foo() constthrows
	{
	}

	void bar() const
throws {
}

};

This would not be such a big problem if this would only break with invalid code.
But it also break for me when I define "throws" in some include file. For some reason, it is indexed properly, but the formatter behaves as if the "throws" was not defined.

I think this is a serious bug because it generates invalid code.

Reproducible: Always

Steps to Reproduce:

See detail description.
Comment 1 Anton Leherbauer CLA 2010-11-03 07:19:19 EDT
Fixed in HEAD and 7.0.2.