diff options
author | Hansruedi Patzen | 2018-05-17 12:34:38 +0000 |
---|---|---|
committer | Thomas Corbat | 2018-06-03 08:43:08 +0000 |
commit | 5c5ce995f6eb390218a1ae5cdb17f23c15b3c6ef (patch) | |
tree | 72009e0c093cb90124e4d652a28377de119df9cc | |
parent | 7b53e75fb2aa2637066b01f099b63ca81c9d0340 (diff) | |
download | org.eclipse.cdt-5c5ce995f6eb390218a1ae5cdb17f23c15b3c6ef.tar.gz org.eclipse.cdt-5c5ce995f6eb390218a1ae5cdb17f23c15b3c6ef.tar.xz org.eclipse.cdt-5c5ce995f6eb390218a1ae5cdb17f23c15b3c6ef.zip |
Bug 534813 - ASTWriter swaps noexcept and pure virtual specifier
Fix and test
Change-Id: I14088e69aed829940fb1e9f5197dedf18d9bb7a5
Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch>
Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
3 files changed, 32 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java index 2c8a3c19cd5..0a477475d42 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ReplaceTests.java @@ -1018,4 +1018,31 @@ public class ReplaceTests extends ChangeGeneratorTest { } }); } + + //struct FooInterface + //{ + // virtual void foo() throw (int); + //}; + + //struct FooInterface + //{ + // virtual void foo() throw (int) = 0; + //}; + public void testPureVirtualFunction() throws Exception { + compareResult(new ASTVisitor() { + { + shouldVisitDeclarators = true; + } + + @Override + public int visit(IASTDeclarator declarator) { + if (declarator instanceof ICPPASTFunctionDeclarator) { + ICPPASTFunctionDeclarator newDeclarator = (ICPPASTFunctionDeclarator) declarator.copy(CopyStyle.withLocations); + newDeclarator.setPureVirtual(true); + addModification(null, ModificationKind.REPLACE, declarator, newDeclarator); + } + return PROCESS_ABORT; + } + }); + } } diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts index fe03601af54..734f54d2005 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts @@ -56,6 +56,7 @@ class TestClass int alpha; TestClass(int a); virtual void pure() = 0; + virtual void func() noexcept = 0; }; TestClass::TestClass(int a) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java index 4ea36fbcac3..18a961b08be 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java @@ -170,10 +170,6 @@ public class DeclaratorWriter extends NodeWriter { scribe.printSpace(); scribe.print(Keywords.MUTABLE); } - writeVirtualSpecifiers(funcDec); - if (funcDec.isPureVirtual()) { - scribe.print(PURE_VIRTUAL); - } writeExceptionSpecification(funcDec, funcDec.getExceptionSpecification(), funcDec.getNoexceptExpression()); writeAttributes(funcDec, EnumSet.of(SpaceLocation.BEFORE)); if (funcDec.getTrailingReturnType() != null) { @@ -182,6 +178,10 @@ public class DeclaratorWriter extends NodeWriter { scribe.printSpace(); funcDec.getTrailingReturnType().accept(visitor); } + writeVirtualSpecifiers(funcDec); + if (funcDec.isPureVirtual()) { + scribe.print(PURE_VIRTUAL); + } } public void writeVirtualSpecifiers(ICPPASTFunctionDeclarator funcDec) { |