Commit Graph

134 Commits

Author SHA1 Message Date
Nico Weber 99c07bc822 Move int<->pointer conversion warnings behind -Wint-conversions.
This is consistent with -Wbool-conversion. Let me know if you prefer
a different flag name.

llvm-svn: 151934
2012-03-02 20:23:08 +00:00
James Molloy 6f8780bed1 Reapply r151638 and r151641.
The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation.

These are now fixed, with regression tests added to catch them both (not Darwin-specific).

Original log:
====================

Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h

Original log:
---------------------
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.

This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
 return 0;
}

This finally fixes PR5464 and PR5477.
---------------------

I also reverted r151641 which was enhancement on top of r151638.

====================

llvm-svn: 151712
2012-02-29 10:24:19 +00:00
Argyrios Kyrtzidis 5929ef2ee7 Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h
Original log:
---------------------
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.

This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
 return 0;
}

This finally fixes PR5464 and PR5477.
---------------------

I also reverted r151641 which was enhancement on top of r151638.

llvm-svn: 151667
2012-02-28 23:39:14 +00:00
James Molloy 051390fffa Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.
This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
  return 0;
}

This finally fixes PR5464 and PR5477.

llvm-svn: 151638
2012-02-28 18:12:11 +00:00
Richard Smith ebeed41587 Support GCC's bug^Wextension allowing class array members to be initalized by a
parenthesized braced-init-list in the base/member initialization list.

llvm-svn: 150625
2012-02-15 22:38:09 +00:00
Dmitri Gribenko c233a545e8 Remove unused diagnostics from include/clang/Basic/Diagnostic*.td files.
llvm-svn: 150409
2012-02-13 20:13:24 +00:00
Ted Kremenek 7f4bd16b53 Per discussion on cfe-dev, remove '#error' and '#warning' from diagnostic text.
llvm-svn: 149566
2012-02-02 00:16:13 +00:00
Ted Kremenek a163d0b5de Fix -fmacro-backtrace-limit=0 to show the entire macro backtrace.
llvm-svn: 148930
2012-01-25 06:07:15 +00:00
Sebastian Pop 422377cfd3 rename -ccc-host-triple into -target
llvm-svn: 148582
2012-01-20 22:01:23 +00:00
Richard Smith 2ec4061e39 Pedantic diagnostic correction: in C++, we have integral constant expressions,
not integer constant expressions. In passing, fix the 'folding is an extension'
diagnostic to not claim we're accepting the code, since that's not true in
-pedantic-errors mode, and add this diagnostic to -Wgnu.

llvm-svn: 148209
2012-01-15 03:51:30 +00:00
Eli Friedman d749c6bf2e Revert r148138; it's causing test failures.
llvm-svn: 148141
2012-01-13 21:33:06 +00:00
Sebastian Pop 9a8d528ddf rename -ccc-host-triple into -target
llvm-svn: 148138
2012-01-13 20:37:02 +00:00
Richard Smith 69f90dce49 PR10828: Produce a warning when a no-arguments function is declared in block
scope, when no other indication is provided that the user intended to declare a
function rather than a variable.

Remove some false positives from the existing 'parentheses disambiguated as a
function' warning by suppressing it when the declaration is marked as 'typedef'
or 'extern'.

Add a new warning group -Wvexing-parse containing both of these warnings.

The new warning is enabled by default; despite a number of false positives (and
one bug) in clang's test-suite, I have only found genuine bugs with it when
running it over a significant quantity of real C++ code.

llvm-svn: 147599
2012-01-05 04:12:21 +00:00
Richard Smith e434590bd9 Change the diagnostics which said 'accepted as an extension' to instead say
'is an extension'. The former is inappropriate and confusing when building with
-Werror/-pedantic-errors.

llvm-svn: 147357
2011-12-29 21:57:33 +00:00
Roman Divacky fadb3bea6b Let the KNR promotion warning be disabled.
Patch by Dimitry Andric!

llvm-svn: 146982
2011-12-20 18:35:44 +00:00
Ted Kremenek 4548e04458 Refactor SerializeDiagnosticsPrinter to using DiagnosticRenderer. This gives us comparative diagnostics
to TextDiagnosticPrinter.

This certainly can be cleaned up a bit.

llvm-svn: 146820
2011-12-17 05:26:11 +00:00
Richard Smith 300237f00c Add a warning flag for ext_embedded_directive. gcc considers this undefined
behaviour to be an error, so it's useful to be able to make it an error in clang
too.

llvm-svn: 146755
2011-12-16 20:58:01 +00:00
Richard Trieu 553b2b2e5d Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared.  If either is a substring of the other, then
no error is given.  This gives rise to an unexpected case:

  // expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

  candidate function has different number of parameters (expected 1 but has 2)
  candidate function has different number of parameters

