1
0
Fork 0
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:
Markus Schorn 2012-01-05 08:39:43 +01:00
parent 76163a477c
commit 2e36c7ca14
2 changed files with 31 additions and 10 deletions

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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.XVALUE;
import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
import java.io.BufferedReader;
import java.io.IOException;
@ -9625,4 +9626,24 @@ public class AST2CPPTests extends AST2BaseTest {
IBinding ctor= bh.assertNonProblem("E(){}", 1);
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);
}
}

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -3211,17 +3211,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (name instanceof ICPPASTConversionName)
return;
// accept destructor
final char[] nchars= name.getLookupKey();
if (nchars.length > 0 && nchars[0] == '~')
return;
if (opt == DeclarationOptions.CPP_MEMBER) {
// accept constructor within class body
if (CharArrayUtils.equals(nchars, currentClassName))
return;
// Accept constructor and destructor within class body
final char[] nchars= name.getLookupKey();
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) {
// accept qualified constructor outside of class body
// Accept qualified constructor or destructor outside of class body
return;
}
}