diff options
author | Anders Carlsson <andersca@mac.com> | 2009-04-29 23:19:39 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-04-29 23:19:39 +0000 |
commit | 118b098cd9f418f6b441f319251d1d2fb5e73500 (patch) | |
tree | 70ced447c7d2373be2c64c27bffc720762309903 | |
parent | e5f93b1e58decee05b955f88a739c7a1a437d428 (diff) | |
download | bcm5719-llvm-118b098cd9f418f6b441f319251d1d2fb5e73500.tar.gz bcm5719-llvm-118b098cd9f418f6b441f319251d1d2fb5e73500.zip |
Just because a declaration has the same name as its containing class doesn't mean that it's a constructor. Fixes rdar://problem/6815988.
llvm-svn: 70436
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 20 | ||||
-rw-r--r-- | clang/test/SemaCXX/constructor.cpp | 5 |
2 files changed, 15 insertions, 10 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index ec8923a23b2..59e9ed6acbe 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1982,16 +1982,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { if (Tok.is(tok::identifier)) { assert(Tok.getIdentifierInfo() && "Not an identifier?"); - - // If this identifier is the name of the current class, it's a - // constructor name. - if (Actions.isCurrentClassName(*Tok.getIdentifierInfo(),CurScope)){ - D.setConstructor(Actions.getTypeName(*Tok.getIdentifierInfo(), - Tok.getLocation(), CurScope), - Tok.getLocation()); - // This is a normal identifier. - } else - D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation()); + D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation()); ConsumeToken(); goto PastIdentifier; } else if (Tok.is(tok::annot_template_id)) { @@ -2101,6 +2092,15 @@ void Parser::ParseDirectDeclarator(Declarator &D) { break; } ParseFunctionDeclarator(ConsumeParen(), D); + + // If this identifier is the name of the current class, it's a + // constructor name. + if (IdentifierInfo *II = D.getIdentifier()) { + if (Actions.isCurrentClassName(*II, CurScope)) + D.setConstructor(Actions.getTypeName(*II, D.getIdentifierLoc(), + CurScope), + D.getIdentifierLoc()); + } } else if (Tok.is(tok::l_square)) { ParseBracketDeclarator(D); } else { diff --git a/clang/test/SemaCXX/constructor.cpp b/clang/test/SemaCXX/constructor.cpp index eae51467961..1429cc64527 100644 --- a/clang/test/SemaCXX/constructor.cpp +++ b/clang/test/SemaCXX/constructor.cpp @@ -40,3 +40,8 @@ extern y b; struct Length { Length l() const { return *this; } }; + +// <rdar://problem/6815988> +struct mmst_reg{ + char mmst_reg[10]; +}; |