aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-07 22:02:30 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-07 22:02:30 +0000
commitc7ed9c60b8ee04b119e23441cae2cfec74536ba9 (patch)
treeb9699bad926b7806e4e3d713177fdd20e45deb20 /lib/Parse/ParseDecl.cpp
parentb737e86bad3ec747dc53889b7eb2cb3c3cd8d782 (diff)
Changes in preparation for nested-name-specifiers.
-When parsing declarators, don't depend on "CurScope->isCXXClassScope() == true" for constructors/destructors -For C++ member declarations, don't depend on "Declarator.getContext() == Declarator::MemberContext" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58866 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 58cc9e2c6b..2b18be02a3 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -1355,6 +1355,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, bool PtrOperator) {
/// conversion-function-id [TODO]
/// '~' class-name
/// template-id [TODO]
+///
void Parser::ParseDirectDeclarator(Declarator &D) {
// Parse the first direct-declarator seen.
if (Tok.is(tok::identifier) && D.mayHaveIdentifier()) {
@@ -1362,31 +1363,35 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
// Determine whether this identifier is a C++ constructor name or
// a normal identifier.
if (getLang().CPlusPlus &&
- CurScope->isCXXClassScope() &&
Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope))
D.SetConstructor(Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope),
Tok.getIdentifierInfo(), Tok.getLocation());
else
D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
ConsumeToken();
- } else if (getLang().CPlusPlus && Tok.is(tok::tilde) &&
- CurScope->isCXXClassScope() && D.mayHaveIdentifier()) {
+ } else if (getLang().CPlusPlus &&
+ Tok.is(tok::tilde) && D.mayHaveIdentifier()) {
// This should be a C++ destructor.
SourceLocation TildeLoc = ConsumeToken();
-
- // Use the next identifier and "~" to form a name for the
- // destructor. This is useful both for diagnostics and for
- // correctness of the parser, since we use presence/absence of the
- // identifier to determine what we parsed.
- // FIXME: We could end up with a template-id here, once we parse
- // templates, and will have to do something different to form the
- // name of the destructor.
- assert(Tok.is(tok::identifier) && "Expected identifier");
- IdentifierInfo *II = Tok.getIdentifierInfo();
- II = &PP.getIdentifierTable().get(std::string("~") + II->getName());
-
- if (TypeTy *Type = ParseClassName())
- D.SetDestructor(Type, II, TildeLoc);
+ if (Tok.is(tok::identifier)) {
+ // Use the next identifier and "~" to form a name for the
+ // destructor. This is useful both for diagnostics and for
+ // correctness of the parser, since we use presence/absence of the
+ // identifier to determine what we parsed.
+ // FIXME: We could end up with a template-id here, once we parse
+ // templates, and will have to do something different to form the
+ // name of the destructor.
+ IdentifierInfo *II = Tok.getIdentifierInfo();
+ II = &PP.getIdentifierTable().get(std::string("~") + II->getName());
+
+ if (TypeTy *Type = ParseClassName())
+ D.SetDestructor(Type, II, TildeLoc);
+ else
+ D.SetIdentifier(0, TildeLoc);
+ } else {
+ Diag(Tok, diag::err_expected_class_name);
+ D.SetIdentifier(0, TildeLoc);
+ }
} else if (Tok.is(tok::kw_operator)) {
SourceLocation OperatorLoc = Tok.getLocation();