It will also match these other error messages:

  candidate function
  function has different number of parameters
  number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting.  Also, all the failing tests from this
change have been corrected.  Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)

llvm-svn: 146619
2011-12-15 00:38:15 +00:00
Argyrios Kyrtzidis 7910d7b72a Make changes to SDiagsWriter to make it work in combination with the ARC migrator:
-Allow it to be used with multiple BeginSourceFile/EndSourceFile calls; for this introduce
 a "finish" callback method in the DiagnosticConsumer. SDiagsWriter finishes up the serialization
 file inside this method.
-Make it independent of any particular DiagnosticsEngine; make it use the SourceManager of the
 Diagnostic object.
-Ignore null source ranges.

llvm-svn: 146020
2011-12-07 05:52:12 +00:00
Ted Kremenek 9c9e81085f Tweak serialized diagnostics to support errors with no categories. Fixes <rdar://problem/10538300>.
llvm-svn: 146011
2011-12-07 02:08:00 +00:00
Hans Wennborg 2fb8b91f6f Suggest typo corrections for implicit function declarations.
A mistyped function call becomes an inmplicit function declaration in C.
Suggest typo correction when one can be found.

llvm-svn: 145930
2011-12-06 09:46:12 +00:00
Ted Kremenek 7623347f83 Place "use @dynamic or provide a method implementation" warnings under a -W flag.
llvm-svn: 145418
2011-11-29 19:18:47 +00:00
Ted Kremenek 6cdff0a82b Fix serialized diagnostics to handle FixIts that only remove text. Fixes <rdar://problem/10473903>.
llvm-svn: 145339
2011-11-29 00:30:52 +00:00
Fariborz Jahanian 197a895e75 Remove one group'ed warning.
llvm-svn: 144678
2011-11-15 19:25:38 +00:00
Richard Trieu 5d1aff049e Change the checks in the type aka printing. A confusing case where the string
of the first type is the same as the aka string of the second type, but both
types are different.  Update the logic to print an aka for the first type to
show that they are different.

llvm-svn: 144558
2011-11-14 19:39:25 +00:00
Rafael Espindola 6cfa82bc5f Fix the signature of the getcontext builtin. Patch by Dimitry Andric.
llvm-svn: 144505
2011-11-13 21:51:09 +00:00
NAKAMURA Takumi e89c3bd004 libclang/CXLoadedDiagnostic.cpp: Work around not to miss the string terminator on fixit.
FixIts might be exposed as C string via clang_getCString(), though the zero terminator is not allocated in CXLoadedDiagnosticSetImpl::makeString.

