Commit Graph

2171 Commits

Author SHA1 Message Date
John McCall c87d97231d Add -Wstatic-local-in-inline, which warns about using a static local
variable in a C99 inline (but not static-inline or extern-inline)
function definition.

The standard doesn't actually say that this doesn't apply to
"extern inline" definitions, but that seems like a useful extension,
and it at least doesn't have the obvious flaw that a static
mutable variable in an externally-available definition does.

rdar://13535367

llvm-svn: 178520
2013-04-02 02:48:58 +00:00
John McCall b65e8fe143 Only merge down a variable type if the previous declaration was
visible.  There's a lot of potential badness in how we're modelling
these things, but getting this much correct is reasonably easy.

rdar://13535367

llvm-svn: 178488
2013-04-01 18:34:28 +00:00
Richard Smith 474b9315ad Add test for PR12527 (bug has apparently already been fixed).
llvm-svn: 178476
2013-04-01 17:41:23 +00:00
Benjamin Kramer 0345f9f900 Sema: Don't crash when trying to emit a precedence warning on postinc/decrement.
Post-Inc can occur as a binary call (the infamous dummy int argument), but it's
not really a binary operator.

Fixes PR15628.

llvm-svn: 178412
2013-03-30 11:56:00 +00:00
Benjamin Kramer 054faa5a48 Sema: Warn on sizeof on binary ops on decayed arrays.
The array will decay into a pointer, creating an unexpected result.
sizeof(array + int) is an easy to make typo for sizeof(array) + int.

This was motivated by a NetBSD security bug, used sizeof(key - r) instead of
sizeof(key) - r, reducing entropy in a random number generator.
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_cprng.c.diff?r1=1.14&r2=1.15&only_with_tag=MAIN&f=h

Differential Revision: http://llvm-reviews.chandlerc.com/D571

llvm-svn: 178371
2013-03-29 21:43:21 +00:00
Timur Iskhodzhanov 554bdc66a4 Revert r178273 as it broke the Linux bootstrap due to false positives
llvm-svn: 178320
2013-03-29 00:22:03 +00:00
Matt Beaumont-Gay 8f51121866 Warn about more than the first unused variable when -Werror is set.
To do this, thread DiagnosticErrorTrap's hasUnrecoverableErrorOccurred through
to Scope.

llvm-svn: 178294
2013-03-28 21:46:45 +00:00
Sam Panzer 6fffec6fd4 Implemented a warning when an input several bitwise operations are
likely be implicitly truncated:

  * All forms of Bitwise-and, bitwise-or, and integer multiplication.
  * The assignment form of integer addition, subtraction, and exclusive-or
  * The RHS of the comma operator
  * The LHS of left shifts.

llvm-svn: 178273
2013-03-28 19:07:11 +00:00
Richard Smith 8ea9720b90 For -Wignored-qualifiers, don't warn on qualifiers which we acquire via a
typedef. Also don't warn on the _Atomic type specifier, just on the _Atomic
type qualifier.

llvm-svn: 178218
2013-03-28 03:27:52 +00:00
Bill Wendling 55ab0c5438 Simplify test to use a count for the number of notes expected.
llvm-svn: 178196
2013-03-27 23:26:09 +00:00
Tim Northover c1ec2dbbd2 Add another expected note. Two errors => two notes.
llvm-svn: 178143
2013-03-27 13:50:57 +00:00
Bill Wendling 953c701b8b Fix testcase to add expected note.
llvm-svn: 178122
2013-03-27 06:45:37 +00:00
Bill Wendling c4fc3a2ba5 Emit an error message instead of crashing when dereferencing an incomplete pointer type.
If the ASM statement is dereferencing an incomplete pointer type, issue an error
instead of crashing.
<rdar://problem/12700799>

llvm-svn: 177915
2013-03-25 21:09:49 +00:00
John McCall 433c2e64f8 Further weaken block conversion rules to permit blocks with
enum return type to be converted to blocks with any integer type
of the same size.

rdar://13463504

llvm-svn: 177613
2013-03-21 00:10:07 +00:00
Fariborz Jahanian abbcbaeb4c documentation comment parsing. Added couple of
top-level HeaderDoc tags @functiongroup and
@methodgroup to doc. tags recognized.
// rdar://12379114 

