Commit Graph

17 Commits

Author SHA1 Message Date
Mark de Wever 9658d895c8 [Sema] Adds the pointer-to-int-cast diagnostic
Converting a pointer to an integer whose result cannot represented in the
integer type is undefined behavior is C and prohibited in C++. C++ already
has a diagnostic when casting. This adds a diagnostic for C.

Since this diagnostic uses the range of the conversion it also modifies
int-to-pointer-cast diagnostic to use a range.

Fixes PR8718: No warning on casting between pointer and non-pointer-sized int

Differential Revision: https://reviews.llvm.org/D72231
2020-02-16 15:38:25 +01:00
Richard Trieu 1c6f15d755 Move a test that requires 64-bit mode to a separate test with a triple in
the run line.

llvm-svn: 181854
2013-05-15 00:44:06 +00:00
Richard Trieu 04d2d94762 When computing the size of large arrays, use char units instead of bits.
This prevents an overflow and assertion when the number of bits cannot be
stored in 64-bits.

llvm-svn: 181839
2013-05-14 21:59:17 +00:00
Richard Smith eda61288ad Perform an lvalue-to-rvalue conversion on an array index in a __builtin_offsetof expression.
llvm-svn: 142179
2011-10-17 05:48:07 +00:00
Douglas Gregor 0be628ff64 Fix a thinko that caused us not to compute __builtin_offset as a
constant expression in C. 

llvm-svn: 102762
2010-04-30 20:35:01 +00:00
Douglas Gregor 10982ea3f9 Diagnose __builtin_offsetof expressions that refer to bit-fields
llvm-svn: 102548
2010-04-28 22:36:06 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
John McCall 9eff4e60ae Diagnose __builtin_offsetof on incomplete types. Fixes
rdar://problem/7222956

llvm-svn: 85999
2009-11-04 03:03:43 +00:00
Eli Friedman 64fc3c68e5 Fix for PR4079: make sure to construct the member expressions for
offsetof correctly in the presence of anonymous structs/unions.

This could definitely use some cleanup, but I don't really want to mess 
with the anonymous union/struct code.

llvm-svn: 70156
2009-04-26 20:50:44 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Eli Friedman 988a16b9b8 Change the AST generated for offsetof a bit so that it looks like a
normal expression, and change Evaluate and IRGen to evaluate it like a 
normal expression.  This simplifies the code significantly, and fixes 
PR3396.

llvm-svn: 65622
2009-02-27 06:44:11 +00:00
Anders Carlsson 3bb1ffca94 Simplify test.
llvm-svn: 60631
2008-12-06 22:27:22 +00:00
Chris Lattner e850fa2452 make this pass by adding an expected error, add some tests.
llvm-svn: 46551
2008-01-30 06:46:30 +00:00
Anders Carlsson a8dc3e6b52 Implement __builtin_offsetof.
llvm-svn: 46515
2008-01-29 15:56:48 +00:00
Chris Lattner 5e4c75f4ef rename -parse-ast-print to -ast-print
rename -parse-ast-dump to -ast-dump
remove -parse-ast, which is redundant with -fsyntax-only

llvm-svn: 42852
2007-10-11 00:18:28 +00:00
Ted Kremenek 0883fd5817 Removed option "-parse-ast-check" from clang driver. This is now implemented
using "-parse-ast -verify".

Updated all test cases (using a sed script) that invoked -parse-ast-check to
now use -parse-ast -verify.

Fixed a bug where using "-verify" instead of "-parse-ast-check" would not
correctly create the DiagClient needed to accumulate diagnostics.

llvm-svn: 42365
2007-09-26 20:14:22 +00:00
Chris Lattner 8718fcf35e a new testcase
llvm-svn: 41614
2007-08-30 17:51:09 +00:00