]> granicus.if.org Git - clang/commitdiff
Add support for attribute((mode(unwind_word))).
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 7 Jan 2013 19:58:54 +0000 (19:58 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 7 Jan 2013 19:58:54 +0000 (19:58 +0000)
Patch by Nick Lewycky. Fixes pr8703.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171781 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/TargetInfo.h
lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-mode.c

index fbf2d30e4e28f0214581d9e1bc3607e21a37e6c6..328ffd960155b590c7b1a144776cbdea1cea0728 100644 (file)
@@ -338,6 +338,9 @@ public:
     return getTypeWidth(IntMaxType);
   }
 
+  // Return the size of unwind_word for this target.
+  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+
   /// \brief Return the "preferred" register width on this target.
   uint64_t getRegisterWidth() const {
     // Currently we assume the register width on the target matches the pointer
index aabf061c32170bc3c288474c6eed9e23e8ce2bf8..accea53bb8437e1774d0b4a1a5a6e1141662590f 100644 (file)
@@ -3270,6 +3270,10 @@ static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
     if (Str == "pointer")
       DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
     break;
+  case 11:
+    if (Str == "unwind_word")
+      DestWidth = S.Context.Target.getUnwindWordWidth();
+    break;
   }
 
   QualType OldTy;
index 0c5336282c4d1ca0c75e6bc01d7f541026869526..a89c8397e0a04d173d8272d9888e34135beed19a 100644 (file)
@@ -17,6 +17,8 @@ typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machin
 typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
 typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
 
+typedef unsigned unwind_word __attribute((mode(unwind_word)));
+
 int **__attribute((mode(QI)))* i32;  // expected-error{{mode attribute}}
 
 typedef _Complex double c32 __attribute((mode(SC)));