Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHansruedi Patzen2017-11-13 04:13:22 -0500
committerThomas Corbat2017-11-15 03:29:51 -0500
commitb721d6a424ff82d9c7c1feab65df53a4fb4c659f (patch)
tree6acb6162c014251c297db135aeacdeb7f5c743d7
parent1bf0dff19f90158633ea4f84a3b0851bb801160b (diff)
downloadorg.eclipse.cdt-b721d6a424ff82d9c7c1feab65df53a4fb4c659f.tar.gz
org.eclipse.cdt-b721d6a424ff82d9c7c1feab65df53a4fb4c659f.tar.xz
org.eclipse.cdt-b721d6a424ff82d9c7c1feab65df53a4fb4c659f.zip
Bug 527179: ExpressionWriter removes nested noexcept expressions
Change-Id: I7c032e9327756704690760f3207c73f1645deb19 Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch>
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts27
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java7
2 files changed, 32 insertions, 2 deletions
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 bb26697b63..ed8fbcfe9e 100644
--- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts
+++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts
@@ -145,4 +145,29 @@ struct S
virtual void memFun() final
{
}
-}; \ No newline at end of file
+};
+
+//!Noexcept without expression specifiers
+//%CPP
+void foo() noexcept
+{
+}
+
+
+//!Noexcept with expression specifiers
+//%CPP
+void foo() noexcept (1 + 1)
+{
+}
+
+//!Nested noexcept specifiers
+//%CPP
+void foo() noexcept (noexcept (1 + 1))
+{
+}
+
+//!Multiple nested noexcept specifiers
+//%CPP
+void foo() noexcept (noexcept (1 + 1) && noexcept (2 + 3))
+{
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
index 62efcd956b..1d75f4d665 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
@@ -71,6 +71,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String OPEN_BRACKET_OP = "("; //$NON-NLS-1$
private static final String SIZEOF_OP = "sizeof "; //$NON-NLS-1$
private static final String SIZEOF_PARAMETER_PACK_OP = "sizeof..."; //$NON-NLS-1$
+ private static final String NOEXCEPT_OP = "noexcept ("; //$NON-NLS-1$
private static final String NOT_OP = "!"; //$NON-NLS-1$
private static final String TILDE_OP = "~"; //$NON-NLS-1$
private static final String AMPERSAND_OP = "&"; //$NON-NLS-1$
@@ -253,6 +254,7 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid:
+ case ICPPASTUnaryExpression.op_noexcept:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_labelReference:
return true;
@@ -269,6 +271,7 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_postFixIncr:
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_typeid:
+ case ICPPASTUnaryExpression.op_noexcept:
case IASTUnaryExpression.op_alignOf:
return true;
@@ -306,6 +309,8 @@ public class ExpressionWriter extends NodeWriter{
return THROW;
case ICPPASTUnaryExpression.op_typeid:
return TYPEID_OP;
+ case ICPPASTUnaryExpression.op_noexcept:
+ return NOEXCEPT_OP;
case IASTUnaryExpression.op_alignOf:
return ALIGNOF_OP;
case IASTUnaryExpression.op_labelReference:
@@ -324,7 +329,7 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_postFixIncr:
return INCREMENT_OP;
case ICPPASTUnaryExpression.op_typeid:
- return CLOSING_BRACKET_OP;
+ case ICPPASTUnaryExpression.op_noexcept:
case IASTUnaryExpression.op_bracketedPrimary:
case IASTUnaryExpression.op_alignOf:
return CLOSING_BRACKET_OP;

Back to the top