llvm-svn: 177358
2013-03-18 23:45:52 +00:00
Richard Smith 9cf21ae068 Diagnose uses of 'alignof' on functions in -pedantic mode.
llvm-svn: 177354
2013-03-18 23:37:25 +00:00
Richard Smith b1402ae94e Add missing diagnostic for a nested-name-specifier on a free-standing type definition. Bump some related diagnostics from warning to extension in C++, since they're errors there. Add some missing checks for function specifiers on non-function declarations.
llvm-svn: 177335
2013-03-18 22:52:47 +00:00
Ted Kremenek b7d7dd4dbf Enhance -Wtautological-constant-out-of-range-compare to include the name of the enum constant.
This is QoI.  Fixes <rdar://problem/13076064>.

llvm-svn: 177190
2013-03-15 21:50:10 +00:00
Fariborz Jahanian 1c150a0d0d c: Also chek for integer overflow for '%' operator.
llvm-svn: 177163
2013-03-15 17:03:56 +00:00
Fariborz Jahanian 352eeafa0a c: add the missing binary operatory when checking
for integer overflow. // rdar://13423975

llvm-svn: 177162
2013-03-15 16:36:04 +00:00
Fariborz Jahanian a649eee9e8 HeaderDoc: Support more of HeaderDoc documentation
commands; top level tags such as @interface and
their 2nd level tags such as @coclass, etc.
// rdar://12379114

llvm-svn: 176667
2013-03-07 23:33:11 +00:00
Fariborz Jahanian ff81b824a2 Spell Objective-C correctly.
llvm-svn: 176563
2013-03-06 17:55:30 +00:00
Fariborz Jahanian 41bb7131b3 say objective-C in the warning and streamline
several diagnostics into one. // rdar://13094352

llvm-svn: 176560
2013-03-06 17:36:51 +00:00
Fariborz Jahanian 56fe4066e5 doc. parsing. Improve on diagnostics on my last patch.
// rdar://13094352.

llvm-svn: 176525
2013-03-05 22:46:07 +00:00
Fariborz Jahanian f4ba35d809 doc parsing. Add @method and @callback for
checkings and few other refactoring/cleanup.
// rdar://13094352.

llvm-svn: 176509
2013-03-05 19:40:47 +00:00
Fariborz Jahanian 8a7a59226d doc parsing. We want to issue a strong warning when
an @function comment is not followed by a function decl.
// rdar://13094352

llvm-svn: 176468
2013-03-05 01:05:07 +00:00
Dmitri Gribenko 05e22f2ef0 Comment parsing tests: move a test into a group of similar tests
llvm-svn: 176449
2013-03-04 20:23:16 +00:00
Fariborz Jahanian c551ecc8f0 [comment parsing] source fidelity for tparam command too.
// rdar://13066276

llvm-svn: 176448
2013-03-04 20:08:47 +00:00
Dmitri Gribenko fd5ef42830 warn-documentation.cpp: reorganize tests
Tests are ordered by command in this file.  It is nice to keep it that way.

llvm-svn: 176445
2013-03-04 19:39:33 +00:00
Fariborz Jahanian 5f2a813d2a comment parsing. Missed a case of referring
to original command in diagnostic. // rdar://13066276

llvm-svn: 176444
2013-03-04 18:53:41 +00:00
Fariborz Jahanian d49963609d comment parsing. Keep the original command format
in AST for source fidelity and use it in diagnostics 
to refer to the original format. // rdar://13066276

llvm-svn: 176387
2013-03-01 22:51:30 +00:00
Fariborz Jahanian 81bbee1ed8 comment parsing: Properties are considered like methods, and people
think of them as having return values that may be computed. Don't
warn when using @return in their comment. // rdar://13189938

llvm-svn: 176147
2013-02-27 00:46:06 +00:00
Matt Arsenault 376f72092c Fix assertion failure when a field is given an address space.
llvm-svn: 176122
2013-02-26 21:16:00 +00:00
Matt Beaumont-Gay 1c417da558 Warn on dropping the return value from a warn_unused_result function, even in
macros.

llvm-svn: 176114
2013-02-26 19:34:08 +00:00
Argyrios Kyrtzidis 1fcd7fd633 In LookupResult::resolveKind(), when handling multiple found declarations, ignore invalid declarations.
This reduces the "ambiguous reference" errors (which are rather strange in C/ObjC) and fixes an assertion hit
with an invalid code test case.

