mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 300978: Template parameter without name.
This commit is contained in:
parent
1385b28bd7
commit
852f5e9d31
2 changed files with 34 additions and 3 deletions
|
@ -1700,4 +1700,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
getBindingFromASTName("Noder1<int>", 11, ICPPClassSpecialization.class);
|
||||
getBindingFromASTName("Noder2<int>", 11, ICPPClassSpecialization.class);
|
||||
}
|
||||
|
||||
|
||||
// template <typename> struct CT;
|
||||
// template <typename T> struct CT {
|
||||
// T f;
|
||||
// };
|
||||
// struct X {
|
||||
// int x;
|
||||
// };
|
||||
|
||||
// void test() {
|
||||
// CT<X> p;
|
||||
// p.f.x;
|
||||
// }
|
||||
public void testTemplateParameterWithoutName_300978() throws Exception {
|
||||
getBindingFromASTName("x;", 1, ICPPField.class);
|
||||
ICPPClassSpecialization ctx = getBindingFromASTName("CT<X>", 5, ICPPClassSpecialization.class);
|
||||
ICPPClassTemplate ct= (ICPPClassTemplate) ctx.getSpecializedBinding();
|
||||
assertEquals("T", ct.getTemplateParameters()[0].getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
@ -92,15 +93,24 @@ public abstract class CPPTemplateParameter extends PlatformObject
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
public final String getName() {
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return declarations[0].getSimpleID();
|
||||
public final char[] getNameCharArray() {
|
||||
// Search for the first declaration that has a name.
|
||||
for (IASTName decl : declarations) {
|
||||
if (decl == null)
|
||||
break;
|
||||
|
||||
final char[] result= decl.getSimpleID();
|
||||
if (result.length > 0)
|
||||
return result;
|
||||
}
|
||||
return CharArrayUtils.EMPTY;
|
||||
}
|
||||
|
||||
public int getParameterID() {
|
||||
|
|
Loading…
Add table
Reference in a new issue