llvm-svn: 144379
2011-11-11 07:27:33 +00:00
NAKAMURA Takumi a5a032025b test/Misc/serialized-diags.c: Tweak FileCheck expressions to be tolerant to DOSish output.
FIXME: For now, " = 0Parse Issueexpected ';' after expression{{XXX}}" would not be matched due to unexpected garbage{{XXX} on some hosts.
llvm-svn: 144374
2011-11-11 05:12:45 +00:00
Ted Kremenek e8ffd1d48d Place 'argument unused during compilation' under a -W flag. Fixes <rdar://problem/10403653>.
llvm-svn: 144365
2011-11-11 03:58:21 +00:00
Ted Kremenek a0e32fc8b6 [serialized diagnostics]: add test cases for serialized diagnostics, including a test case for no issues, multiple issues, and
a single issue.  Along the way, tweak c-index-test -read-diagnostics output so it is easier to tell what diagnostics are
child diagnostics.

llvm-svn: 144349
2011-11-11 00:46:43 +00:00
Douglas Gregor dbb9ea51fa Put ext_offsetof_extended_field_designator under the warning flag
-Wextended-offsetof, from Jeff Walden!

llvm-svn: 144160
2011-11-09 03:01:42 +00:00
Richard Trieu 09d3af4c2b Remove test with int128 printing since it breaks on some platforms.
llvm-svn: 143997
2011-11-07 19:30:35 +00:00
Richard Trieu 8b626ba6de Add support for printing integer literals of type short, unsigned short,
__int128_t and __uint128_t.  Short and unsigned short integer literals support
is only to work around a crasher as reported in PR11179 and will be removed
once Clang no longer builds short integer literals.

llvm-svn: 143977
2011-11-07 18:40:31 +00:00
Chandler Carruth 8c43e66336 Switch to a more natural formatting of the macro name printing.
Suggested by John McCall.

llvm-svn: 142836
2011-10-24 18:51:08 +00:00
Ted Kremenek a08713ce86 Move about 20 random diagnostics under -W flags. Patch by Ahmed Charles!
llvm-svn: 142284
2011-10-17 21:47:53 +00:00
Chandler Carruth 01ca696581 Add a testcase for r142121 based on an idea from Richard Smith. Thanks!
llvm-svn: 142160
2011-10-16 21:33:06 +00:00
David Blaikie e4e9766e3c Remove the leftover partial comment.
llvm-svn: 142138
2011-10-16 14:41:13 +00:00
Chandler Carruth 454de773e1 I fixed this with r142127; these notes now make sense even w/o the caret.
llvm-svn: 142129
2011-10-16 09:41:04 +00:00
Chandler Carruth 9e8ce4ccb9 Now that macro expansion notes are real notes and go through the same
formatting as any other diagnostic, they will be properly line wrapped and
otherwise pretty printed. Let's take advantage of that and the new factoring to
add some helpful information to them (much like template backtrace notes and
other notes): the name of the macro whose expansion is being noted. This makes
a world of difference if caret diagnostics are disabled, making the expansion
notes actually useful in this case. It also helps ensure that in edge cases the
information the user needs is present. Consider:

% nl -ba t5.cc
     1  #define M(x, y, z) \
     2    y
     3
     4  M(
     5    1,
     6    2,
     7    3);

We now produce:
% ./bin/clang -fsyntax-only t5.cc
t5.cc:6:3: error: expected unqualified-id
  2,
  ^
t5.cc:2:3: note: expanded from macro: M
  y
  ^
1 error generated.

Without the added information in the note, the name of the macro being expanded
would never be shown.

This also deletes a FIXME to use the diagnostic formatting. It's not yet clear
to me that we *can* do this reasonably, and the production of this message was
my primary goal here anyways.

I'd love any comments or suggestions on improving these notes, their wording,
etc. Currently, I need to make them provide more helpful information in the
presence of a token-pasting buffer, and I'm pondering adding something along
the lines of "expanded from argument N of macro: ...".

llvm-svn: 142127
2011-10-16 09:30:08 +00:00
Chandler Carruth dc2f257680 Now that the structure of this is more reasonably laid out, fix a long
standing deficiency: we were providing no macro backtrace information
whenever caret diagnostics were turned off. This sinks the logic for
suppressing the code snippet and caret to the code that actually prints
tho code snippet and caret. Along the way, clean up the naming of
functions, remove some now fixed FIXMEs, and generally improve the
wording and logic of this process.

Add a test case exerecising this functionality. It is notable that the
resulting messages are extremely low quality. I'm working on a follow-up
patch that should address this and have left a FIXME in the test case.

llvm-svn: 142120
2011-10-16 07:20:28 +00:00
Chandler Carruth 5371981593 Add a prefix to the existing test to prepare for more tests of other
backtrace behavior.

llvm-svn: 142119
2011-10-16 07:20:23 +00:00
Chandler Carruth 33d64bf8e5 Fold two run lines into a single logical one, and move them down below
the important code in this test to make the test more stable. Now adding
further tests won't shift the line numbers occuring in the diagnostic
output.

llvm-svn: 142118
2011-10-16 07:20:21 +00:00
Chandler Carruth 322db385ac Rename this test to a more general name in preparation for adding more
tests to it to cover more of the macro bactrace functionality.

llvm-svn: 142116
2011-10-16 06:55:30 +00:00
Joerg Sonnenberger 0533869aed Add flags for the remaining shift related warnings
(-Wshift-count-negative, -Wshift-count-overflow).

llvm-svn: 141962
2011-10-14 17:34:53 +00:00
Richard Smith 9ca5c42582 Update all tests other than Driver/std.cpp to use -std=c++11 rather than
-std=c++0x. Patch by Ahmed Charles!

llvm-svn: 141900
2011-10-13 22:29:44 +00:00
Ted Kremenek 03eec60483 Place diagnostic group ext_typecheck_decl_incomplete_type under a -W flag.
llvm-svn: 141620
2011-10-11 01:02:24 +00:00
Ivan Krasin 31f7411bfc Add -Wlanguage-extension-token option for ext_token_used warning.
llvm-svn: 141268
2011-10-06 02:46:34 +00:00
Ted Kremenek f58dbb038c Place diagnostic warn_atomic_property_rule under a -W flag. Fixes <rdar://problem/10230631>.
llvm-svn: 141089
2011-10-04 15:53:53 +00:00
Ted Kremenek edadecdb36 Place diagnostic warn_ownin_getter_rule under a -W flag. Fixes <rdar://problem/10230626>.
llvm-svn: 141088
2011-10-04 15:50:00 +00:00
Ted Kremenek 472a3c1237 Place diagnostic ext_predef_outside_function under a -W flag. Fixes <rdar://problem/10226192>.
llvm-svn: 141087
2011-10-04 15:41:53 +00:00