mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 367590: Destructor with wrong name.
This commit is contained in:
parent
76163a477c
commit
2e36c7ca14
2 changed files with 31 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE;
|
||||||
|
import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -9625,4 +9626,24 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IBinding ctor= bh.assertNonProblem("E(){}", 1);
|
IBinding ctor= bh.assertNonProblem("E(){}", 1);
|
||||||
assertTrue(ctor instanceof ICPPConstructor);
|
assertTrue(ctor instanceof ICPPConstructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct S;
|
||||||
|
// struct S {
|
||||||
|
// S();
|
||||||
|
// ~S();
|
||||||
|
// T();
|
||||||
|
// ~T();
|
||||||
|
// };
|
||||||
|
public void testErrorForDestructorWithWrongName_367590() throws Exception {
|
||||||
|
IASTTranslationUnit tu= parse(getAboveComment(), CPP, false, false);
|
||||||
|
IASTCompositeTypeSpecifier S;
|
||||||
|
IASTProblemDeclaration p;
|
||||||
|
IASTSimpleDeclaration s;
|
||||||
|
|
||||||
|
S= getCompositeType(tu, 1);
|
||||||
|
s= getDeclaration(S, 0);
|
||||||
|
s= getDeclaration(S, 1);
|
||||||
|
p= getDeclaration(S, 2);
|
||||||
|
p= getDeclaration(S, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2011 IBM Corporation and others.
|
* Copyright (c) 2002, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -3211,17 +3211,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (name instanceof ICPPASTConversionName)
|
if (name instanceof ICPPASTConversionName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// accept destructor
|
|
||||||
final char[] nchars= name.getLookupKey();
|
|
||||||
if (nchars.length > 0 && nchars[0] == '~')
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (opt == DeclarationOptions.CPP_MEMBER) {
|
if (opt == DeclarationOptions.CPP_MEMBER) {
|
||||||
// accept constructor within class body
|
// Accept constructor and destructor within class body
|
||||||
if (CharArrayUtils.equals(nchars, currentClassName))
|
final char[] nchars= name.getLookupKey();
|
||||||
return;
|
if (nchars.length > 0 && currentClassName != null) {
|
||||||
|
final int start= nchars[0] == '~' ? 1 : 0;
|
||||||
|
if (CharArrayUtils.equals(nchars, start, nchars.length-start, currentClassName))
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else if (isQualified) {
|
} else if (isQualified) {
|
||||||
// accept qualified constructor outside of class body
|
// Accept qualified constructor or destructor outside of class body
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue