summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-07-01 21:55:12 (EDT)
committerSergey Prigogin2013-07-07 19:25:44 (EDT)
commit44b957a28e6a2129275746c9c63ed5822306dcd1 (patch)
treeed45718a12f863b367c452b7b718b81aed7c730f
parent1df606bb26322b5ac3b68a5c97f022964d22e3ac (diff)
downloadorg.eclipse.cdt-44b957a28e6a2129275746c9c63ed5822306dcd1.zip
org.eclipse.cdt-44b957a28e6a2129275746c9c63ed5822306dcd1.tar.gz
org.eclipse.cdt-44b957a28e6a2129275746c9c63ed5822306dcd1.tar.bz2
Bug 408303 - [C++11] Incorrect member not initialized warnings forrefs/changes/77/14177/2
template class's defaulted constructors Change-Id: I61064421c2cee405c9a915abe500c94fa4423eef Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/14177 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java6
2 files changed, 19 insertions, 1 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java
index be2e57f..33a156f 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java
@@ -590,6 +590,8 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
}
// struct S {
+ // int i;
+ //
// S(S&) = default;
// S(const S&) = default;
// S(volatile S&) = default;
@@ -604,6 +606,18 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
checkNoErrors();
}
+ // template <typename T>
+ // struct S {
+ // int i;
+ //
+ // S(const S&) = default;
+ // S(S&&) = default;
+ // };
+ public void testBug408303_defaultCopyOrMoveConstructorInTemplate() throws Exception {
+ loadCodeAndRun(getAboveComment());
+ checkNoErrors();
+ }
+
// struct A {
// A(int n) : waldo(n) {}
// A() : A(42) {}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java
index 60fd014..523fd65 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java
@@ -14,6 +14,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/**
@@ -57,7 +58,10 @@ public class SemanticQueries {
return false;
firstArgumentType = firstArgReferenceType.getType();
firstArgumentType = SemanticUtil.getNestedType(firstArgumentType, CVTYPE);
- return firstArgumentType.isSameType(constructor.getClassOwner());
+ ICPPClassType classType = constructor.getClassOwner();
+ if (classType instanceof ICPPClassTemplate)
+ classType = CPPTemplates.createDeferredInstance((ICPPClassTemplate) classType);
+ return firstArgumentType.isSameType(classType);
}
private static boolean isCallableWithNumberOfArguments(ICPPFunction function, int numArguments) {