From: Aaron Ballman Date: Tue, 22 Jul 2014 14:09:34 +0000 (+0000) Subject: Improve the checkUInt32Argument() helper function so that it diagnoses integer consta... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=adfdde5ba6b8072d4f3e5894edab12d6d10e0395;p=platform%2Fupstream%2Fllvm.git Improve the checkUInt32Argument() helper function so that it diagnoses integer constants larger than 32-bits. llvm-svn: 213658 --- diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 61683cd..973b63d 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -192,6 +192,12 @@ static bool checkUInt32Argument(Sema &S, const AttributeList &Attr, << Expr->getSourceRange(); return false; } + + if (!I.isIntN(32)) { + S.Diag(Expr->getExprLoc(), diag::err_integer_too_large) << 32; + return false; + } + Val = (uint32_t)I.getZExtValue(); return true; } diff --git a/clang/test/Sema/constructor-attribute.c b/clang/test/Sema/constructor-attribute.c index 1bb69fc..9460c75 100644 --- a/clang/test/Sema/constructor-attribute.c +++ b/clang/test/Sema/constructor-attribute.c @@ -5,6 +5,7 @@ int f() __attribute__((constructor)); int f() __attribute__((constructor(1))); int f() __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}} int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}} +int f() __attribute__((constructor(0x100000000))); // expected-error {{integer constant is larger than the largest 32-bit unsigned integer type}} int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}} int f() __attribute__((destructor));