a destructor.
llvm-svn: 76436
def err_unexpected_typedef_ident : Error<
"unexpected type name %0: expected identifier">;
def err_expected_class_name : Error<"expected class name">;
+def err_destructor_class_name : Error<
+ "destructor name must be same as the class name">;
def err_unspecified_vla_size_with_static : Error<
"'static' may not be used with an unspecified variable length array size">;
//===--------------------------------------------------------------------===//
// C++ 9: classes [class] and C structs/unions.
TypeResult ParseClassName(SourceLocation &EndLocation,
- const CXXScopeSpec *SS = 0);
+ const CXXScopeSpec *SS = 0,
+ bool DestrExpected = false);
void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc,
DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
SourceLocation NameLoc = Tok.getLocation();
SourceLocation EndLoc;
CXXScopeSpec *SS = afterCXXScope? &D.getCXXScopeSpec() : 0;
- TypeResult Type = ParseClassName(EndLoc, SS);
+ TypeResult Type = ParseClassName(EndLoc, SS, true);
if (Type.isInvalid())
D.SetIdentifier(0, TildeLoc);
else
D.setDestructor(Type.get(), TildeLoc, NameLoc);
} else {
- Diag(Tok, diag::err_expected_class_name);
+ Diag(Tok, diag::err_destructor_class_name);
D.SetIdentifier(0, TildeLoc);
}
goto PastIdentifier;
/// simple-template-id
///
Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
- const CXXScopeSpec *SS) {
+ const CXXScopeSpec *SS,
+ bool DestrExpected) {
// Check whether we have a template-id that names a type.
if (Tok.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId
TypeTy *Type = Actions.getTypeName(*Tok.getIdentifierInfo(),
Tok.getLocation(), CurScope, SS);
if (!Type) {
- Diag(Tok, diag::err_expected_class_name);
+ Diag(Tok, DestrExpected ? diag::err_destructor_class_name
+ : diag::err_expected_class_name);
return true;
}
~F(); // expected-error {{destructor cannot be redeclared}}
};
-~; // expected-error {{expected class name}}
-~undef(); // expected-error {{expected class name}}
+~; // expected-error {{destructor name must be same as the class name}}
+~undef(); // expected-error {{destructor name must be same as the class name}}
~F(){} // expected-error {{destructor must be a non-static member function}}
struct G {