diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-11-05 15:47:02 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-11-05 15:47:02 +0000 |
commit | 2ac67239b4ab81c439ffcc56367574c869f87dae (patch) | |
tree | 632ec89a17ac419bf889877d83b4aa279fa3e4b2 | |
parent | ff87603939b2620dcf345c0fa2971314394a77c3 (diff) |
Parse C++0x constexpr. Test case follows when this does something useful.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86135 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/DeclSpec.h | 12 | ||||
-rw-r--r-- | lib/Parse/DeclSpec.cpp | 8 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 3 |
4 files changed, 28 insertions, 1 deletions
diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h index dccb8bcfeb..d539508e97 100644 --- a/include/clang/Parse/DeclSpec.h +++ b/include/clang/Parse/DeclSpec.h @@ -131,6 +131,9 @@ private: // friend-specifier bool Friend_specified : 1; + // constexpr-specifier + bool Constexpr_specified : 1; + /// TypeRep - This contains action-specific information about a specific TST. /// For example, for a typedef or struct, it might contain the declaration for /// these. @@ -155,7 +158,7 @@ private: SourceLocation TSWLoc, TSCLoc, TSSLoc, TSTLoc; SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc; SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc; - SourceLocation FriendLoc; + SourceLocation FriendLoc, ConstexprLoc; DeclSpec(const DeclSpec&); // DO NOT IMPLEMENT void operator=(const DeclSpec&); // DO NOT IMPLEMENT @@ -174,6 +177,7 @@ public: FS_virtual_specified(false), FS_explicit_specified(false), Friend_specified(false), + Constexpr_specified(false), TypeRep(0), AttrList(0), ProtocolQualifiers(0), @@ -309,9 +313,15 @@ public: bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); + bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, + unsigned &DiagID); + bool isFriendSpecified() const { return Friend_specified; } SourceLocation getFriendSpecLoc() const { return FriendLoc; } + bool isConstexprSpecified() const { return Constexpr_specified; } + SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } + /// AddAttributes - contatenates two attribute lists. /// The GCC attribute syntax allows for the following: /// diff --git a/lib/Parse/DeclSpec.cpp b/lib/Parse/DeclSpec.cpp index 3436900027..0a4e036e43 100644 --- a/lib/Parse/DeclSpec.cpp +++ b/lib/Parse/DeclSpec.cpp @@ -334,6 +334,14 @@ bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, return false; } +bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, + unsigned &DiagID) { + // 'constexpr constexpr' is ok. + Constexpr_specified = true; + ConstexprLoc = Loc; + return false; +} + void DeclSpec::setProtocolQualifiers(const ActionBase::DeclPtrTy *Protos, unsigned NP, SourceLocation *ProtoLocs, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e905553fd8..99752b5950 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -769,6 +769,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, /// [C++] 'virtual' /// [C++] 'explicit' /// 'friend': [C++ dcl.friend] +/// 'constexpr': [C++0x dcl.constexpr] /// void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, @@ -1070,6 +1071,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, } break; + // constexpr + case tok::kw_constexpr: + isInvalid = DS.SetConstexprSpec(Loc, PrevSpec, DiagID); + break; + // type-specifier case tok::kw_short: isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_short, Loc, PrevSpec, diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index eb6e935405..7ac2977109 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -503,6 +503,7 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, /// function-specifier /// 'friend' /// 'typedef' +/// [C++0x] 'constexpr' /// [GNU] attributes declaration-specifiers[opt] /// /// storage-class-specifier: @@ -615,9 +616,11 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() { // function-specifier // 'friend' // 'typedef' + // 'constexpr' case tok::kw_friend: case tok::kw_typedef: + case tok::kw_constexpr: // storage-class-specifier case tok::kw_register: case tok::kw_static: |