[PATCH] D16301: Allow mode attribute for member variables again

Stephan Bergmann via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 18 12:39:31 PST 2016


sberg created this revision.
sberg added reviewers: ABataev, aaron.ballman.
sberg added a subscriber: cfe-commits.

...after r257868 "PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration" (presumably accidentally) restricted it to variables and typedefs, excluding member variables (aka fields).  That broke building LibreOffice, which, in bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx, contains a "typedef-unwound" copy of struct _Unwind_Except from GCC's libgcc/unwind-generic.h.

http://reviews.llvm.org/D16301

Files:
  include/clang/Basic/Attr.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-mode.c

Index: test/Sema/attr-mode.c
===================================================================
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -76,3 +76,7 @@
 #else
 #error Unknown test architecture.
 #endif
+
+struct S {
+  int n __attribute((mode(HI)));
+};
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3392,7 +3392,7 @@
   if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
     OldTy = TD->getUnderlyingType();
   else
-    OldTy = cast<VarDecl>(D)->getType();
+    OldTy = cast<ValueDecl>(D)->getType();
 
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
@@ -3465,7 +3465,7 @@
   if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
     TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
   else
-    cast<VarDecl>(D)->setType(NewTy);
+    cast<ValueDecl>(D)->setType(NewTy);
 
   D->addAttr(::new (S.Context)
              ModeAttr(Attr.getRange(), S.Context, Name,
Index: include/clang/Basic/Attr.td
===================================================================
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -887,7 +887,7 @@
 
 def Mode : Attr {
   let Spellings = [GCC<"mode">];
-  let Subjects = SubjectList<[Var, TypedefName], ErrorDiag,
+  let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag,
                              "ExpectedVariableOrTypedef">;
   let Args = [IdentifierArgument<"Mode">];
   let Documentation = [Undocumented];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16301.45203.patch
Type: text/x-patch
Size: 1600 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160118/270d4ff0/attachment.bin>


More information about the cfe-commits mailing list