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

Bug 329165

Summary: Formatter corrupts code
Product: [Tools] CDT Reporter: Missing name <spamdaemon>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: major    
Priority: P3 CC: cdtdoug
Version: 7.0   
Target Milestone: 7.0.2   
Hardware: PC   
OS: Linux   
Whiteboard:

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.