Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNathan Ridge2018-02-27 05:06:59 +0000
committerThomas Corbat2018-06-11 11:34:03 +0000
commit4e4e010e3353372d0d38a3b1f5fcd957ed3fefae (patch)
tree80219763c2d4a33ba9920a9318379732af2f4e03 /core
parente02e28eec1d7b08a85021f383d2ecc945540e98c (diff)
downloadorg.eclipse.cdt-4e4e010e3353372d0d38a3b1f5fcd957ed3fefae.tar.gz
org.eclipse.cdt-4e4e010e3353372d0d38a3b1f5fcd957ed3fefae.tar.xz
org.eclipse.cdt-4e4e010e3353372d0d38a3b1f5fcd957ed3fefae.zip
Bug 531701 - ClassCastException in
AttributeWriter.writeGCCAttributeSpecifier() * Added test to reproduce initial issue. Change-Id: I72e60fb2244b7d40492bfcdeaa58a8707c39e277 Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/AttributeWriter.java30
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java17
2 files changed, 39 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/AttributeWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/AttributeWriter.java
index 23c63a5e3fc..2689dd200f3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/AttributeWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/AttributeWriter.java
@@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttributeList;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
import org.eclipse.cdt.core.parser.GCCKeywords;
import org.eclipse.cdt.core.parser.Keywords;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAttribute;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
@@ -65,7 +64,11 @@ public class AttributeWriter extends NodeWriter {
IASTAttribute[] innerAttributes = specifier.getAttributes();
for (int i = 0; i < innerAttributes.length; i++) {
IASTAttribute innerAttribute = innerAttributes[i];
- writeAttribute((CPPASTAttribute)innerAttribute);
+ if (innerAttribute instanceof ICPPASTAttribute) {
+ writeAttribute((ICPPASTAttribute) innerAttribute);
+ } else {
+ writeAttribute(innerAttribute);
+ }
if (i < innerAttributes.length - 1) {
scribe.print(',');
scribe.printSpace();
@@ -91,12 +94,7 @@ public class AttributeWriter extends NodeWriter {
scribe.print(CLOSING_SQUARE_BRACKET);
}
- private void writeAttribute(ICPPASTAttribute attribute) {
- char[] scope = attribute.getScope();
- if (scope != null) {
- scribe.print(scope);
- scribe.print(COLON_COLON);
- }
+ private void writeAttribute(IASTAttribute attribute) {
scribe.print(attribute.getName());
IASTToken argumentClause = attribute.getArgumentClause();
@@ -105,13 +103,29 @@ public class AttributeWriter extends NodeWriter {
printTokens(argumentClause);
scribe.print(CLOSING_PARENTHESIS);
}
+ }
+
+ private void writeAttributeScope(ICPPASTAttribute attribute) {
+ char[] scope = attribute.getScope();
+ if (scope != null) {
+ scribe.print(scope);
+ scribe.print(COLON_COLON);
+ }
+ }
+ private void writeAttributeVarArgs(ICPPASTAttribute attribute) {
if (attribute.hasPackExpansion()) {
scribe.printSpace();
scribe.print(VAR_ARGS);
}
}
+ private void writeAttribute(ICPPASTAttribute attribute) {
+ writeAttributeScope(attribute);
+ writeAttribute((IASTAttribute) attribute);
+ writeAttributeVarArgs(attribute);
+ }
+
protected void printTokens(IASTToken token) {
if (token instanceof IASTTokenList) {
for (IASTToken innerToken : ((IASTTokenList) token).getTokens()) {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java
index 0414dcfac5b..f16f3c9e9d6 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java
@@ -3551,4 +3551,21 @@ public class ToggleRefactoringTest extends RefactoringTestBase {
public void testToggleWithTemplateArgumentDependentQualifierInReturnType_399931() throws Exception {
assertRefactoringSuccess();
}
+
+ //A.c
+ //void /*$*/freefunction/*$$*/(int x __attribute__((unused))) {
+ // return;
+ //}
+ //====================
+ //#include "A.h"
+ //
+
+ //A.h
+ //====================
+ //void freefunction(int x __attribute__((unused))) {
+ // return;
+ //}
+ public void testFreeFunctionFromHeaderToImplInC_531701() throws Exception {
+ assertRefactoringSuccess();
+ }
}

Back to the top