Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335122 - DeclarationGenerator asserts for templated types with namespace
Summary: DeclarationGenerator asserts for templated types with namespace
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Marc-André Laperle CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-23 12:29 EST by Marc-André Laperle CLA
Modified: 2011-03-17 03:44 EDT (History)
1 user (show)

See Also:
malaperle: review? (emanuel)


Attachments
DeclarationGenerator, template with namespace patch (2.93 KB, patch)
2011-01-24 09:59 EST, Marc-André Laperle CLA
no flags Details | Diff
DeclarationGenerator, template with namespace patch (4.09 KB, patch)
2011-01-24 10:55 EST, Marc-André Laperle CLA
malaperle: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2011-01-23 12:29:51 EST
Using HEAD as of today.

#include <vector>

template<typename T>
std::vector<T> test(){};

int main() {
	test<int>();
	return 0;
}


Try extracting 'test<int>()', it will assert:

java.lang.AssertionError
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId.setTemplateName(CPPASTTemplateId.java:71)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId.<init>(CPPASTTemplateId.java:46)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory.newTemplateId(CPPNodeFactory.java:538)
	at org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl.getDeclSpecForTemplate(DeclarationGeneratorImpl.java:307)
	at org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl.createDeclSpecFromType(DeclarationGeneratorImpl.java:119)
Comment 1 Marc-André Laperle CLA 2011-01-24 09:44:24 EST
BTW, assertions need to be enable to reproduce this, by adding -ea in the VM arguments.
Comment 2 Marc-André Laperle CLA 2011-01-24 09:59:20 EST
Created attachment 187425 [details]
DeclarationGenerator, template with namespace patch

Here is a patch. There is no need for a new test because if assertions are enabled, the namespace test from bug 331963 will fail.
Comment 3 Marc-André Laperle CLA 2011-01-24 10:46:16 EST
Comment on attachment 187425 [details]
DeclarationGenerator, template with namespace patch

Oops, this patch is missing a change
Comment 4 Marc-André Laperle CLA 2011-01-24 10:55:08 EST
Created attachment 187435 [details]
DeclarationGenerator, template with namespace patch

NameWriter.isDependentName(...) contains a call to resolveBinding so the index needs to be locked in CRefactoring.createChange
Comment 5 Marc-André Laperle CLA 2011-03-12 15:03:40 EST
Comment on attachment 187435 [details]
DeclarationGenerator, template with namespace patch

Fixed in HEAD.
Comment 6 Marc-André Laperle CLA 2011-03-12 15:05:15 EST
Emanuel, can you review?
Comment 8 CDT Genie CLA 2011-03-13 07:23:53 EDT
*** cdt cvs genie on behalf of mlaperle ***
Bug 335122 - Fix index locking issue discovered by running the 'old' ImplementMethod test (new one being Bug 292851). Should fix build not ending.

[*] CRefactoring.java 1.23 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java?root=Tools_Project&r1=1.22&r2=1.23
Comment 9 Emanuel Graf CLA 2011-03-17 03:44:49 EDT
we need to have a look at the index locking, the AST is created in the checkInitialConditions method and used in all the following methods. So the lock should be held the hole time. The lockIndex() method has a side effect to initialize the fIndex field, so locking the index in the Runner class will effect the AST produced in the inital conditions check.