summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix warning text: lower -> higherRichard Trieu2014-10-281-2/+2
| | | | llvm-svn: 220763
* Prune CRLF.NAKAMURA Takumi2014-10-274-293/+293
| | | | llvm-svn: 220678
* Add frontend support for __vectorcallReid Kleckner2014-10-243-6/+9
| | | | | | | | | | | | | Wire it through everywhere we have support for fastcall, essentially. This allows us to parse the MSVC "14" CTP headers, but we will miscompile them because LLVM doesn't support __vectorcall yet. Reviewed By: Aaron Ballman Differential Revision: http://reviews.llvm.org/D5808 llvm-svn: 220573
* patch to issue warning on comparing parameters withFariborz Jahanian2014-10-231-0/+25
| | | | | | | | nonnull attribute when comparison is always true/false. Patch by Steven Wu with few fixes and minor refactoring and adding tests by me. rdar://18712242 llvm-svn: 220496
* Switch C compilations to C11 by default.Richard Smith2014-10-204-10/+10
| | | | | | | | 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
* tests: move test to more appropriate locationSaleem Abdulrasool2014-10-161-10/+0
| | | | | | The test is a C++ semantic analysis test, move it to SemaCXX from Sema. NFC. llvm-svn: 219932
* Sema: handle AttributedTypeLocs in C++14 auto deductionSaleem Abdulrasool2014-10-151-0/+10
| | | | | | | | | | | | | | When performing a type deduction from the return type, the FunctionDecl may be attributed with a calling convention. In such a case, the retrieved type location may be an AttributedTypeLoc. Performing a castAs<FunctionProtoTypeLoc> on such a type loc would result in an assertion as they are not derived types. Ensure that we correctly handle the attributed type location by looking through it to the modified type loc. Fixes an assertion triggered in C++14 mode. llvm-svn: 219851
* Adding attributes to the IndirectFieldDecl that we generate for anonymous ↵Aaron Ballman2014-10-151-0/+10
| | | | | | struct/union fields. This fixes PR20930. llvm-svn: 219807
* Patch to warn on interger overflow in presence ofFariborz Jahanian2014-10-141-0/+5
| | | | | | | implicit casts. Reviewed by Reid Kleckner. rdar://18405357 llvm-svn: 219712
* ms-inline-asm: Correctly mark MS inline ASM labels as usedEhsan Akhgari2014-10-081-2/+8
| | | | | | | | | | | | | | Summary: This fixes PR21155. Test Plan: The patch includes a test. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5619 llvm-svn: 219322
* Disallow using function parameters in extended asm inputs or outputs in ↵Hans Wennborg2014-10-081-0/+16
| | | | | | | | | | | | | | naked functions (PR21178) Clang won't emit any prologues for such functions, so it would assert trying to codegen the parameter references. This patch makes Clang check the extended asm inputs and outputs for references to function parameters. Differential Revision: http://reviews.llvm.org/D5640 llvm-svn: 219272
* MS ABI: Disallow dllimported/exported variables from having TLSDavid Majnemer2014-10-042-0/+6
| | | | | | | | | | | | | | | | | | | Windows TLS relies on indexing through a tls_index in order to get at the DLL's thread local variables. However, this index is not exported along with the variable: it is assumed that all accesses to thread local variables are inside the same module which created the variable in the first place. While there are several implementation techniques we could adopt to fix this (notably, the Itanium ABI gets this for free), it is not worth the heroics. Instead, let's just ban this combination. We could revisit this in the future if we need to. This fixes PR21111. llvm-svn: 219049
* 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
OpenPOWER on IntegriCloud