Commit Graph

2117 Commits

Author SHA1 Message Date
Tim Northover da16507111 Also promote fp16 types to double when they're anonymous variadic arguments.
__fp16 isn't covered by the standard, but this resolves the oddity that float
gets promoted when passed variadically, but not the smaller type. This is
required by the AArch64 ABI, and a sane action elsewhere.

llvm-svn: 173918
2013-01-30 09:46:55 +00:00
Richard Smith d4cca6b2db Fix test failure from previous change.
llvm-svn: 173899
2013-01-30 06:27:44 +00:00
Richard Smith debc59d1f3 Semantic analysis and CodeGen support for C11's _Noreturn. This is modeled as
an attribute for consistency with our other noreturn mechanisms.

llvm-svn: 173898
2013-01-30 05:45:05 +00:00
Fariborz Jahanian 4d365ba9b9 c: When checking on validity of sizeof passed as size of
argument to be memset, check for its type to be complete 
before calling Context.getTypeSize(PointeeTy) to prevent 
crash. // rdar://13081751.

llvm-svn: 173872
2013-01-30 01:12:44 +00:00
Richard Smith 064697ca06 Test update missed in r173789.
llvm-svn: 173790
2013-01-29 10:18:33 +00:00
Richard Smith 810ad3eb44 Downgrade 'attribute ignored when parsing type' from error to warning, to match
the diagnostic's warn_ name. Switch some places (notably C++11 attributes)
which really wanted an error over to a different diagnostic. Finally, suppress
the diagnostic entirely for __ptr32, __ptr64 and __w64, to avoid producing
diagnostics in important system headers.

llvm-svn: 173788
2013-01-29 10:02:16 +00:00
Richard Smith 1dba27cd49 Implement C++11 [dcl.align]p1 and C11 6.7.5/2 rules for alignas and _Alignas.
llvm-svn: 173779
2013-01-29 09:02:09 +00:00
Richard Smith 210b67d221 Test that we print MS keyword attributes without a __declspec(...) adornment.
llvm-svn: 173754
2013-01-29 02:31:57 +00:00
Richard Smith 0cdcc98200 Replace AS_MSTypespec with AS_Keyword, for representing any attribute spelled
as a keyword. Rationalize existing attributes to use it as appropriate, and to
not lie about some __declspec attributes being GNU attributes. In passing,
remove a gross hack which was discarding attributes which we could handle. This
results in us actually respecting the __pascal keyword again.

llvm-svn: 173746
2013-01-29 01:24:26 +00:00
Dmitri Gribenko 01b065117b Comment parsing: attach any tag type's documentation to its typedef if latter
does not have one of its own. // rdar://13067629

Original patch (r173586 and r173587) by Fariborz Jahanian, modified by me.

llvm-svn: 173626
2013-01-27 21:18:39 +00:00
Dmitri Gribenko 7146930591 Comment parsing: actually check for a block command after "\param x"
This fixes PR15068.

llvm-svn: 173539
2013-01-26 00:36:14 +00:00
Fariborz Jahanian d0ed6c249d Add space after ';'.
llvm-svn: 173462
2013-01-25 17:47:49 +00:00
Fariborz Jahanian 740396437b Improve diagnsotic further on integer overflow.
llvm-svn: 173461
2013-01-25 17:19:07 +00:00
Fariborz Jahanian ee19ceb409 Fixes text of diagnostics in integer overflow patch.
llvm-svn: 173388
2013-01-24 23:24:32 +00:00
Fariborz Jahanian e735ff93e8 Patch to check for integer overflow. It has been
commented on and approved by Richard Smith.

llvm-svn: 173377
2013-01-24 22:11:45 +00:00
Jordan Rose 7f43dddae0 Handle universal character names and Unicode characters outside of literals.
This is a missing piece for C99 conformance.

This patch handles UCNs by adding a '\\' case to LexTokenInternal and
LexIdentifier -- if we see a backslash, we tentatively try to read in a UCN.
If the UCN is not syntactically well-formed, we fall back to the old
treatment: a backslash followed by an identifier beginning with 'u' (or 'U').

Because the spelling of an identifier with UCNs still has the UCN in it, we
need to convert that to UTF-8 in Preprocessor::LookUpIdentifierInfo.

Of course, valid code that does *not* use UCNs will see only a very minimal
performance hit (checks after each identifier for non-ASCII characters,
checks when converting raw_identifiers to identifiers that they do not
contain UCNs, and checks when getting the spelling of an identifier that it
does not contain a UCN).

