Commit Graph

283 Commits

Author SHA1 Message Date
Richard Smith ab506adf7d Switch C compilations to C11 by default.
This is long-since overdue, and matches GCC 5.0. This should also be
backwards-compatible, because we already supported all of C11 as an extension
in C99 mode.

llvm-svn: 220244
2014-10-20 23:26:58 +00:00
Richard Smith 06f621d349 Don't destroy MacroInfos if we find the macro definition is invalid; it'll get
destroyed on shutdown regardless. Fixes a double-delete.

llvm-svn: 214675
2014-08-03 23:41:04 +00:00
Aaron Ballman 31f42318d8 Improving the "integer constant too large" diagnostics based on post-commit feedback from Richard Smith. Amends r213657.
llvm-svn: 213865
2014-07-24 14:51:23 +00:00
Aaron Ballman 446867ee4e Provide extra information in the "integer constant is too large" diagnostic. This will be used to improve other diagnostics.
llvm-svn: 213657
2014-07-22 14:08:09 +00:00
Alp Toker e492fae27d Make MS i128 suffix test from r211446 more robust
We want to catch both negative and positive failure conditions.

llvm-svn: 211449
2014-06-21 23:32:05 +00:00
David Majnemer 355597e99e The i128 suffix isn't always available.
This Lexer test unconditionally used the i128 integer literal suffix.
This suffix is only available to targets that have 128-bit arithmetic
support.

llvm-svn: 211446
2014-06-21 22:49:50 +00:00
Richard Smith 4676203011 [C++1z] Implement N3981: Disable trigraphs by default in C++1z mode.
llvm-svn: 211392
2014-06-20 19:23:57 +00:00
Alp Toker ed2c033b9b Show -Wdate-time in system headers
Anyone enabling this warning would expect to hear about all occurrences
including those in system headers that can cause non-reproducible builds.

To achieve this, rework ShowInSystemHeader to remove broken unused mapping code
that didn't make sense with a simpler and correct scheme.

llvm-svn: 210512
2014-06-10 06:09:00 +00:00
Alp Toker 4f43e55408 Implement -Wdate-time preprocessor warning
This GCC warning is useful for validating reproducible builds
and might help when tracking down issues with modules too.

llvm-svn: 210511
2014-06-10 06:08:51 +00:00
Peter Collingbourne efe09b4c65 Permit the "if" literal suffix with Microsoft extensions enabled.
Differential Revision: http://reviews.llvm.org/D3963

llvm-svn: 209859
2014-05-29 23:10:15 +00:00
Aaron Ballman 857c7fb448 Fixing some comments in this test. No functional changes.
llvm-svn: 209128
2014-05-19 14:52:09 +00:00
Richard Smith 6d54014144 PR19698, PR19674: enable __has_feature checks for cxx_generic_lambdas and
cxx_decltype_auto, and fix documentation of cxx_generic_lambdas and
cxx_init_captures to specify the right feature-check name.

llvm-svn: 208445
2014-05-09 21:08:59 +00:00
Yunzhong Gao e185d28862 Clean up some existing keyword tests in the test/Lexer directory by using the
pre-defined __is_identifier() macro.

Differential Revision: http://reviews.llvm.org/D3460

llvm-svn: 208147
2014-05-07 01:58:02 +00:00
Richard Smith 70ee92fa4d Add some missing checks for C++1y digit separators that don't in fact separate
digits. Turns out we have completely separate lexing codepaths for floating
point numbers depending on whether or not they start with a zero. Who knew...
=)

llvm-svn: 206932
2014-04-22 23:50:25 +00:00
Justin Bogner 4e3a01fa5f Lex: Fix __has_feature(cxx_exceptions) for objective C++
At one point, -fexceptions was a synonym for -fcxx-exceptions. While
the driver options still enables cxx-exceptions by default, the cc1
flag is purely about exception tables and this doesn't account for
objective C exceptions. Because of this, checking for the
cxx_exceptions feature in objective C++ often gives the wrong answer.

The cxx_exceptions feature should be based on the -fcxx-exceptions cc1
flag, not -fexceptions. Furthermore, at some point the tests were
changed to use cc1 even though they were testing the driver behaviour.
We're better off testing both the driver and cc1 here.

llvm-svn: 206352
2014-04-16 02:56:48 +00:00
Yunzhong Gao ef309f4326 Add a test to distinguish between reserved tokens and normal identifiers.
The -fms-extensions option affects a number of subtle front-end C/C++
behaviors, and it would be useful to be able to distinguish MS keywords
from regular identifiers in the ms-extensions mode even if the triple
does not define a Windows target. It should make life easier if anyone
needs to port their Windows codes to elsewhere.

Differential Revision: http://reviews.llvm.org/D3034

