[PATCH] D17248: [Sema] PR26444 fix crash when alignment value is <= 2**16

don hinton via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 14 14:50:48 PST 2016


hintonda created this revision.
hintonda added a reviewer: majnemer.
hintonda added a subscriber: cfe-commits.

Sema allows max values up to 2**28, use unsigned instead of unsiged
short to hold values that large.

http://reviews.llvm.org/D17248

Files:
  lib/CodeGen/CGValue.h
  test/Sema/attr-aligned.c

Index: test/Sema/attr-aligned.c
===================================================================
--- test/Sema/attr-aligned.c
+++ test/Sema/attr-aligned.c
@@ -2,6 +2,7 @@
 
 int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
 int y __attribute__((aligned(1 << 29))); // expected-error {{requested alignment must be 268435456 bytes or smaller}}
+int y __attribute__((aligned(1 << 28)));
 
 // PR3254
 short g0[3] __attribute__((aligned));
Index: lib/CodeGen/CGValue.h
===================================================================
--- lib/CodeGen/CGValue.h
+++ lib/CodeGen/CGValue.h
@@ -445,7 +445,7 @@
   // Qualifiers
   Qualifiers Quals;
 
-  unsigned short Alignment;
+  unsigned Alignment;
 
   /// DestructedFlag - This is set to true if some external code is
   /// responsible for setting up a destructor for the slot.  Otherwise


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17248.47935.patch
Type: text/x-patch
Size: 891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160214/b1c4bb97/attachment.bin>


More information about the cfe-commits mailing list