diff options
author | Hansruedi Patzen | 2017-11-28 14:40:28 +0000 |
---|---|---|
committer | Hansruedi Patzen | 2017-11-28 14:40:28 +0000 |
commit | 7d208e098f2c7e0e201a986c8f2c825ae68c34cb (patch) | |
tree | 64f3cc81098ab09c684f736e08084a0440ec80ee /core | |
parent | 6db1357b1abf4944e40d8aa6ddd1520c2e224ce8 (diff) | |
download | org.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>
Diffstat (limited to 'core')
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 ed8fbcfe9e2..7bf6cc650a9 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 6afe8cca260..cefa059c626 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; |