llvm-svn: 206069
2014-04-11 20:55:19 +00:00
Marshall Clow d28acc0d98 Added a __has_feature() for 'is_constructible'
llvm-svn: 204153
2014-03-18 14:13:10 +00:00
NAKAMURA Takumi b19018681a Disable cross-windows-on-linux.cpp for now. It may or may not fail. :/
llvm-svn: 203642
2014-03-12 06:16:26 +00:00
Saleem Abdulrasool bfaec9bf8b Lexer: split test into separate files
Unfortunately, XFAIL applies to the entire file.  Split the test into two
different units, enabling the proper application of XFAIL on the test which is
expected to fail on Windows.

llvm-svn: 203633
2014-03-12 02:53:12 +00:00
Saleem Abdulrasool 729b7d357d Lex: reduce buffer size, add a test
Reduce the stack usage as hopefully include paths are usually not too long.  Add
a test case for the path normalisation behaviour.

llvm-svn: 203632
2014-03-12 02:26:08 +00:00
Richard Smith 86b86973c7 Tests for lexing of digit separators versus UCNs.
llvm-svn: 202534
2014-02-28 20:13:19 +00:00
Richard Smith 35ddad0723 Fix a minor bug in lexing pp-numbers with digit separators: if a pp-number contains "'e+", the pp-number ends between the 'e' and the '+'.
llvm-svn: 202533
2014-02-28 20:06:02 +00:00
Alp Toker 6de6da603e Lexer: Issue -Wbackslash-newline-escape for line comments
The warning for backslash and newline separated by whitespace was missed in
this code path.

backslash<whitespace><newline> is handled differently from compiler to compiler
so it's important to warn consistently where there's ambiguity.

Matches similar handling of block comments and non-comment lines.

llvm-svn: 197331
2013-12-14 23:32:31 +00:00
Alp Toker 6ed7251683 Revert "Don't require -re suffix on -verify directives with regexes."
This patch was submitted to the list for review and didn't receive a LGTM.

(In fact one explicit objection and one query were raised.)

This reverts commit r197295.

llvm-svn: 197299
2013-12-14 01:07:05 +00:00
Hans Wennborg 9b395ef284 Don't require -re suffix on -verify directives with regexes.
Differential Revision: http://llvm-reviews.chandlerc.com/D2392

llvm-svn: 197295
2013-12-14 00:46:53 +00:00
Hans Wennborg cda4b6dd00 Change semantics of regex expectations in the diagnostic verifier
Previously, a line like

  // expected-error-re {{foo}}

treats the entirety of foo as a regex. This is inconvenient when matching type
names containing regex characters. For example, to match
"void *(class test8::A::*)(void)" inside such a regex, one would have to type
"void \*\(class test8::A::\*\)\(void\)".

This patch changes the semantics of expected-error-re to only treat the parts
of the directive wrapped in double curly braces as regexes. This avoids the
escaping problem and leads to nicer patterns for those cases; see e.g. the
change to test/Sema/format-strings-scanf.c.

(The balanced search for closing }} of a directive also makes us handle the
full directive in test\SemaCXX\constexpr-printing.cpp:41 and :53.)

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

llvm-svn: 197092
2013-12-11 23:40:50 +00:00
Richard Smith 91e474fc91 Add support for C++'s SD6 feature test macros.
llvm-svn: 195888
2013-11-27 22:58:16 +00:00
Ismail Pazarbasi 8d0f2f3ae3 Relax header guard mismatch warning with edit distance heuristic.
If the edit distance between the two macros is more than 50%, DefinedMacro may not be header guard or can be header guard of another header file or it might be defining something completely different set by the build environment.

llvm-svn: 192547
2013-10-12 23:17:37 +00:00
Richard Smith b438e62aba Mark lambda init-captures as complete.
llvm-svn: 191607
2013-09-28 04:37:56 +00:00
Richard Smith dca0c7a5fb Mark variable template implementation as complete. Nearly all of the credit
here goes to Larisse Voufo.

