John McCall
80ee5963fd
Pretty up the wrong-number-of-arguments-for-attribute diagnostic by
...
using a custom plural form. Split out the range diagnostics as their
own message.
llvm-svn: 126840
2011-03-02 12:15:05 +00:00
Ted Kremenek
e96dad9544
Don't warn about unused values in ternary ?: expressions unless both the LHS and RHS are "unused" (side-effect free).
...
Patch by Justin Bogner! Fixes PR 8282.
llvm-svn: 126779
2011-03-01 20:34:48 +00:00
Ted Kremenek
26bbc3d494
Don't warning about shifting by too many bits in dead code.
...
llvm-svn: 126770
2011-03-01 19:13:22 +00:00
Ted Kremenek
63657fe995
Don't wanr about "negative shifts" in code that is unreachable. Fixes PR 5544.
...
llvm-svn: 126762
2011-03-01 18:09:31 +00:00
John McCall
4b13633082
Don't crash during constant-evaluation of 1/(1/0). PR9262.
...
llvm-svn: 126541
2011-02-26 08:27:17 +00:00
Peter Collingbourne
54f43b87dc
Rename test/Sema/expr-comma-c89.c to expr-comma-c99.c. Spotted by
...
Anton Lokhmotov.
llvm-svn: 126482
2011-02-25 12:37:11 +00:00
Ted Kremenek
b6f9ab6378
Teach TextDiagnosticPrinter to print out '-Werror' in addition to the warning flag for a warning mapped to an error.
...
For example:
t.c:7:9: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
llvm-svn: 126466
2011-02-25 01:28:26 +00:00
Ted Kremenek
a8890833f2
Don't warn about using PredefinedExprs as format string literals. These never can be a real security issue.
...
Fixes PR 9314.
llvm-svn: 126447
2011-02-24 23:03:04 +00:00
Chandler Carruth
e721185799
Simplify messages as requested by Chris.
...
llvm-svn: 126389
2011-02-24 17:13:15 +00:00
Chandler Carruth
4c6fdca035
Implement a warning for known shift overflows on constant shift
...
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
2011-02-23 23:34:11 +00:00
Chandler Carruth
e71b378dc7
Fix the behavior of -Wignored-qualifiers on return type qualifiers in
...
several ways. We now warn for more of the return types, and correctly
locate the ignored ones. Also adds fix-it hints to remove the ignored
qualifiers. Fixes much of PR9058, although not all of it.
Patch by Hans Wennborg, a couple of minor style tweaks from me.
llvm-svn: 126321
2011-02-23 18:51:59 +00:00
Ted Kremenek
1a241d1619
Teach CFGBuilder about null pointer constants in conditionals, and how they can be used to prune branches. Fixes false null pointer dereference warning in PR 8183.
...
llvm-svn: 126305
2011-02-23 05:11:46 +00:00
Ted Kremenek
ef59fe7845
Add test case (from PR 8876) for suppressing 'indirection of non-volatile null pointer...' warning due to reachability analysis.
...
llvm-svn: 126294
2011-02-23 02:15:19 +00:00
Ted Kremenek
3427fac7c8
Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the related code is reachable. This suppresses some
...
diagnostics that occur in unreachable code (e.g., -Warray-bound).
We only pay the cost of doing the reachability analysis when we issue one of these diagnostics.
llvm-svn: 126290
2011-02-23 01:52:04 +00:00
Douglas Gregor
996a735b88
We need a longer long when testing this pathe Microsoft fixed-underlying-type extension for enumeration types
...
llvm-svn: 126250
2011-02-22 21:42:31 +00:00
Douglas Gregor
a1aec29a2d
Enable enumeration types with a fixed underlying type, e.g.,
...
enum X : long { Value = 0x100000000 };
when in Microsoft-extension mode (-fms-extensions). This (now C++0x)
feature has been supported since Microsoft Visual Studio .NET 2003.
llvm-svn: 126243
2011-02-22 20:32:04 +00:00
Douglas Gregor
e2f943b5cb
Implement the GNU C extension which permits the initialization of an
...
array from a constant array compound literal. Fixes PR9261.
llvm-svn: 126230
2011-02-22 18:29:51 +00:00
Douglas Gregor
a78f193e7e
Warn about implicit conversions between values of different, named
...
enumeration types. Fixes <rdar://problem/8559831>.
llvm-svn: 126183
2011-02-22 02:45:07 +00:00
Anders Carlsson
4fc229ef69
Move some Objective-C tests to SemaObjC and CodeGenObjC.
...
llvm-svn: 126175
2011-02-22 01:23:29 +00:00
Chandler Carruth
468b5cbd40
Allow -Wformat to be enabled without -Wformat-security. GCC gates
...
-Wformat-security on -Wformat, not vice-versa.
Fixes PR8486. Patch by Oleg Slezberg.
llvm-svn: 126096
2011-02-21 00:07:51 +00:00
Chris Lattner
29eb47bd68
Fix PR9253, allowing attribute(aligned) to reduce the alignment of
...
a typedef.
llvm-svn: 126059
2011-02-19 22:55:41 +00:00
Chandler Carruth
a8bea4b90e
Initial steps to improve diagnostics when there is a NULL and
...
a non-pointer on the two sides of a conditional expression.
Patch by Stephen Hines and Mihai Rusu.
llvm-svn: 125995
2011-02-18 23:54:50 +00:00
Chris Lattner
9ba479bd2c
fix rdar://9024687, a crash on invalid that we used to silently ignore.
...
llvm-svn: 125962
2011-02-18 21:16:39 +00:00
Chris Lattner
0f79084117
break testcase over multiple lines to make it easier to read.
...
llvm-svn: 125810
2011-02-18 01:25:14 +00:00
Chris Lattner
cab02a60d2
Step #2/N of __label__ support: keep pushing LabelDecl forward,
...
making them be template instantiated in a more normal way and
make them handle attributes like other decls.
This fixes the used/unused label handling stuff, making it use
the same infrastructure as other decls.
llvm-svn: 125771
2011-02-17 20:34:02 +00:00
Chandler Carruth
22c7a79a1d
Implement a sub-group of -Wconversion: -Wliteral-conversion. This
...
specifically targets literals which are implicitly converted, a those
are more often unintended and trivial to fix. This can be especially
helpful for diagnosing what makes 'const int x = 1e6' not an ICE.
Original patch authored by Jim Meehan with contributions from other
Googlers and a few cleanups from myself.
llvm-svn: 125745
2011-02-17 11:05:49 +00:00
Chris Lattner
c8e630e4db
Step #1/N of implementing support for __label__: split labels into
...
LabelDecl and LabelStmt. There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself. This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.
This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.
This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.
Review appreciated, particularly for the cindex and template bits.
llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Ted Kremenek
197fcd4418
Fix assertion failure in -Warray-bounds on template parameters used as arrays.
...
llvm-svn: 125693
2011-02-16 23:39:09 +00:00
Ted Kremenek
3a854f8ad2
Placate Doug and change capitalization of diagnostic note.
...
llvm-svn: 125688
2011-02-16 22:08:28 +00:00
Ted Kremenek
108b2d56bf
Tweak -Warray-bounds diagnostics based on feedback from Chandler.
...
llvm-svn: 125649
2011-02-16 04:01:44 +00:00
Ted Kremenek
64699befcd
Add trivial buffer overflow checking in Sema.
...
llvm-svn: 125640
2011-02-16 01:57:07 +00:00
Peter Collingbourne
e91b2dbdf1
OpenCL: standardise naming of test cases
...
llvm-svn: 125590
2011-02-15 19:46:41 +00:00
Fariborz Jahanian
178259710a
Fix a block sema bug where result type of initializer
...
is unqualified but its initialized is qualified.
This is for c only and fixes the imm. problem.
c++ is more involved and is wip.
// rdar://8979379
llvm-svn: 125386
2011-02-11 18:46:17 +00:00
John McCall
7a198cef04
When checking the 'weak' and 'weakref' attributes, look for non-external
...
linkage rather than the presence of the 'static' storage class specifier.
Fixes rdar://problem/8814626.
llvm-svn: 125126
2011-02-08 22:35:49 +00:00
John McCall
653dac4b0a
dgregor accidentally killed this assert, but on investigation, it can fire
...
on invalid code and we don't really care, so kill it harder.
llvm-svn: 125068
2011-02-08 01:59:10 +00:00
Ted Kremenek
e6a12a97d4
Move uninitialized variable checking back under -Wuninitialized-experimental. It is clear from user feedback that this warning is not quite ready.
...
llvm-svn: 125007
2011-02-07 17:38:38 +00:00
Ted Kremenek
436cc8ffe7
Reenable -Wuninitialized warning for captured block variables.
...
llvm-svn: 124782
2011-02-03 06:51:50 +00:00
Ted Kremenek
b3dbe28e31
Based on user feedback, swap -Wuninitialized diagnostics to have the warning refer to the bad use, and the note to the variable declaration.
...
llvm-svn: 124758
2011-02-02 23:35:53 +00:00
John McCall
71de91cc09
When diagnosing address-space changes, apply array-to-pointer decay first.
...
llvm-svn: 124702
2011-02-01 23:28:01 +00:00
Ted Kremenek
ba357296e7
Enhance -Wuninitialized to better reason about || and &&, tracking dual dataflow facts and properly merging them.
...
Fixes PR 9076.
llvm-svn: 124666
2011-02-01 17:43:18 +00:00
John McCall
4fff8f6cff
Perform the bad-address-space conversions check as part of
...
CheckPointerTypesForAssignment.
llvm-svn: 124632
2011-02-01 00:10:29 +00:00
Argyrios Kyrtzidis
857dd06605
Fix the diagnostic when we are shadowing an external variable and there exists a locally scoped extern with the same name.
...
llvm-svn: 124580
2011-01-31 07:04:50 +00:00
Argyrios Kyrtzidis
819f610942
Diagnose if extern local variable is followed by non-extern and vice-versa.
...
llvm-svn: 124579
2011-01-31 07:04:46 +00:00
Argyrios Kyrtzidis
f41860c882
'extern' variables in functions don't shadow externs in global scope. Fixes rdar://8883302.
...
llvm-svn: 124578
2011-01-31 07:04:41 +00:00
Ted Kremenek
1be4a59a11
Teach -Wuninitialized about indirect goto. Fixes PR 9071.
...
llvm-svn: 124394
2011-01-27 18:51:39 +00:00
Argyrios Kyrtzidis
ff115a2f35
Allow #pragma unused to be used on global variables like gcc. Fixes rdar://8793832.
...
llvm-svn: 124383
2011-01-27 18:16:48 +00:00
Ted Kremenek
93a313869f
Teach -Wuninitialized not to assert when analyzing
...
blocks that reference captured variables.
llvm-svn: 124348
2011-01-27 02:29:34 +00:00
Ted Kremenek
e543be3531
Merge -Wuninitialized-experimental into -Wuninitialized.
...
llvm-svn: 124279
2011-01-26 04:49:48 +00:00
Ted Kremenek
33ddd9692d
Tweak -Wuninitialized-experimental to not emit
...
a warning for uses of an uninitialized variable
when the use is a void cast, e.g. (void) x.
llvm-svn: 124278
2011-01-26 04:49:43 +00:00
Argyrios Kyrtzidis
7e71884ecb
Correct r124242 making sure function chunk that gets diagnosed is really about the block.
...
Clairvoyance by John!
llvm-svn: 124264
2011-01-26 01:26:44 +00:00