1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 368419 - FP in members not initialized in constructor

This commit is contained in:
Marc-Andre Laperle 2012-03-07 01:33:16 -05:00
parent 9634e0c57f
commit 0a9a95adcd
2 changed files with 25 additions and 3 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Anton Gorenkov
* Copyright (c) 2011, 2012 Anton Gorenkov and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Anton Gorenkov - initial implementation
* Marc-Andre Laperle
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers;
@ -113,7 +114,7 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
if (fBinding instanceof ICPPMethod) {
ICPPMethod method = (ICPPMethod)fBinding;
ICompositeType constructorOwner = actualConstructorFields.iterator().next().getCompositeTypeOwner();
if (constructorOwner == method.getClassOwner() && !method.getType().isConst()) {
if (constructorOwner.equals(method.getClassOwner()) && !method.getType().isConst()) {
skipCurrentConstructor = true;
}
} else if (fBinding instanceof ICPPFunction) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Anton Gorenkov
* Copyright (c) 2011, 2012 Anton Gorenkov and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Anton Gorenkov - initial implementation
* Marc-Andre Laperle
*******************************************************************************/
package org.eclipse.cdt.codan.core.internal.checkers;
@ -476,4 +477,24 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment());
checkErrorLines(8,9,10,11);
}
// @file:test.h
// class C {
// int field;
// C();
// void initObject();
//};
// @file:test.cpp
// #include "test.h"
// C::C() {
// initObject();
// }
public void testBug368419_methodDeclarationInOtherFile() throws Exception {
CharSequence[] code = getContents(2);
loadcode(code[0].toString());
loadcode(code[1].toString());
runOnProject();
checkNoErrors();
}
}