mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
Bug 282418: String representation of token-paste.
This commit is contained in:
parent
4c3dd79ee8
commit
518f686e52
2 changed files with 18 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -298,4 +298,14 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
|
||||||
validateEOF();
|
validateEOF();
|
||||||
validateProblemCount(9);
|
validateProblemCount(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #define str(x) #x
|
||||||
|
// #define xstr(x) str(x)
|
||||||
|
// #define MY_MACROS(Type) unsigned ##Type f();
|
||||||
|
// xstr(MY_MACROS(int))
|
||||||
|
public void testStringify_Bug282418() throws Exception {
|
||||||
|
initializeScanner();
|
||||||
|
validateString("unsignedint f();");
|
||||||
|
validateEOF();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -629,6 +629,8 @@ public class MacroExpander {
|
||||||
Token pasteArg2= null;
|
Token pasteArg2= null;
|
||||||
TokenList rest= null;
|
TokenList rest= null;
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
|
Token spaceDef0= n;
|
||||||
|
Token spaceDef1= (Token) n.getNext();
|
||||||
if (n.getType() == CPreprocessor.tMACRO_PARAMETER) {
|
if (n.getType() == CPreprocessor.tMACRO_PARAMETER) {
|
||||||
TokenList arg;
|
TokenList arg;
|
||||||
idx= ((TokenParameterReference) n).getIndex();
|
idx= ((TokenParameterReference) n).getIndex();
|
||||||
|
@ -636,12 +638,13 @@ public class MacroExpander {
|
||||||
arg= clone(args[idx]);
|
arg= clone(args[idx]);
|
||||||
pasteArg2= arg.first();
|
pasteArg2= arg.first();
|
||||||
if (pasteArg2 != null && arg.first() != arg.last()) {
|
if (pasteArg2 != null && arg.first() != arg.last()) {
|
||||||
|
spaceDef0= pasteArg2;
|
||||||
rest= arg;
|
rest= arg;
|
||||||
rest.removeFirst();
|
rest.removeFirst();
|
||||||
|
spaceDef1= rest.first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
idx= -1;
|
idx= -1;
|
||||||
pasteArg2= n;
|
pasteArg2= n;
|
||||||
}
|
}
|
||||||
|
@ -659,7 +662,7 @@ public class MacroExpander {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result.append(generated);
|
result.append(generated);
|
||||||
addSpacemarker(pasteArg2, rest == null ? n : rest.first(), result); // end token paste
|
addSpacemarker(spaceDef0, spaceDef1, result); // end token paste
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rest != null) {
|
if (rest != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue