summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/shift.c
Commit message (Collapse)AuthorAgeFilesLines
* [APSInt][OpenMP] Fix isNegative, etc. for unsigned typesJoel E. Denny2019-04-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, APSInt inherits APInt::isNegative, which merely checks the sign bit without regard to whether the type is actually signed. isNonNegative and isStrictlyPositive call isNegative and so are also affected. This patch adjusts APSInt to override isNegative, isNonNegative, and isStrictlyPositive with implementations that consider whether the type is signed. A large set of Clang OpenMP tests are affected. Without this patch, these tests assume that `true` is not a valid argument for clauses like `collapse`. Indeed, `true` fails APInt::isStrictlyPositive but not APSInt::isStrictlyPositive. This patch adjusts those tests to assume `true` should be accepted. This patch also adds tests revealing various other similar fixes due to APSInt::isNegative calls in Clang's ExprConstant.cpp and SemaExpr.cpp: `++` and `--` overflow in `constexpr`, evaluated object size based on `alloc_size`, `<<` and `>>` shift count validation, and OpenMP array section validation. Reviewed By: lebedev.ri, ABataev, hfinkel Differential Revision: https://reviews.llvm.org/D59712 llvm-svn: 359012
* Fix For pr28288 - Error message in shift of vector valuesAndrey Bokhanko2016-08-121-0/+11
| | | | | | | | | | This fixes an error in type checking of shift of vector values. Patch by Vladimir Yakovlev. Differential Revision: https://reviews.llvm.org/D21678 llvm-svn: 278501
* [Sema] Warn when shifting a negative value.Davide Italiano2015-07-061-2/+3
| | | | | | | | | | | | | | | Example: % ./clang -Wshift-negative-value emit.c emit.c:3:14: warning: shifting a negative signed value is undefined [-Wshift-negative-value] int a = -1 << 3; ~~ ^ 1 warning generated. PR: 24026 Differential Revision: http://reviews.llvm.org/D10938 Reviewed by: rsmith llvm-svn: 241478
* Move a bunch of tests to directly use the CC1 layer. This at least savesChandler Carruth2014-01-151-1/+1
| | | | | | | | | | | a subprocess invocation which is pretty significant on Windows. It also likely saves a bunch of thrashing the host machine needlessly. Finally it makes the tests much more predictable and less dependent on the host. For example 'header_lookup1.c' was passing '-fno-ms-extensions' just to thwart the host detection adding it into the compilation. By runnig CC1 directly we don't have to deal with such oddities. llvm-svn: 199308
* Sema: show shift result in hexadecimalTed Kremenek2011-06-151-1/+1
| | | | | | | | | | | | | | | | | Change the output for -Wshift-overflow and -Wshift-sign-overflow to an unsigned hexadecimal. It makes more sense for looking at bits than a signed decimal does. Also, change the diagnostic's wording from "overrides" to "sets". This uses a new optional argument in APInt::toString() that adds the '0x' prefix to hexademical numbers. This fixes PR 9651. Patch by nobled@dreamwidth.org! llvm-svn: 133033
* Don't warning about shifting by too many bits in dead code.Ted Kremenek2011-03-011-0/+6
| | | | llvm-svn: 126770
* Don't wanr about "negative shifts" in code that is unreachable. Fixes PR 5544.Ted Kremenek2011-03-011-0/+4
| | | | llvm-svn: 126762
* Simplify messages as requested by Chris.Chandler Carruth2011-02-241-3/+3
| | | | llvm-svn: 126389
* Implement a warning for known shift overflows on constant shiftChandler Carruth2011-02-231-1/+19
| | | | | | | | | | | | | | | | | | | | | | | expressions. Consider the code: int64_t i = 10 << 30; This compiles fine, but most developers expect it to produce the value for 10 gigs, not -2 gigs. This is actually undefined behavior because the LHS is a signed integer type. The warning is currently gated behind -Wshift-overflow. There is a special case where only the sign bit is overridden that gets a custom error message and is by default ignored. This case is much less likely to cause observed buggy behavior, it's just undefined behavior according to the spec. This warning can be enabled with -Wshift-sign-overflow. Original patch by Oleg Slezberg, with style tweaks and some correctness fixes by me. llvm-svn: 126342
* This really seems like a boring set of fixes to our tests to make them moreChandler Carruth2010-11-161-1/+1
| | | | | | | independent of the underlying system. Let me know if any of these are too aggressive. llvm-svn: 119345
* Update tests to use %clang instead of 'clang', and forcibly disable use of 'Daniel Dunbar2009-12-151-1/+1
| | | | | | | clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to garbage). llvm-svn: 91460
* Use clang to run tests which include headers from the system.Daniel Dunbar2009-11-171-1/+1
| | | | llvm-svn: 89085
* PR4700 - remove shift by 0 warningRyan Flynn2009-08-081-3/+8
| | | | llvm-svn: 78488
* PR3333: warn when shifting by invalid amountRyan Flynn2009-08-071-2/+31
| | | | llvm-svn: 78385
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Don't do integer promotions of LHS for compound shift assignment. The LHS ↵Chris Lattner2007-12-131-0/+6
has to be a modifiable lvalue. llvm-svn: 44993
OpenPOWER on IntegriCloud