Skip to content

Commit

Permalink
[Sema] PR26444 fix crash when alignment value is >= 2**16
Browse files Browse the repository at this point in the history
Sema allows max values up to 2**28, use unsigned instead of unsiged
short to hold values that large.

Differential Revision: http://reviews.llvm.org/D17248

Patch by Don Hinton!

llvm-svn: 262466
  • Loading branch information
majnemer committed Mar 2, 2016
1 parent 5aadde1 commit ec4b734
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGValue.h
Expand Up @@ -445,7 +445,7 @@ class AggValueSlot {
// 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
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Sema/attr-aligned.c
Expand Up @@ -3,6 +3,9 @@
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}}

// PR26444
int y __attribute__((aligned(1 << 28)));

// PR3254
short g0[3] __attribute__((aligned));
short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
Expand Down

0 comments on commit ec4b734

Please sign in to comment.