LEFT | RIGHT |
1 //===--- ParseDeclCXX.cpp - C++ Declaration Parsing -----------------------===// | 1 //===--- ParseDeclCXX.cpp - C++ Declaration Parsing -----------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the C++ Declaration portions of the Parser interfaces. | 10 // This file implements the C++ Declaration portions of the Parser interfaces. |
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 | 1777 |
1778 // Consume the optional ';' | 1778 // Consume the optional ';' |
1779 if (Tok.is(tok::semi)) | 1779 if (Tok.is(tok::semi)) |
1780 ConsumeToken(); | 1780 ConsumeToken(); |
1781 return; | 1781 return; |
1782 } | 1782 } |
1783 | 1783 |
1784 Decl *FunDecl = | 1784 Decl *FunDecl = |
1785 ParseCXXInlineMethodDef(AS, DeclaratorInfo, TemplateInfo, VS, Init); | 1785 ParseCXXInlineMethodDef(AS, DeclaratorInfo, TemplateInfo, VS, Init); |
1786 | 1786 |
1787 while (LateParsedAttrs.size() > 0) { | 1787 for (unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) { |
1788 LateParsedAttrs.back()->setDecl(FunDecl); | 1788 LateParsedAttrs[i]->setDecl(FunDecl); |
1789 LateParsedAttrs.pop_back(); | |
1790 } | 1789 } |
| 1790 LateParsedAttrs.clear(); |
1791 | 1791 |
1792 // Consume the ';' - it's optional unless we have a delete or default | 1792 // Consume the ';' - it's optional unless we have a delete or default |
1793 if (Tok.is(tok::semi)) { | 1793 if (Tok.is(tok::semi)) { |
1794 ConsumeToken(); | 1794 ConsumeToken(); |
1795 } | 1795 } |
1796 | 1796 |
1797 return; | 1797 return; |
1798 } | 1798 } |
1799 } | 1799 } |
1800 | 1800 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 | 1881 |
1882 if (DeclaratorInfo.isFunctionDeclarator() && | 1882 if (DeclaratorInfo.isFunctionDeclarator() && |
1883 DeclaratorInfo.getDeclSpec().getStorageClassSpec() | 1883 DeclaratorInfo.getDeclSpec().getStorageClassSpec() |
1884 != DeclSpec::SCS_typedef) { | 1884 != DeclSpec::SCS_typedef) { |
1885 HandleMemberFunctionDefaultArgs(DeclaratorInfo, ThisDecl); | 1885 HandleMemberFunctionDefaultArgs(DeclaratorInfo, ThisDecl); |
1886 } | 1886 } |
1887 | 1887 |
1888 DeclaratorInfo.complete(ThisDecl); | 1888 DeclaratorInfo.complete(ThisDecl); |
1889 | 1889 |
1890 // Set the Decl for any late parsed attributes | 1890 // Set the Decl for any late parsed attributes |
1891 while (LateParsedAttrs.size() > 0) { | 1891 for (unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) { |
1892 LateParsedAttrs.back()->setDecl(ThisDecl); | 1892 LateParsedAttrs[i]->setDecl(ThisDecl); |
1893 LateParsedAttrs.pop_back(); | 1893 } |
1894 } | 1894 LateParsedAttrs.clear(); |
1895 | 1895 |
1896 if (HasDeferredInitializer) { | 1896 if (HasDeferredInitializer) { |
1897 if (!getLang().CPlusPlus0x) | 1897 if (!getLang().CPlusPlus0x) |
1898 Diag(Tok, diag::warn_nonstatic_member_init_accepted_as_extension); | 1898 Diag(Tok, diag::warn_nonstatic_member_init_accepted_as_extension); |
1899 | 1899 |
1900 if (DeclaratorInfo.isArrayOfUnknownBound()) { | 1900 if (DeclaratorInfo.isArrayOfUnknownBound()) { |
1901 // C++0x [dcl.array]p3: An array bound may also be omitted when the | 1901 // C++0x [dcl.array]p3: An array bound may also be omitted when the |
1902 // declarator is followed by an initializer.· | 1902 // declarator is followed by an initializer.· |
1903 // | 1903 // |
1904 // A brace-or-equal-initializer for a member-declarator is not an | 1904 // A brace-or-equal-initializer for a member-declarator is not an |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 // C++0x [class.mem]p2: Within the class member-specification, the class is | 2158 // C++0x [class.mem]p2: Within the class member-specification, the class is |
2159 // regarded as complete within function bodies, default arguments, exception- | 2159 // regarded as complete within function bodies, default arguments, exception- |
2160 // specifications, and brace-or-equal-initializers for non-static data | 2160 // specifications, and brace-or-equal-initializers for non-static data |
2161 // members (including such things in nested classes). | 2161 // members (including such things in nested classes). |
2162 // | 2162 // |
2163 // FIXME: Only function bodies and brace-or-equal-initializers are currently | 2163 // FIXME: Only function bodies and brace-or-equal-initializers are currently |
2164 // handled. Fix the others! | 2164 // handled. Fix the others! |
2165 if (TagDecl && NonNestedClass) { | 2165 if (TagDecl && NonNestedClass) { |
2166 // We are not inside a nested class. This class and its nested classes | 2166 // We are not inside a nested class. This class and its nested classes |
2167 // are complete and we can parse the delayed portions of method | 2167 // are complete and we can parse the delayed portions of method |
2168 // declarations and the lexed inline method definitions. | 2168 // declarations and the lexed inline method definitions, along with any |
| 2169 // delayed attributes. |
2169 SourceLocation SavedPrevTokLocation = PrevTokLocation; | 2170 SourceLocation SavedPrevTokLocation = PrevTokLocation; |
2170 ParseLexedAttributes(getCurrentClass()); | 2171 ParseLexedAttributes(getCurrentClass()); |
2171 ParseLexedMethodDeclarations(getCurrentClass()); | 2172 ParseLexedMethodDeclarations(getCurrentClass()); |
2172 ParseLexedMemberInitializers(getCurrentClass()); | 2173 ParseLexedMemberInitializers(getCurrentClass()); |
2173 ParseLexedMethodDefs(getCurrentClass()); | 2174 ParseLexedMethodDefs(getCurrentClass()); |
2174 PrevTokLocation = SavedPrevTokLocation; | 2175 PrevTokLocation = SavedPrevTokLocation; |
2175 } | 2176 } |
2176 | 2177 |
2177 if (TagDecl) | 2178 if (TagDecl) |
2178 Actions.ActOnTagFinishDefinition(getCurScope(), TagDecl, RBraceLoc); | 2179 Actions.ActOnTagFinishDefinition(getCurScope(), TagDecl, RBraceLoc); |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2771 // Parse all the comma separated declarators. | 2772 // Parse all the comma separated declarators. |
2772 ParseCXXClassMemberDeclaration(CurAS); | 2773 ParseCXXClassMemberDeclaration(CurAS); |
2773 } | 2774 } |
2774 | 2775 |
2775 if (Tok.isNot(tok::r_brace)) { | 2776 if (Tok.isNot(tok::r_brace)) { |
2776 Diag(Tok, diag::err_expected_rbrace); | 2777 Diag(Tok, diag::err_expected_rbrace); |
2777 return; | 2778 return; |
2778 } | 2779 } |
2779 ConsumeBrace(); | 2780 ConsumeBrace(); |
2780 } | 2781 } |
LEFT | RIGHT |