summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Make test/Sema/atomic-ops.c free-standingHal Finkel2014-10-031-1/+1
| | | | | | | | This test includes stdint.h, which might include system headers (and that might not work, depending on the system configuration). Attempting to fix llvm-clang-lld-x86_64-debian-fast. llvm-svn: 218959
* Add an implementation of C11's stdatomic.hHal Finkel2014-10-031-4/+67
| | | | | | | | | | | | | | | | | | | | | | | | Adds a Clang-specific implementation of C11's stdatomic.h header. On systems, such as FreeBSD, where a stdatomic.h header is already provided, we defer to that header instead (using our __has_include_next technology). Otherwise, we provide an implementation in terms of our __c11_atomic_* intrinsics (that were created for this purpose). C11 7.1.4p1 requires function declarations for atomic_thread_fence, atomic_signal_fence, atomic_flag_test_and_set, atomic_flag_test_and_set_explicit, and atomic_flag_clear, and requires that they have external linkage. Accordingly, we provide these declarations, but if a user elides the shadowing macros and uses them, then they must have a libc (or similar) that actually provides definitions. atomic_flag is implemented using _Bool as the underlying type. This is consistent with the implementation provided by FreeBSD and also GCC 4.9 (at least when __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1). Patch by Richard Smith (rebased and slightly edited by me -- Richard said I should drive at this point). llvm-svn: 218957
* Initial support for the align_value attributeHal Finkel2014-10-021-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for the align_value attribute. This attribute is supported by Intel's compiler (versions 14.0+), and several of my HPC users have requested support in Clang. It specifies an alignment assumption on the values to which a pointer points, and is used by numerical libraries to encourage efficient generation of vector code. Of course, we already have an aligned attribute that can specify enhanced alignment for a type, so why is this additional attribute important? The problem is that if you want to specify that an input array of T is, say, 64-byte aligned, you could try this: typedef double aligned_double attribute((aligned(64))); void foo(aligned_double *P) { double x = P[0]; // This is fine. double y = P[1]; // What alignment did those doubles have again? } the access here to P[1] causes problems. P was specified as a pointer to type aligned_double, and any object of type aligned_double must be 64-byte aligned. But if P[0] is 64-byte aligned, then P[1] cannot be, and this access causes undefined behavior. Getting round this problem requires a lot of awkward casting and hand-unrolling of loops, all of which is bad. With the align_value attribute, we can accomplish what we'd like in a well defined way: typedef double *aligned_double_ptr attribute((align_value(64))); void foo(aligned_double_ptr P) { double x = P[0]; // This is fine. double y = P[1]; // This is fine too. } This attribute does not create a new type (and so it not part of the type system), and so will only "propagate" through templates, auto, etc. by optimizer deduction after inlining. This seems consistent with Intel's implementation (thanks to Alexey for confirming the various Intel-compiler behaviors). As a final note, I would have chosen to call this aligned_value, not align_value, for better naming consistency with the aligned attribute, but I think it would be more useful to users to adopt Intel's name. llvm-svn: 218910
* Add __sync_fetch_and_nand (again)Hal Finkel2014-10-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to GCC 4.4, __sync_fetch_and_nand was implemented as: { tmp = *ptr; *ptr = ~tmp & value; return tmp; } but this was changed in GCC 4.4 to be: { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } in response to this change, support for sync_fetch_and_nand (and sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code depending on the old semantics. However, at this point: 1. Many years have passed, and the amount of code relying on the old semantics is likely smaller. 2. Through the work of many contributors, all LLVM backends have been updated such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process was complete July of 2014 (added to the release notes in r212635). 3. The lack of this intrinsic is now a needless impediment to porting codes from GCC to Clang (I've now seen several examples of this). It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC 4.2). To compensate for this, and to address the original concern regarding code relying on the old semantics, I've added a warning that specifically details the fact that the semantics have changed and that we provide the newer semantics. Fixes PR8842. llvm-svn: 218905
* Support the assume_aligned function attributeHal Finkel2014-09-261-0/+15
| | | | | | | | | In addition to __builtin_assume_aligned, GCC also supports an assume_aligned attribute which specifies the alignment (and optional offset) of a function's return value. Here we implement support for the assume_aligned attribute by making use of the @llvm.assume intrinsic. llvm-svn: 218500
* Fix handling of preincrement on bit-fields. This gives a bit-field in C++, butRichard Smith2014-09-241-1/+20
| | | | | | | | | | | we were failing to find that bit-field when performing integer promotions. This brings us closer to following the standard, and closer to GCC. In C, this change is technically a regression: we get bit-field promotions completely wrong in C, promoting cases that are categorically not bit-field designators. This change makes us do so slightly more consistently, though. llvm-svn: 218428
* Simplify tests.Nico Weber2014-09-241-8/+0
| | | | | | | This reverts bits of r218166 that are no longer necessary now that r218394 made -Wmissing-prototype-for-cc a regular warning. llvm-svn: 218400
* Downgrade error about stdcall decls with no prototype to a warningReid Kleckner2014-09-243-9/+9
| | | | | | | | | | | | | | | | | | Fixes PR21027. The MIDL compiler produces code that does this. If we wanted to improve the warning, I think we could do this: void __stdcall f(); // Don't warn without -Wstrict-prototypes. void g() { f(); // Might warn, the user probably meant for f to take no args. f(1, 2, 3); // Warn, we have no idea what args f takes. f(1); // Error, this is insane, one of these calls is broken. } Reviewers: thakis Differential Revision: http://reviews.llvm.org/D5481 llvm-svn: 218394
* Fix the argument index error of __builtin___memccpy_chkSteven Wu2014-09-241-0/+9
| | | | | | | memccpy_check should have source and dest size at arg 3 and 4 rdar://18431336 llvm-svn: 218367
* Attempt to fix Sema/builtin-object-size.c after r218258Hans Wennborg2014-09-231-1/+1
| | | | | | The type of size_t varies between targets. llvm-svn: 218288
* Fix evatuated value of __builtin_object_size according to itsFariborz Jahanian2014-09-221-0/+17
| | | | | | | 'type' argument when it cannot be determined which objects ptr points to at compile time. rdar://18334276 llvm-svn: 218258
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-221-3/+37
| | | | | | | | | | | | | | | | Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
* Follow-up to r214408: Warn on other callee-cleanup functions without ↵Nico Weber2014-09-192-5/+25
| | | | | | | | | | | | | | | | | | prototype too. According to lore, we used to verifier-fail on: void __thiscall f(); int main() { f(1); } So that's fixed now. System headers use prototype-less __stdcall functions, so make that a warning that's DefaultError -- then it fires on regular code but is suppressed in system headers. Since it's used in system headers, we have codegen tests for this; massage them slightly so that they still compile. llvm-svn: 218166
* Patch to check at compile time for overflow whenFariborz Jahanian2014-09-182-3/+24
| | | | | | | | __builtin___memcpy_chk and similar builtins are being used. Patch by Jacques Fortier (with added clang tests). rdar://11076881 llvm-svn: 218063
* Sema: Diagnose undefined structs used as Microsoft anonymous structsDavid Majnemer2014-09-181-0/+8
| | | | | | | | | | | | | | | Previously, we would not mark structs containing anonymous structs as invalid. Later, horrific things would occur when trying to determine the size of the parent record. Instead, require the struct to be a complete type when used as an anonymous struct. Mark both the anonymous field for the struct and the parent context as invalid (this is similar to what we do when a struct contains a field with an incomplete type.) This fixes PR11847. llvm-svn: 218006
* Pretty print attributes associated with record declarations.Aaron Ballman2014-09-151-0/+3
| | | | llvm-svn: 217784
* patch to add missing warning on sizeof wrong parameterFariborz Jahanian2014-09-121-5/+25
| | | | | | | | for __builtin___strlcpy_chk/__builtin___strlcat_chk. Patch by Jacques Fortier with monir change by me and addition of test. rdar://18259539 llvm-svn: 217700
* Allow empty statements in naked functions in addition to ASM statementsEhsan Akhgari2014-09-091-0/+9
| | | | | | | | | | | | Summary: This fixes PR20883. Test Plan: The patch includes an automated test. Reviewers: hansw Differential Revision: http://reviews.llvm.org/D5256 llvm-svn: 217413
* Don't test really-large alignments for nowHal Finkel2014-09-081-1/+3
| | | | | | | | Temporarily comment out the test for really-large powers of two. This seems to be host-sensitive for some reason... trying to fix the clang-i386-freebsd builder. llvm-svn: 217351
* Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.Hal Finkel2014-09-072-1/+51
| | | | | | | | | | | This makes use of the recently-added @llvm.assume intrinsic to implement a __builtin_assume(bool) intrinsic (to provide additional information to the optimizer). This hooks up __assume in MS-compatibility mode to mirror __builtin_assume (the semantics have been intentionally kept compatible), and implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM now contains special logic to deal with assumptions of this form. llvm-svn: 217349
* Try to green test/Sema/format-strings.c on Win botsHans Wennborg2014-09-072-3/+7
| | | | llvm-svn: 217327
* MS format strings: parse the 'Z' printf conversion specifier (PR20808)Hans Wennborg2014-09-071-1/+11
| | | | llvm-svn: 217326
* Reword switch/goto diagnostics "protected scope" diagnostics. Making up a termRichard Smith2014-09-062-19/+19
| | | | | | | | "protected scope" is very unhelpful here and actively confuses users. Instead, simply state the nature of the problem in the diagnostic: we cannot jump from here to there. The notes explain nicely why not. llvm-svn: 217293
* Don't allow inline asm statements to reference parameters in naked functionsHans Wennborg2014-09-042-0/+16
| | | | | | Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217200
* Don't allow non-ASM statements in naked functionsHans Wennborg2014-09-041-1/+9
| | | | | | | | | | Naked functions don't have prologues or epilogues, so doing codegen for anything other than inline assembly would be completely hit or miss. Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217199
* MS format strings: allow the 'h' length modifier with C, C, s and S (PR20808)Hans Wennborg2014-09-041-0/+12
| | | | llvm-svn: 217196
* MS format strings: support the 'w' length modifier (PR20808)Hans Wennborg2014-09-041-13/+54
| | | | llvm-svn: 217195
* Allow adding dll attributes on certain redecls with a warning if the decl ↵Hans Wennborg2014-08-272-4/+29
| | | | | | | | | | | | hasn't been used yet (PR20746) This shouldn't really be allowed, but it comes up in real code (see PR). As long as the decl hasn't been used there's no technical difficulty in supporting it, so downgrade the error to a warning. Differential Revision: http://reviews.llvm.org/D5087 llvm-svn: 216619
* Fix representation of __attribute__((nonnull)) to support correctly modelingRichard Smith2014-08-272-6/+35
| | | | | | | | | | | | | | | the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B, C))) attribute, since that does the wrong thing for function templates and varargs functions. In passing, fix a grammar error in the diagnostic, a crash if __attribute__((nonnull(N))) is applied to a varargs function, a bug where the same null argument could be diagnosed multiple times if there were multiple nonnull attributes referring to it, and a bug where nonnull attributes would not be accumulated correctly across redeclarations. llvm-svn: 216520
* revert patch r216469.Fariborz Jahanian2014-08-262-2/+2
| | | | llvm-svn: 216485
* c11- Check for c11 language option as documentation saysFariborz Jahanian2014-08-262-2/+2
| | | | | | | | feature is c11 about nested struct declarations must have struct-declarator-list. Without this change, code which was meant for c99 breaks. rdar://18125536 llvm-svn: 216469
* arm_acle: Add mappings for dbg intrinsicYi Kong2014-08-261-0/+9
| | | | | | This completes all ACLE hint intrinsics. llvm-svn: 216453
* ARM: Add dbg builtin intrinsicYi Kong2014-08-261-1/+4
| | | | llvm-svn: 216452
* Fix a bad location in -Wparentheses fix-it hintRichard Trieu2014-08-231-0/+102
| | | | | | | The code used getLocStart() instead of getLocEnd(). This works for single token expressions, but breaks if the expression is longer. llvm-svn: 216306
* [AArch64, inline-asm] Improve diagnostic that is printed when the size of aAkira Hatanaka2014-08-223-2/+40
| | | | | | | | | | | | | | | | | variable that has regiser constraint "r" is not 64-bit. General register operands are output using 64-bit "x" register names, regardless of the size of the variable, unless the asm operand is prefixed with the "%w" modifier. This surprises and confuses many users who aren't familiar with aarch64 inline assembly rules. With this commit, a note and fixit hint are printed which tell the users that they need modifier "%w" in order to output a "w" register instead of an "x" register. <rdar://problem/12764785> llvm-svn: 216260
* R600: Implement getPointerWidthV()Tom Stellard2014-08-211-0/+18
| | | | | | | This fixes a crash in the OCL_ImgProc/Canny OpenCV test. NOTE: This is a candidate for the 3.5 branch. llvm-svn: 216181
* Fix assertion on asm register that are "%"Olivier Goffart2014-08-171-0/+1
| | | | | | | | | | | Name might be empty again after we removed the '%' prefix and Name[0] would assert. Found on code like register int foo asm("%" MACRO); where MACRO was supposed to be defined in a header file that was not found. llvm-svn: 215834
* Uniformed parsing of GNU attributes at line beginnning and added GNU ↵Abramo Bagnara2014-08-161-0/+18
| | | | | | attributes parsing FIXMEs. llvm-svn: 215814
* Delete support for AuroraUX.Rafael Espindola2014-08-141-2/+2
| | | | | | auroraux.org is not resolving. llvm-svn: 215644
* ARM: Add mappings for ACLE prefetch intrinsicsYi Kong2014-08-131-0/+7
| | | | | | | Implement __pld, __pldx, __pli and __plix builtin intrinsics as specified in ARM ACLE 2.0. llvm-svn: 215599
* AArch64: Prefetch intrinsicYi Kong2014-08-131-0/+7
| | | | llvm-svn: 215569
* ARM: Prefetch intrinsicsYi Kong2014-08-131-0/+5
| | | | llvm-svn: 215568
* Sema: Properly perform lookup when acting on fields for desig initsDavid Majnemer2014-08-111-0/+2
| | | | | | | | | | | | | | | | | | | | Clang used a custom implementation of lookup when handling designated initializers. The custom code was not particularly optimized and relied on standard lookup for typo-correction anyway. This custom code has to go, it doesn't properly support MSVC-style anonymous structs embedded inside other records; replace it with the typo-correction path. This has the side effect of speeding up semantic handling of the fields for a designated initializer while simplifying the code at the same time. This fixes PR20573. Differential Revision: http://reviews.llvm.org/D4839 llvm-svn: 215372
* Sema: Handle declspecs without declarators in records properly in C modeDavid Majnemer2014-08-112-1/+16
| | | | | | | | | | | | | | | | | | | | | We had two bugs: - We wouldn't properly warn when a struct/union/enum was mentioned inside of a record definition if no declarator was provided. We should have mentioned that this declaration declares nothing. - We didn't properly support Microsoft's extension where certain declspecs without declarators would act as anonymous structs/unions. * We completely ignored the case where such a declspec could be a union. * We didn't properly handle the case where a record was defined inside another record: struct X { int a; struct Y { int b; }; }; llvm-svn: 215347
* MachO: set sizeof result type to what embedded headers expect.Tim Northover2014-08-051-0/+1
| | | | | | | | | Embedded systems seem to have inherited Darwin's choise of "unsigned long" for size_t (via a bunch of headers), so we should respect that. rdar://problem/17872787 llvm-svn: 214854
* clang/test/Sema/struct-packed-align.c: Add the case in MS mode that ↵NAKAMURA Takumi2014-08-041-4/+6
| | | | | | | | | | alignment doesn't affect packing. Also, revert a couple of suppressions. r214298, "Suppress clang/test/Sema/struct-packed-align.c for targeting LLP64." r214301, "Suppress clang/test/Sema/struct-packed-align.c also on msvc for investigating." llvm-svn: 214794
* Trailing linefeed.NAKAMURA Takumi2014-08-041-4/+0
| | | | llvm-svn: 214793
* Thread Safety Analysis: add a -Wthread-safety-negative flag that warns wheneverDeLesley Hutchins2014-08-041-3/+3
| | | | | | | a mutex is acquired, but corresponding mutex is not provably not-held. This is based on the earlier negative requirements patch. llvm-svn: 214789
* [x32] Add __int128 supportPavel Chupin2014-08-041-0/+2
| | | | | | | | | | | | | | | | Summary: Adding __int128 support explicitly for x86_64 because currently it's on only when pointer size >= 64 which is not the case for x32. Test Plan: One of the tests using __int128 is updated Reviewers: atanasyan, chandlerc Subscribers: cfe-commits, rob.khasanov, zinovy.nis, dschuff Differential Revision: http://reviews.llvm.org/D4755 llvm-svn: 214710
* Fix tests Clang::Sema/statements.c and ↵Keith Walker2014-08-041-1/+1
| | | | | | | | Clang::SemaTemplate/instantiate-expr-1.cpp when AArch64 is the default target. Commit r213935 added additional validation of register constants/size for AArch64 and because these tests which contain Intel assembler the new validation caused these tests to fail when the default target is changed to an AArch64 target. llvm-svn: 214706
OpenPOWER on IntegriCloud