llvm-svn: 175869
2013-02-22 06:58:37 +00:00
Argyrios Kyrtzidis 425daaa5d2 When a parameter list in a C function has an error, recover by forming a K&R function,
instead of a non-function type.

llvm-svn: 175868
2013-02-22 06:58:32 +00:00
Argyrios Kyrtzidis e936505807 Don't crash when applying an alloc_size attribute on a K&R function.
llvm-svn: 175867
2013-02-22 06:58:28 +00:00
Richard Smith 463abbb4a7 Fix typo 'with with' in diagnostic.
llvm-svn: 175823
2013-02-21 23:15:05 +00:00
Jordan Rose 011bda8031 Revert "intmax_t is long long on Darwin, not long."
'long' and 'long long' are different for the purposes of mangling.
This caused <rdar://problem/13254874>.

This reverts commit c2f994d31ec85e9af811af38eb1b28709aef0b2c.

llvm-svn: 175681
2013-02-20 22:28:41 +00:00
Jordan Rose e2b34142c3 intmax_t is long long on Darwin, not long.
<rdar://problem/11540697>

llvm-svn: 175588
2013-02-20 01:56:21 +00:00
John McCall d041a9bf2d Add a new 'type_visibility' attribute to allow users to
control the visibility of a type for the purposes of RTTI
and template argument restrictions independently of how
visibility propagates to its non-type member declarations.

Also fix r175326 to not ignore template argument visibility
on a template explicit instantiation when a member has
an explicit attribute but the instantiation does not.

The type_visibility work is rdar://11880378

llvm-svn: 175587
2013-02-20 01:54:26 +00:00
Tim Northover 847d2d4549 AArch64: add atomic support parameters to TargetInfo
This allows Clang to detect and deal wih __atomic_* operations properly on
AArch64. Previously we produced an error when encountering them at high
optimisation levels.

llvm-svn: 175438
2013-02-18 12:11:32 +00:00
Enea Zaffanella 2f40be7511 Fixed diagnostic nondeterministic order bug (pr14901).
llvm-svn: 175289
2013-02-15 20:09:55 +00:00
Nick Lewycky a096b14d1d The meat of this patch is in BuildCXXMemberCalLExpr where we make it use
MarkMemberReferenced instead of marking functions referenced directly. An audit
of callers to MarkFunctionReferenced and DiagnoseUseOfDecl also caused a few
other changes:
 * don't mark functions odr-used when considering them for an initialization
   sequence. Do mark them referenced though.
 * the function nominated by the cleanup attribute should be diagnosed.
 * operator new/delete should be diagnosed when building a 'new' expression.

llvm-svn: 174951
2013-02-12 08:08:54 +00:00
Chad Rosier b31d71367b Testcase for r174477.
llvm-svn: 174640
2013-02-07 18:32:25 +00:00
Tim Northover 570b7478fa Add AArch64 wchar definition to test
This should allow it to pass if the default triple is AArch64

llvm-svn: 174620
2013-02-07 15:11:44 +00:00
Ted Kremenek c43636a53d Remove unneeded test. We have plenty of subgroup relations between warnings,
and for those we care about we should have a general way of testing them.

llvm-svn: 174531
2013-02-06 19:24:28 +00:00
Ted Kremenek 8ae67871b4 Change subexpressions to be visited in the CFG from left-to-right.
This is a more natural order of evaluation, and it is very important
for visualization in the static analyzer.  Within Xcode, the arrows
will not jump from right to left, which looks very visually jarring.
It also provides a more natural location for dataflow-based diagnostics.

Along the way, we found a case in the analyzer diagnostics where we
needed to indicate that a variable was "captured" by a block.

-fsyntax-only timings on sqlite3.c show no visible performance change,
although this is just one test case.

Fixes <rdar://problem/13016513>

llvm-svn: 174447
2013-02-05 22:00:19 +00:00
Richard Smith c084bd2888 PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.

llvm-svn: 174262
2013-02-02 02:14:45 +00:00
Richard Smith 9eaab4be04 Fix diagnostic for bad alignas use: it can't be applied to functions.
llvm-svn: 174160
2013-02-01 08:25:07 +00:00