[cfe-commits] r86135 - in /cfe/trunk: include/clang/Parse/DeclSpec.h lib/Parse/DeclSpec.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseTentative.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu Nov 5 07:47:02 PST 2009


Author: cornedbee
Date: Thu Nov  5 09:47:02 2009
New Revision: 86135

URL: http://llvm.org/viewvc/llvm-project?rev=86135&view=rev
Log:
Parse C++0x constexpr. Test case follows when this does something useful.

Modified:
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/lib/Parse/DeclSpec.cpp
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseTentative.cpp

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=86135&r1=86134&r2=86135&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Thu Nov  5 09:47:02 2009
@@ -131,6 +131,9 @@
   // 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 @@
   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 @@
       FS_virtual_specified(false),
       FS_explicit_specified(false),
       Friend_specified(false),
+      Constexpr_specified(false),
       TypeRep(0),
       AttrList(0),
       ProtocolQualifiers(0),
@@ -309,9 +313,15 @@
   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:
   ///

Modified: cfe/trunk/lib/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/DeclSpec.cpp?rev=86135&r1=86134&r2=86135&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Parse/DeclSpec.cpp Thu Nov  5 09:47:02 2009
@@ -334,6 +334,14 @@
   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,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=86135&r1=86134&r2=86135&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Nov  5 09:47:02 2009
@@ -769,6 +769,7 @@
 /// [C++]   'virtual'
 /// [C++]   'explicit'
 ///       'friend': [C++ dcl.friend]
+///       'constexpr': [C++0x dcl.constexpr]
 
 ///
 void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
@@ -1070,6 +1071,11 @@
       }
       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,

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=86135&r1=86134&r2=86135&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Thu Nov  5 09:47:02 2009
@@ -503,6 +503,7 @@
 ///           function-specifier
 ///           'friend'
 ///           'typedef'
+/// [C++0x]   'constexpr'
 /// [GNU]     attributes declaration-specifiers[opt]
 ///
 ///         storage-class-specifier:
@@ -615,9 +616,11 @@
     //   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:





More information about the cfe-commits mailing list