1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-17 22:15:23 +02:00

Bug 400673 - [c++11] Unnecessary warning in class constructor (not

initialized member) when using "in class member initialization" 

Change-Id: I4e6af3b0927d44f0bb5417d7788fc9a026f8fb7c
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
Reviewed-on: https://git.eclipse.org/r/14397
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Nathan Ridge 2013-07-08 22:23:22 -04:00 committed by Sergey Prigogin
parent 0d801f0615
commit e876bb04f2
2 changed files with 14 additions and 1 deletions

View file

@ -92,7 +92,11 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
// Add all class fields
for (IField field : ClassTypeHelper.getDeclaredFields(constructor.getClassOwner(), declaration)) {
if (isSimpleType(field.getType()) && !field.isStatic()) {
fieldsInConstructor.add(field);
// In C++11, a field may have an initial value specified at its declaration.
// Such a field does not need to be initialized in the constructor as well.
if (field.getInitialValue() == null) {
fieldsInConstructor.add(field);
}
}
}
}

View file

@ -638,4 +638,13 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
// struct A {
// A() {};
// int x = 0;
// };
public void testNonstaticDataMemberInitializer_400673() throws Exception {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
}