1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 282418: String representation of token-paste.

This commit is contained in:
Markus Schorn 2010-03-15 17:04:20 +00:00
parent 4c3dd79ee8
commit 518f686e52
2 changed files with 18 additions and 5 deletions

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -298,4 +298,14 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
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();
}
}

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -629,6 +629,8 @@ public class MacroExpander {
Token pasteArg2= null;
TokenList rest= null;
if (n != null) {
Token spaceDef0= n;
Token spaceDef1= (Token) n.getNext();
if (n.getType() == CPreprocessor.tMACRO_PARAMETER) {
TokenList arg;
idx= ((TokenParameterReference) n).getIndex();
@ -636,12 +638,13 @@ public class MacroExpander {
arg= clone(args[idx]);
pasteArg2= arg.first();
if (pasteArg2 != null && arg.first() != arg.last()) {
spaceDef0= pasteArg2;
rest= arg;
rest.removeFirst();
spaceDef1= rest.first();
}
}
}
else {
} else {
idx= -1;
pasteArg2= n;
}
@ -659,7 +662,7 @@ public class MacroExpander {
}
else {
result.append(generated);
addSpacemarker(pasteArg2, rest == null ? n : rest.first(), result); // end token paste
addSpacemarker(spaceDef0, spaceDef1, result); // end token paste
}
}
if (rest != null) {