Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVladimir Hirsl2004-10-12 01:50:18 -0400
committerVladimir Hirsl2004-10-12 01:50:18 -0400
commitf1617823d5493bcaf686a2f9e05f4a8d0b1f6f21 (patch)
treeb7669f1ebf59953680874baad55e16ba7a1b4ccb /core
parentacf19e50fa65590efee798b6f494aa295ba8a029 (diff)
downloadorg.eclipse.cdt-f1617823d5493bcaf686a2f9e05f4a8d0b1f6f21.tar.gz
org.eclipse.cdt-f1617823d5493bcaf686a2f9e05f4a8d0b1f6f21.tar.xz
org.eclipse.cdt-f1617823d5493bcaf686a2f9e05f4a8d0b1f6f21.zip
Fix for PR 69604 [Templates] Instantiating template with deferred template instance.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java45
-rw-r--r--core/org.eclipse.cdt.core/ChangeLog8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java11
4 files changed, 68 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java
index 4ed0bbe4769..75d8c8f81cb 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java
@@ -1194,4 +1194,49 @@ public class CompleteParseASTTemplateTest extends CompleteParseBaseTest {
assertTrue(ad != null);
assertAllReferences(4, createTaskList(new Task(tp, 2), new Task(x), new Task(y)));
}
+
+ public void testInstantiatingTemplateWithDTI_bug69604() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template <typename T> class A {}; \n");
+ writer.write("template <typename U> class B {}; \n");
+ writer.write("template <typename V, typename W = B< A<V> > > class C {}; \n");
+ writer.write("C<int> c_int;\n");
+ Iterator i = parse(writer.toString()).getDeclarations();
+ IASTTemplateDeclaration td1 = (IASTTemplateDeclaration) i.next();
+ IASTClassSpecifier cs1 = (IASTClassSpecifier) td1.getOwnedDeclaration();
+ IASTTemplateDeclaration td2 = (IASTTemplateDeclaration) i.next();
+ IASTClassSpecifier cs2 = (IASTClassSpecifier) td2.getOwnedDeclaration();
+ IASTTemplateDeclaration td3 = (IASTTemplateDeclaration) i.next();
+ IASTClassSpecifier cs3 = (IASTClassSpecifier) td3.getOwnedDeclaration();
+ Iterator j = td3.getTemplateParameters();
+ IASTTemplateParameter tp1 = (IASTTemplateParameter) j.next();
+ IASTTemplateParameter tp2 = (IASTTemplateParameter) j.next();
+ assertFalse(j.hasNext());
+ IASTVariable cr = (IASTVariable) i.next();
+ assertFalse(i.hasNext());
+ assertReferenceTask(new Task(cs1, 1));
+ assertReferenceTask(new Task(cs2, 1));
+ }
+
+ public void testTemplatedBaseClass_bug74359() throws Exception {
+ Writer writer = new StringWriter();
+ writer.write("template <typename T> class A {}; \n");
+ writer.write("template <typename U> class B {}; \n");
+ writer.write("template <typename V> class C : public B<A<V> > {}; \n");
+ writer.write("C<int> c_int;\n");
+ Iterator i = parse(writer.toString()).getDeclarations();
+ IASTTemplateDeclaration td1 = (IASTTemplateDeclaration) i.next();
+ IASTClassSpecifier cs1 = (IASTClassSpecifier) td1.getOwnedDeclaration();
+ IASTTemplateDeclaration td2 = (IASTTemplateDeclaration) i.next();
+ IASTClassSpecifier cs2 = (IASTClassSpecifier) td2.getOwnedDeclaration();
+ IASTTemplateDeclaration td3 = (IASTTemplateDeclaration) i.next();
+ IASTClassSpecifier cs3 = (IASTClassSpecifier) td3.getOwnedDeclaration();
+ Iterator j = cs3.getBaseClauses();
+ IASTBaseSpecifier bs = (IASTBaseSpecifier) j.next();
+ assertFalse(j.hasNext());
+ IASTVariable cr = (IASTVariable) i.next();
+ assertFalse(i.hasNext());
+ assertReferenceTask(new Task(cs1, 1));
+ assertReferenceTask(new Task(cs2, 1));
+ }
}
diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog
index 9fdbbf71878..dd4b8242773 100644
--- a/core/org.eclipse.cdt.core/ChangeLog
+++ b/core/org.eclipse.cdt.core/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-12 Vladimir Hirsl
+
+ Fix for PR 69604 [Templates] Instantiating template with deferred template instance
+ Original Andrew's patch + a cleanup of processed deferred instntiations.
+
+ * parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
+ * parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol
+
2004-10-06 Vladimir Hirsl
Fix for PR 75728 [ParserSymbolTable] NPE in TypeInfoProvider.newTypeInfo
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
index b925b65565d..e537caf1c59 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DeferredTemplateInstance.java
@@ -63,7 +63,12 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
deferredTemplate = (ITemplateSymbol) i.getTypeSymbol();
}
+ // process any accumulated deferred instances, we may need them
+ if (template instanceof TemplateSymbol)
+ ((TemplateSymbol)template).processDeferredInstantiations();
+
ISymbol instance = deferredTemplate.instantiate( newArgs );
+
// if( !( instance instanceof IDeferredTemplateInstance ) )
// return instance.instantiate( template, argMap );
// else
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java
index 1e5ebc367eb..62a4ab74cf1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TemplateSymbol.java
@@ -98,7 +98,8 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
if( arg.isType( ITypeInfo.t_type ) ){
if( arg.getTypeSymbol() == null )
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
- else if( arg.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) )
+ else if( arg.getTypeSymbol().isType( ITypeInfo.t_templateParameter ) ||
+ arg.getTypeSymbol() instanceof IDeferredTemplateInstance )
return deferredInstance( arguments );
}
} else {
@@ -115,6 +116,13 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) arg.getTypeSymbol();
arg = TypeInfoProvider.newTypeInfo( arg );
arg.setTypeSymbol( deferred.instantiate( this, map ) );
+// // IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) info.getTypeSymbol();
+// ITypeInfo newInfo = TypeInfoProvider.newTypeInfo( arg );
+// //newInfo.setTypeSymbol( deferred.instantiate( template, argMap ) );
+// template.registerDeferredInstatiation( newInfo, deferred, ITemplateSymbol.DeferredKind.TYPE_SYMBOL, map );
+// newInfo.setTypeSymbol( deferred );
+// // process any accumulated deferred instances, we may need them
+// processDeferredInstantiations();
}
} else {
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
@@ -465,6 +473,7 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
throw new ParserSymbolTableException( ParserSymbolTableException.r_RecursiveTemplate );
}
}
+ _deferredInstantiations.clear();
_processingDeferred = false;
}

Back to the top