mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-17 05:55:22 +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:
parent
0d801f0615
commit
e876bb04f2
2 changed files with 14 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue