1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 562722 - Fix noexcept using implement method

Change-Id: I3ac99f916883fa4be55af29e51b63bc8aa40a63f
This commit is contained in:
Marco Stornelli 2020-05-02 15:26:54 +02:00
parent 0124c964b5
commit e730b264c5
3 changed files with 26 additions and 1 deletions

View file

@ -919,4 +919,21 @@ public class ImplementMethodRefactoringTest extends RefactoringTestBase {
public void testNamespaceAlreadyInDefinition_Bug434677() throws Exception { public void testNamespaceAlreadyInDefinition_Bug434677() throws Exception {
assertRefactoringSuccess(); assertRefactoringSuccess();
} }
//A.h
//
//struct A {
// /*$*/void waldo() noexcept;/*$$*/
//};
//A.cpp
//#include "A.h"
//====================
//#include "A.h"
//
//void A::waldo() noexcept {
//}
public void testNoexpect_Bug562722() throws Exception {
assertRefactoringSuccess();
}
} }

View file

@ -498,7 +498,7 @@ public class OverrideMethodsRefactoringTest extends RefactoringTestBase {
// virtual void baseFunc() const noexcept; // virtual void baseFunc() const noexcept;
//}; //};
// //
//inline void X::baseFunc() const { //inline void X::baseFunc() const noexcept {
//} //}
public void testWithNoExcept() throws Exception { public void testWithNoExcept() throws Exception {
selectedMethods = new String[] { "baseFunc()const" }; selectedMethods = new String[] { "baseFunc()const" };

View file

@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@ -357,6 +358,13 @@ public class ImplementMethodRefactoring extends CRefactoring {
.addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy(CopyStyle.withLocations)); .addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy(CopyStyle.withLocations));
} }
} }
ICPPASTExpression noexceptExpression = functionDeclarator.getNoexceptExpression();
if (noexceptExpression != null) {
createdMethodDeclarator.setNoexceptExpression(
noexceptExpression == ICPPASTFunctionDeclarator.NOEXCEPT_DEFAULT ? noexceptExpression
: (ICPPASTExpression) noexceptExpression.copy(CopyStyle.withLocations));
}
IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier,
createdMethodDeclarator, nodeFactory.newCompoundStatement()); createdMethodDeclarator, nodeFactory.newCompoundStatement());
functionDefinition.setParent(unit); functionDefinition.setParent(unit);