This patch also adds basic support for actual UTF-8 in the source. This is
treated almost exactly the same as UCNs except that we consider stray
Unicode characters to be mistakes and offer a fixit to remove them.

llvm-svn: 173369
2013-01-24 20:50:46 +00:00
Jordan Rose aa89cf1a66 Unify diagnostics for \x, \u, and \U without any following hex digits.
llvm-svn: 173368
2013-01-24 20:50:13 +00:00
Chad Rosier 879edcd1a4 Fail these tests in a way that doesn't cause unexpected successes, per Daniel's
suggestion.

llvm-svn: 173367
2013-01-24 20:46:39 +00:00
Chad Rosier 709863514e Temporarily XFAIL this test; the compiler will segfault if the target-specific
parser is not included in the compiler. Thanks to Renato for discovering the
underlying issue.

llvm-svn: 173365
2013-01-24 20:33:35 +00:00
Chad Rosier 282d675b28 [ms-inline asm] Add an error when trying to compile MS-style inline assembly
for an unsupported architecture.
rdar://13063988

llvm-svn: 173364
2013-01-24 20:24:34 +00:00
Michael Han 9931593299 PR14922: when printing an attribute, use the real syntax of the attribute (GNU, C++11, MS Declspec) instead of hardcoded GNU syntax.
Introduce a spelling index to Attr class, which is an index into the attribute spelling list of an attribute defined in Attr.td. 
This index will determine the actual spelling used by an attribute, as it incorporates both the syntax and naming of the attribute.
When constructing an attribute AST node, the spelling index is computed based on attribute kind, scope (if it's a C++11 attribute), and
name, then passed to Attr that will use the index to print itself. 

Thanks to Richard Smith for the idea and review.

llvm-svn: 173358
2013-01-24 16:46:58 +00:00
Joey Gouly 7b79dff544 Properly remove this test file, that I copied over to test/SemaOpenCL in r173352.
llvm-svn: 173353
2013-01-24 15:19:51 +00:00
Dmitri Gribenko 6c926ccbd2 Implement -Wvla correctly
GCC implements -Wvla as "warn on every VLA" (this is useful to find every VLA,
for example, if they are forbidden by coding guidelines).  Currently Clang
implements -Wvla as "warn on VLA when it is an extension".

The attached patch makes our behavior match GCC.  The existing vla extwarn is
moved under -Wvla-extension and is still included into -Wgnu.

This fixes PR5953.

llvm-svn: 173286
2013-01-23 20:02:51 +00:00
Chad Rosier e3aac2c864 [ms-inline asm] Remove the -fenable-experimental-ms-inline-asm flag. MS-style
inline assembly can be enable with -fasm-blocks or -fms-extensions alone.

llvm-svn: 173186
2013-01-22 19:38:32 +00:00
Ted Kremenek c0da34e6ab Split "discards qualifiers" warnings of -Wincompatible-pointer-types into subgroup.
This allows users to promote -Wincompatible-pointer-type warnings to
errors but keep those for "discard qualifiers" as warnings (if they
so desire).

Addresses <rdar://problem/13062738>.

llvm-svn: 173184
2013-01-22 19:32:27 +00:00
Dmitri Gribenko 7ec6f3ddeb Add a fixit for _Noreturn main,
add tests for fixits removing static and inline from main

llvm-svn: 173024
2013-01-21 11:25:03 +00:00
Chad Rosier 92c487d13c [ms-inline asm] Test case for r172773.
llvm-svn: 172774
2013-01-18 00:51:29 +00:00
Jordan Rose 1eb342920b Format strings: don't ever convert %+d to %lu.
Presumably, if the printf format has the sign explicitly requested, the user
wants to treat the data as signed.

This is a fix-up for r172739, and also includes several test changes that
didn't make it into that commit.

llvm-svn: 172762
2013-01-17 22:34:10 +00:00
Richard Smith 0015f09877 Parsing support for C11's _Noreturn keyword. No semantics yet.
llvm-svn: 172761
2013-01-17 22:16:11 +00:00
Chad Rosier e343bc83f0 [ms-inline asm] Updates and test case for r172743.
Part of rdar://12576868

llvm-svn: 172744
2013-01-17 19:22:48 +00:00
Matt Beaumont-Gay 978cca9f49 Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.

This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.

There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.

llvm-svn: 172696
2013-01-17 02:06:08 +00:00
Dmitri Gribenko ae73417b69 Implement a fixit for -Wmain-return-type
llvm-svn: 172684
2013-01-17 00:26:13 +00:00
Rafael Espindola f1d2f0ea21 Check for internal weak decls after merging.
This fixes pr14946. The problem was that the linkage computation was done too
early, so things like "extern int a;" would be given external linkage, even if
a previous declaration was static.

llvm-svn: 172667
2013-01-16 23:11:15 +00:00
Reed Kotler 373feca7a0 First step in implementation of mips16 and nomips16 attributes.
Waiting for new llvm attribute code for the next step.

llvm-svn: 172626
2013-01-16 17:10:28 +00:00
Dmitri Gribenko 813985b073 Add a comment to test to clarify the intention here
Comment is taken from the commit message of r151080, by Jean-Daniel Dupas

llvm-svn: 172332
2013-01-12 22:39:30 +00:00
Matt Beaumont-Gay b1e71a7d0c Fix -Wunused-comparison for comparisons in arguments to function-like macros.
Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.

Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.

llvm-svn: 172279
2013-01-12 00:54:16 +00:00
Rafael Espindola 46afb35181 Reject incompatible redeclarations of extern C symbols.
Before we were only checking if the new declaration itself was marked extern
C. Fixes prpr14766.

llvm-svn: 172243
2013-01-11 19:34:23 +00:00
Fariborz Jahanian 70ae634f87 Improve diagnostic per Richard's suggestion
(which may yet change if we move the diagnostic
 outside case value).

llvm-svn: 172242
2013-01-11 19:33:54 +00:00
Fariborz Jahanian 941827931e Provide a better warning when case value overflows.
// rdar://11577384

llvm-svn: 172102
2013-01-10 20:26:42 +00:00
Fariborz Jahanian 8b115b7872 Issue warning when case value is too large to fit
in case condition type. // rdar://11577384.
Test is conditionalized on x86_64-apple triple as
I am not sure if the INT_MAX/LONG_MAX values in the test
will pass this test for other hosts.

llvm-svn: 172016
2013-01-09 23:04:56 +00:00
Rafael Espindola b68dd4717e Clear LV cache when dropping availability attributes.
llvm-svn: 171906
2013-01-08 22:31:36 +00:00
Rafael Espindola c231fab756 Don't crash when trying to apply the availability attribute to a block.
llvm-svn: 171899
2013-01-08 21:30:32 +00:00
Rafael Espindola 9a5a6dddf9 Clear the LV cache when merging the availability attribute.
The availability implies default visibility, so it can change the computed
visibility.

llvm-svn: 171840
2013-01-08 04:04:30 +00:00
Ted Kremenek a046169000 Don't warn about undefined varargs argument behavior in unreachable code.
Fixes <rdar://problem/12322000>.

llvm-svn: 171831
2013-01-08 01:50:40 +00:00
Rafael Espindola f0dafd3cbb Add support for attribute((mode(unwind_word))).
Patch by Nick Lewycky. Fixes pr8703.

llvm-svn: 171781
2013-01-07 19:58:54 +00:00
David Tweed 042e0883cb Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to be
with respect to the lower "left-hand-side bitwidth" bits, even when negative);
see OpenCL spec 6.3j. This patch both implements this behaviour in the code
generator and "constant folding" bits of Sema, and also prevents tests
to detect undefinedness in terms of the weaker C99 or C++ specifications
from being applied. 

llvm-svn: 171755
2013-01-07 16:43:27 +00:00
Rafael Espindola 4588a1a205 Unqualify the parameter type.
This fixes a regression from 168895.

llvm-svn: 171519
2013-01-04 20:34:32 +00:00
Dmitri Gribenko 154e6e53ad Type safety attributes: add tests for enumerations (users are actually doing
this, ensure we don't regress)

llvm-svn: 171412
2013-01-02 21:12:03 +00:00
Richard Smith 74fc72143a PR14729: Fix typo in CheckICE for BinaryConditionalOperators.
llvm-svn: 171191
2012-12-28 12:53:55 +00:00
Guy Benyei f0a014bbb7 Add intel_ocl_bicc calling convention as a function attribute to clang. The calling convention is already implemented in LLVM.
llvm-svn: 171056
2012-12-25 08:53:55 +00:00