Small patch to move the type qualifier enum to Basic for sharing between Sema (DeclSpec) and AST (Qualifiers).

AST uses a value (CVRMask = Const | Restrict | Volatile) that DeclSpec does not, and so the move introduced a warning for the switch in DeclSpec::getSpecifierName. I dealt with it by moving the value out of the enum and into AST.

- John
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index d01ba94..7d5d864 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/Linkage.h"
 #include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Basic/Visibility.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateName.h"
@@ -109,13 +110,11 @@ namespace clang {
 /// * Objective C: the GC attributes (none, weak, or strong)
 class Qualifiers {
 public:
-  // FIXME: Why not just move this enum to Basic?
-  enum TQ { // NOTE: These flags must be kept in sync with DeclSpec::TQ.
-    Const    = 0x1,
-    Restrict = 0x2,
-    Volatile = 0x4,
-    CVRMask = Const | Volatile | Restrict
-  };
+  typedef TypeQualifier TQ;
+  static const TQ Const = clang::TQ_const;
+  static const TQ Restrict = clang::TQ_restrict;
+  static const TQ Volatile = clang::TQ_volatile;
+  static const TQ CVRMask = static_cast<TQ>(Const | Restrict | Volatile);
 
   enum GC {
     GCNone = 0,
diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h
index dfff637..05a97e4 100644
--- a/include/clang/Basic/Specifiers.h
+++ b/include/clang/Basic/Specifiers.h
@@ -16,6 +16,14 @@
 #define LLVM_CLANG_BASIC_SPECIFIERS_H
 
 namespace clang {
+  /// \brief Type qualifiers.
+  enum TypeQualifier {
+    TQ_unspecified = 0x0,
+    TQ_const       = 0x1,
+    TQ_restrict    = 0x2,
+    TQ_volatile    = 0x4
+  };
+
   /// \brief Specifies the width of a type, e.g., short, long, or long long.
   enum TypeSpecifierWidth {
     TSW_unspecified,
diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h
index 1380b2a..eac4260 100644
--- a/include/clang/Sema/DeclSpec.h
+++ b/include/clang/Sema/DeclSpec.h
@@ -264,13 +264,12 @@ public:
   static const TST TST_atomic = clang::TST_atomic;
   static const TST TST_error = clang::TST_error;
 
-  // type-qualifiers
-  enum TQ {   // NOTE: These flags must be kept in sync with Qualifiers::TQ.
-    TQ_unspecified = 0,
-    TQ_const       = 1,
-    TQ_restrict    = 2,
-    TQ_volatile    = 4
-  };
+  // Import type qualifiers.
+  typedef TypeQualifier TQ;
+  static const TQ TQ_unspecified = clang::TQ_unspecified;
+  static const TQ TQ_const = clang::TQ_const;
+  static const TQ TQ_restrict = clang::TQ_restrict;
+  static const TQ TQ_volatile = clang::TQ_volatile;
 
   /// ParsedSpecifiers - Flags to query which specifiers were applied.  This is
   /// returned by getParsedSpecifiers.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to