Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHansruedi Patzen2017-11-28 14:40:28 +0000
committerHansruedi Patzen2017-11-28 14:40:28 +0000
commit7d208e098f2c7e0e201a986c8f2c825ae68c34cb (patch)
tree64f3cc81098ab09c684f736e08084a0440ec80ee
parent6db1357b1abf4944e40d8aa6ddd1520c2e224ce8 (diff)
downloadorg.eclipse.cdt-7d208e098f2c7e0e201a986c8f2c825ae68c34cb.tar.gz
org.eclipse.cdt-7d208e098f2c7e0e201a986c8f2c825ae68c34cb.tar.xz
org.eclipse.cdt-7d208e098f2c7e0e201a986c8f2c825ae68c34cb.zip
Bug 527872: UDL operator name gets duplicated on rewrite
Change-Id: Id1cda5f09f6fc3852a99a607be21f6ea33f5faf5 Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch>
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java8
2 files changed, 9 insertions, 6 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 ed8fbcfe9e..7bf6cc650a 100644
--- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts
+++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts
@@ -171,3 +171,10 @@ void foo() noexcept (noexcept (1 + 1))
void foo() noexcept (noexcept (1 + 1) && noexcept (2 + 3))
{
}
+
+//!Basic UDL operator
+//%CPP
+constexpr long double operator ""_deg(long double deg)
+{
+ return deg * 3.141592 / 180;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 6afe8cca26..cefa059c62 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -913,7 +913,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
IToken ident = consume(IToken.tIDENTIFIER);
char[] operatorName = CharArrayUtils.concat(firstToken.getCharImage(), " ".toCharArray()); //$NON-NLS-1$
- operatorName = CharArrayUtils.concat(operatorName, strOp.getCharImage());
+ operatorName = CharArrayUtils.concat(operatorName, strOp.getCharImage());
operatorName = CharArrayUtils.concat(operatorName, ident.getCharImage());
IASTName name = getNodeFactory().newOperatorName(operatorName);
@@ -929,12 +929,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
int startQuote = image.indexOf('"');
int endQuote = image.lastIndexOf('"');
if (startQuote != -1 && endQuote == startQuote + 1) {
- char[] ident = image.substring(endQuote + 1).toCharArray();
-
char[] operatorName = CharArrayUtils.concat(firstToken.getCharImage(), " ".toCharArray()); //$NON-NLS-1$
- operatorName = CharArrayUtils.concat(operatorName, strOp.getCharImage());
- operatorName = CharArrayUtils.concat(operatorName, ident);
-
+ operatorName = CharArrayUtils.concat(operatorName, strOp.getCharImage());
IASTName name = getNodeFactory().newOperatorName(operatorName);
setRange(name, firstToken.getOffset(), strOp.getEndOffset());
return name;

Back to the top