llvm-svn: 191549
2013-09-27 20:19:41 +00:00
Richard Smith 52d0211ce3 Add macro test from N3781.
llvm-svn: 191444
2013-09-26 18:15:22 +00:00
Richard Smith 7f2707a7f4 Per updates to D3781, allow underscore under ' in a pp-number, and allow ' in a #line directive.
llvm-svn: 191443
2013-09-26 18:13:20 +00:00
Richard Smith fde9485297 Implement C++1y digit separator proposal (' as a digit separator). This is not
yet approved by full committee, but was unanimously supported by EWG.

llvm-svn: 191417
2013-09-26 03:33:06 +00:00
Reid Kleckner 881dff3683 Lex and ignore Microsoft's #pragma warning(...)
Summary:
This fixes PR17145 and avoids unknown pragma warnings.

This change does not attempt to map MSVC warning numbers to clang
warning flags.  Perhaps in the future we will implement a mapping for
some common subset of Microsoft warnings, but for now we don't.

Reviewers: rsmith

CC: cfe-commits

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

llvm-svn: 190726
2013-09-13 22:00:30 +00:00
Eli Friedman a1e01e8516 Add specific warning flags for GNU ext in lexer.
This patch adds the following flags covering existing warnings:

-Wgnu-zero-variadic-macro-arguments
-Wgnu-imaginary-constant
-Wgnu-binary-literal
-Wgnu-zero-line-directive

Patch by Peter Lewis.

llvm-svn: 190017
2013-09-05 00:02:30 +00:00
Jordan Rose 9217aa3b15 Revise -Wnewline-eof test per feedback from Dmitri.
llvm-svn: 189113
2013-08-23 16:12:49 +00:00
Jordan Rose 4c55d45b13 Respect -Wnewline-eof even in C++11 mode.
If the user has requested this warning, we should emit it, even if it's not
an extension in the current language mode. However, being an extension is
more important, so prefer the pedantic warning or the pedantic-compatibility
warning if those are enabled.

<rdar://problem/12922063>

llvm-svn: 189110
2013-08-23 15:42:01 +00:00
Nick Lewycky 8054f1de88 Revert r188863 which could propose wrong fixits for multibyte character literals.
llvm-svn: 188918
2013-08-21 18:57:51 +00:00
Nick Lewycky 3151d7c76a Issue fixits replacing invalid character literals with the equivalent \xNN
escape code.

llvm-svn: 188863
2013-08-21 04:10:58 +00:00
Tim Northover 19ae1175ae Fix FileCheck --check-prefix lines.
Various tests had sprung up over the years which had --check-prefix=ABC on the
RUN line, but "CHECK-ABC:" later on. This happened to work before, but was
strictly incorrect. FileCheck is getting stricter soon though.

Patch by Ron Ofir.

llvm-svn: 188174
2013-08-12 12:51:05 +00:00
Eli Friedman ab09187553 Partially revert r186903.
It turns out that Plum Hall depends on us not emitting an error on
integer literals which fit into long long, but fit into
unsigned long long.  So C99 conformance requires not conforming to C99. :)

llvm-svn: 187172
2013-07-26 00:06:45 +00:00
Richard Smith c0f7b81d89 Update documentation to match current C++1y feature set.
llvm-svn: 187055
2013-07-24 17:41:31 +00:00
Eli Friedman 088d39afc6 Integers which are too large should be an error.
Switch some warnings over to errors which should never have been warnings
in the first place.  (Also, a minor fix to the preprocessor rules for
integer literals while I'm here.)

llvm-svn: 186903
2013-07-23 00:25:18 +00:00
Rafael Espindola 925213b0fa Add 'not' to commands that are expected to fail.
This is at least good documentation, but also opens the possibility of
using pipefail.

llvm-svn: 185652
2013-07-04 16:16:58 +00:00
Richard Smith 089ee1554c PR16339: Don't produce a diagnostic pointing at the whitespace between a '#if'
and a '!defined(X)' if we find a broken header guard. This is suboptimal; we
should point the diagnostic at the 'X' token not the 'if' token, but it fixes
the crash.

llvm-svn: 184054
2013-06-16 05:05:39 +00:00
Richard Trieu 33a4b3db0d Introducing -Wheader-guard, a warning that checks header guards actually work
properly.  This warning checks that the #ifndef and #define directives at
the beginning of a header refer to the same macro name.  Includes a fix-it
hint to correct the header guard.

llvm-svn: 183867
2013-06-12 21:20:57 +00:00
Hans Wennborg 8f62c5ca22 Better diagnostics for string initialization.
This commit improves Clang's diagnostics for string initialization.
Where it would previously say:

  /tmp/a.c:3:9: error: array initializer must be an initializer list
  wchar_t s[] = "Hi";
          ^
  /tmp/a.c:4:6: error: array initializer must be an initializer list or string literal
  char t[] = L"Hi";
       ^

It will now say

  /tmp/a.c:3:9: error: initializing wide char array with non-wide string literal
  wchar_t s[] = "Hi";
          ^
  /tmp/a.c:4:6: error: initializing char array with wide string literal
  char t[] = L"Hi";
       ^

As a bonus, it also fixes the fact that Clang would previously reject
this valid C11 code:

  char16_t s[] = u"hi";
  char32_t t[] = U"hi";

because it would only recognize the built-in types for char16_t and
char32_t, which do not exist in C.

llvm-svn: 181880
2013-05-15 11:03:04 +00:00
Richard Smith 9155be1e54 C++1y: provide full 'auto' return type deduction for lambda expressions. This
completes the implementation of N3638.

llvm-svn: 181669
2013-05-12 03:09:35 +00:00
Richard Smith 0a715429b9 C++1y: Update __cplusplus to temporary value 201305L to allow detection of provisional C++1y support.
Add __has_feature and __has_extension checks for C++1y features (based on the provisional names from
the C++ features study group), and update documentation to match.

llvm-svn: 181342
2013-05-07 19:32:56 +00:00
Aaron Ballman d428ff46fe Reverting r181004 since it has broken test/Sema/wchar.c.
llvm-svn: 181122
2013-05-04 16:56:22 +00:00