Commit Graph

2196 Commits

Author SHA1 Message Date
Richard Smith 3b87038631 Fix PR15845: apparently MSVC does not support implicit int in C++ mode.
llvm-svn: 180822
2013-04-30 22:43:51 +00:00
Fariborz Jahanian 4289a5a429 c language: diagnose use of "[*]" on any array dimension
in the parameter of a function definition. Currently,
it crashes in irgen if it is on other than the 1st dimension.
// rdar://13705391

llvm-svn: 180732
2013-04-29 22:01:25 +00:00
Benjamin Kramer 7ee3b9c0e4 Reject asm output constraints that consist of modifiers only.
Fixes PR15759.

llvm-svn: 179756
2013-04-18 13:23:23 +00:00
Richard Trieu e089497121 Switch the note order for -Woverloaded-shift-op-parentheses so that the note
with the silence fix-it comes first.  This is more consistent with the rest
of the warnings in -Wparentheses.

llvm-svn: 179742
2013-04-18 01:04:37 +00:00
Richard Trieu cf2a4c0653 Update the -Wparentheses tests to check that fix-its are in the correct place.
llvm-svn: 179740
2013-04-18 00:56:23 +00:00
Fariborz Jahanian 799a4036da [document parsing]: When tag declaration (but not definition!)
is part of the decl-specifier-seq of some other declaration, 
it doesn't get comment. // rdar://12390371

llvm-svn: 179722
2013-04-17 21:05:20 +00:00
Andy Gibbs fcc699aee8 Extended VerifyDiagnosticConsumer to also verify source file for diagnostic.
VerifyDiagnosticConsumer previously would not check that the diagnostic and
its matching directive referenced the same source file.  Common practice was
to create directives that referenced other files but only by line number,
and this led to problems such as when the file containing the directive
didn't have enough lines to match the location of the diagnostic in the
other file, leading to bizarre file formatting and other oddities.

This patch causes VerifyDiagnosticConsumer to match source files as well as
line numbers.  Therefore, a new syntax is made available for directives, for
example:

// expected-error@file:line {{diagnostic message}}

This extends the @line feature where "file" is the file where the diagnostic
is generated.  The @line syntax is still available and uses the current file
for the diagnostic.  "file" can be specified either as a relative or absolute
path - although the latter has less usefulness, I think!  The #include search
paths will be used to locate the file and if it is not found an error will be
generated.

The new check is not optional: if the directive is in a different file to the
diagnostic, the file must be specified.  Therefore, a number of test-cases
have been updated with regard to this.

This closes out PR15613.

llvm-svn: 179677
2013-04-17 08:06:46 +00:00
Richard Trieu fe042e6aab Add warning group -Woverloaded-shift-op-parentheses to -Wparentheses. This
will fire on code such as:

  cout << x == 0;

which the compiler will intrepret as

  (cout << x) == 0;

This warning comes with two fixits attached to notes, one for parentheses to
silence the warning, and another to evaluate the comparison first.

llvm-svn: 179662
2013-04-17 02:12:45 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

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

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
Jyotsna Verma e90fe76abd Remove setjmp.h header file from Sema/return.c test and include necessary
declarations explicitly in the test.

llvm-svn: 179604
2013-04-16 16:10:38 +00:00
Douglas Gregor 012efe22bc Fix PR4296: Add parser detection/error recovery for nested functions, from Serve Pavlov!
llvm-svn: 179603
2013-04-16 16:01:32 +00:00
Douglas Gregor 8997dac30a Fix handling of atomic shift operations, from Serge Pavlov.
llvm-svn: 179600
2013-04-16 15:41:08 +00:00
Richard Smith 5990db62f6 Local thread_local variables are implicitly 'static'. (This doesn't apply to _Thread_local nor __thread.)
llvm-svn: 179517
2013-04-15 08:33:22 +00:00
Richard Smith 774672e943 Properly check for a constant initializer for a thread-local variable.
llvm-svn: 179516
2013-04-15 08:07:34 +00:00
Richard Smith 6ea1a4d1dc Diagnose if a __thread or _Thread_local variable has a non-constant initializer
or non-trivial destructor.

llvm-svn: 179491
2013-04-14 20:11:31 +00:00
John McCall ad327cd214 Handle incompatible redeclarations of library builtins better.
Invalid redeclarations of valid explicit declarations shouldn't
take the same path as redeclarations of implicit declarations,
and invalid local extern declarations shouldn't foul things up
for everybody else.

llvm-svn: 179482
2013-04-14 08:50:55 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
John McCall a4da323ee0 Don't replace an existing decl in the scope chains with its
local-extern redeclaration;  type refinements, default arguments,
etc. must all be locally scoped.

rdar://13535367

llvm-svn: 179430
2013-04-13 00:20:21 +00:00
Richard Smith b4a9e86877 Parsing support for thread_local and _Thread_local. We give them the same
semantics as __thread for now.

llvm-svn: 179424
2013-04-12 22:46:28 +00:00
Bob Wilson 2b59395d0e Define Neon intrinsics as "static inline" to avoid warning. rdar://13108414
We had been defining Neon intrinsics as "static" with always_inline attributes.
If you use them from an extern inline function, you get a warning, e.g.:

static function 'vadd_u8' is used in an inline function with external linkage

This change simply adds the inline keyword to avoid that warning.

llvm-svn: 179406
2013-04-12 20:17:20 +00:00
Jyotsna Verma 2147a3d039 Exclude test30 of Sema/return.c for Hexagon since setjmp.h include file
is unavailable for Hexagon.

llvm-svn: 179310
2013-04-11 18:56:34 +00:00
Richard Trieu c47f2d3ea3 Remove outdated run lines from tests.
These run lines originally tested that the fix-its were properly applied.
Originally, the fixits were attached to warnings and were applied by -fixit.
Now, the fixits are attached to notes, so nothing happens.  These run lines
still manage to pass since Clang will produce an empty output which gets piped
back to Clang.  Then Clang produces no error on an empty input.

llvm-svn: 179131
2013-04-09 22:06:27 +00:00
Benjamin Kramer 5c488ef85c Sema: Don't crash when trying to emit a warning for a duplicate value in an invalid enum.
Fixes PR15693. A null check on a pointer returned from cast<> is a very dubious
construct, do we have a checker for this somewhere?

llvm-svn: 178975
2013-04-07 14:10:40 +00:00
Richard Smith 86c0d06194 Fix 41 of the 61 tests which fail with modules enabled: we were computing and
caching the linkage for a declaration before we set up its redeclaration chain,
when determining whether a declaration could be a redeclaration of something
from an unimported submodule. We actually want to look at the declaration as if
it were not a redeclaration here, so compute the linkage but don't cache it.

llvm-svn: 178733
2013-04-04 01:51:11 +00:00
Andy Gibbs c804e08a67 Enable use of _Static_assert inside structs and unions in C11 mode (as per C11 6.7.2.1p1).
llvm-svn: 178632
2013-04-03 09:46:04 +00:00
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