summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Enable -Wimplicit-float-conversion for integral to floating point ↵Ziang Wan2019-07-253-9/+39
| | | | | | | | | | | | | | | precision loss Issue an warning when the code tries to do an implicit int -> float conversion, where the float type ha a narrower significant than the float type. The new warning is controlled by flag -Wimplicit-int-float-conversion, under -Wimplicit-float-conversion and -Wconversion. Differential Revision: https://reviews.llvm.org/D64666 llvm-svn: 366972
* Implement P1301R4, which allows specifying an optional message on the ↵Aaron Ballman2019-07-201-1/+5
| | | | | | | | [[nodiscard]] attribute. This also bumps the attribute feature test value and introduces the notion of a C++2a extension warning. llvm-svn: 366626
* Disallow most calling convention attributes on PS4Sunil Srivastava2019-07-191-0/+44
| | | | | | | | PS4 now only allows "cdecl", and its equivalent on PS4, "sysv_abi". Differential Revision: https://reviews.llvm.org/D64780 llvm-svn: 366617
* Renamed and changed the wording of warn_cconv_ignoredSunil Srivastava2019-07-175-34/+34
| | | | | | | | As discussed in D64780 the wording of this warning message is being changed to say 'is not supported' instead of 'ignored', and the diag ID itself is being changed to warn_cconv_not_supported. llvm-svn: 366368
* Revert [AArch64] Add support for Transactional Memory Extension (TME)Momchil Velikov2019-07-173-16/+0
| | | | | | This reverts r366322 (git commit 4b8da3a503e434ddbc08ecf66582475765f449bc) llvm-svn: 366355
* [AArch64] Add support for Transactional Memory Extension (TME)Momchil Velikov2019-07-173-0/+16
| | | | | | | | | | | | | | | | | | | | | | | TME is a future architecture technology, documented in https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools https://developer.arm.com/docs/ddi0601/a More about the future architectures: https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/new-technologies-for-the-arm-a-profile-architecture This patch adds support for the TME instructions TSTART, TTEST, TCOMMIT, and TCANCEL and the target feature/arch extension "tme". It also implements TME builtin functions, defined in ACLE Q2 2019 (https://developer.arm.com/docs/101028/latest) Patch by Javed Absar and Momchil Velikov Differential Revision: https://reviews.llvm.org/D64416 llvm-svn: 366322
* fix unnamed fiefield issue and add tests for __builtin_preserve_access_index ↵Yonghong Song2019-07-161-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | intrinsic The original commit is r366076. It is temporarily reverted (r366155) due to test failure. This resubmit makes test more robust by accepting regex instead of hardcoded names/references in several places. This is a followup patch for https://reviews.llvm.org/D61809. Handle unnamed bitfield properly and add more test cases. Fixed the unnamed bitfield issue. The unnamed bitfield is ignored by debug info, so we need to ignore such a struct/union member when we try to get the member index in the debug info. D61809 contains two test cases but not enough as it does not checking generated IRs in the fine grain level, and also it does not have semantics checking tests. This patch added unit tests for both code gen and semantics checking for the new intrinsic. Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 366231
* [Sema] Suppress additional warnings for C's zero initializerPeter Wu2019-07-161-0/+7
| | | | | | | | | | | | | | | | | | Summary: D28148 relaxed some checks for assigning { 0 } to a structure for all C standards, but it failed to handle structures with non-integer subobjects. Relax -Wmissing-braces checks for such structures, and add some additional tests. This fixes PR39931. Patch By: al3xtjames Reviewed By: Lekensteyn Differential Revision: https://reviews.llvm.org/D61838 llvm-svn: 366163
* Temporarily Revert "fix unnamed fiefield issue and add tests for ↵Eric Christopher2019-07-151-13/+0
| | | | | | | | | | __builtin_preserve_access_index intrinsic" The commit had tests that would only work with names in the IR. This reverts commit r366076. llvm-svn: 366155
* fix unnamed fiefield issue and add tests for __builtin_preserve_access_index ↵Yonghong Song2019-07-151-0/+13
| | | | | | | | | | | | | | | | | | | | intrinsic This is a followup patch for https://reviews.llvm.org/D61809. Handle unnamed bitfield properly and add more test cases. Fixed the unnamed bitfield issue. The unnamed bitfield is ignored by debug info, so we need to ignore such a struct/union member when we try to get the member index in the debug info. D61809 contains two test cases but not enough as it does not checking generated IRs in the fine grain level, and also it does not have semantics checking tests. This patch added unit tests for both code gen and semantics checking for the new intrinsic. Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 366076
* [ObjC] Add a warning for implicit conversions of a constant non-boolean ↵Erik Pilkington2019-07-092-0/+78
| | | | | | | | | | value to BOOL rdar://51954400 Differential revision: https://reviews.llvm.org/D63912 llvm-svn: 365518
* Ignore trailing NullStmts in StmtExprs for GCC compatibility.Aaron Ballman2019-07-091-0/+18
| | | | | | | | Ignore trailing NullStmts in compound expressions when determining the result type and value. This is to match the GCC behavior which ignores semicolons at the end of compound expressions. Patch by Dominic Ferreira. llvm-svn: 365498
* clang-cl: Port cl.exe's C4659 to clang-clNico Weber2019-07-091-0/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D64349 llvm-svn: 365411
* [ObjC] Add a -Wtautological-compare warning for BOOLErik Pilkington2019-07-081-0/+24
| | | | | | | | | | | | On macOS, BOOL is a typedef for signed char, but it should never hold a value that isn't 1 or 0. Any code that expects a different value in their BOOL should be fixed. rdar://51954400 Differential revision: https://reviews.llvm.org/D63856 llvm-svn: 365408
* [AST] Fixed extraneous warnings for binary conditional operatorNathan Huckleberry2019-06-191-0/+15
| | | | | | | | | | | | | | | | | | | | Summary: Binary conditional operator gave warnings where ternary operators did not. They have been fixed to warn similarly to ternary operators. Link: https://bugs.llvm.org/show_bug.cgi?id=42239 Reviewers: rsmith, aaron.ballman, nickdesaulniers Reviewed By: rsmith, nickdesaulniers Subscribers: srhines, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63369 llvm-svn: 363857
* Suggestions to fix -Wmissing-{prototypes,variable-declarations}Aaron Puchert2019-06-182-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've found that most often the proper way to fix this warning is to add `static`, because if the code otherwise compiles and links, the function or variable is apparently not needed outside of the TU. We can't provide a fix-it hint for variable declarations, because multiple VarDecls can share the same type, and if we put static in front of that, we affect all declared variables, some of which might have previous declarations. We also provide no fix-it hint for the rare case of an `extern` function definition, because that would require removing `extern` and I have no idea how to get the source location of the storage class specifier from a FunctionDecl. I believe this information is only available earlier in the AST construction from DeclSpec::getStorageClassSpecLoc(), but we don't have that here. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D59402 llvm-svn: 363749
* Show note for -Wmissing-prototypes for functions with parametersAaron Puchert2019-06-181-4/+5
| | | | | | | | | | | | | | Summary: There was a search for non-prototype declarations for the function, but we only showed the results for zero-parameter functions. Now we show the note for functions with parameters as well, but we omit the fix-it hint suggesting to add `void`. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D62750 llvm-svn: 363748
* Clang :: Sema/wchar.c has long been failing on Solaris:Rainer Orth2019-06-172-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | error: 'error' diagnostics expected but not seen: File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 22: initializing wide char array with non-wide string literal error: 'error' diagnostics seen but not expected: File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 20: array initializer must be an initializer list File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 22: array initializer must be an initializer list It turns out the definition is wrong, as can be seen in GCC's gcc/config/sol2.h: /* wchar_t is called differently in <wchar.h> for 32 and 64-bit compilations. This is called for by SCD 2.4.1, p. 6-83, Figure 6-65 (32-bit) and p. 6P-10, Figure 6.38 (64-bit). */ #undef WCHAR_TYPE #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int") The following patch implements this, and at the same time corrects the wint_t definition which is the same: /* Same for wint_t. See SCD 2.4.1, p. 6-83, Figure 6-66 (32-bit). There's no corresponding 64-bit definition, but this is what Solaris 8 <iso/wchar_iso.h> uses. */ #undef WINT_TYPE #define WINT_TYPE (TARGET_64BIT ? "int" : "long int") Clang :: Preprocessor/wchar_t.c and Clang :: Sema/format-strings.c need to be adjusted to account for that. Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11, and x86_64-pc-linux-gnu. Differential Revision: https://reviews.llvm.org/D62944 llvm-svn: 363612
* [RISCV][NFC] Add missing test files for D54091Lewis Revill2019-06-111-0/+26
| | | | llvm-svn: 363056
* Require stdcall etc parameters to be complete on ODR useReid Kleckner2019-06-101-0/+53
| | | | | | | | | | | | | | | | | | | Functions using stdcall, fastcall, or vectorcall with C linkage mangle in the size of the parameter pack. Calculating the size of the pack requires the parameter types to complete, which may require template instantiation. Previously, we would crash during IRgen when requesting the size of incomplete or uninstantiated types, as in this reduced example: struct Foo; void __fastcall bar(struct Foo o); void (__fastcall *fp)(struct Foo) = &bar; Reported in Chromium here: https://crbug.com/971245 Differential Revision: https://reviews.llvm.org/D62975 llvm-svn: 363000
* DebugInfo: Add support for 'nodebug' attribute on typedefs and alias templatesDavid Blaikie2019-06-081-1/+1
| | | | | | | | | Seems like a logical extension to me - and of interest because it might help reduce the debug info size of libc++ by applying this attribute to type traits that have a disproportionate debug info cost compared to the benefit (& possibly harm/confusion) they cause users. llvm-svn: 362856
* Avoid using NoThrow Exception Specifier in non-C++ Modes.Erich Keane2019-06-051-0/+18
| | | | | | | | | | | | | | | | | As reported in https://bugs.llvm.org/show_bug.cgi?id=42113, there are a number of locations in Clang where it is assumed that exception specifications are only valid in C++ mode. Since the original justification for the NoThrow Exception Specifier Type was C++ related, this patch just makes C mode use the attribute-based nothrow handling. Additionally, I noticed that the handling of non-prototype functions regressed the behavior of the nothrow attribute, in part because it is was listed in the function type macro(which I did in the previous patch). In reality, it should only be doing so in a conditional nature, so this patch removes it there and puts it directly in the switch to be handled correctly. llvm-svn: 362607
* [clang] [test] Add a (xfailing) test for PR41027Michal Gorny2019-06-051-0/+10
| | | | | | | | | | Add a test for tracking PR41027 (8.0 regression breaking assembly code relying on __builtin_constant_p() to identify compile-time constants). Mark it as expected to fail everywhere. Differential Revision: https://reviews.llvm.org/D60728 llvm-svn: 362587
* Re-check in clang support gun asm goto after fixing tests.Jennifer Yu2019-06-033-0/+94
| | | | llvm-svn: 362410
* Revert "clang support gnu asm goto."Erich Keane2019-05-304-92/+0
| | | | | | | | | | | This reverts commit 954ec09aed4f2be04bb5f4e10dbb4ea8bd19ef9a. Reverting due to test failures as requested by Jennifer Yu. Conflicts: clang/test/CodeGen/asm-goto.c llvm-svn: 362106
* clang support gnu asm goto.Jennifer Yu2019-05-304-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Syntax: asm [volatile] goto ( AssemblerTemplate : : InputOperands : Clobbers : GotoLabels) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html New llvm IR is "callbr" for inline asm goto instead "call" for inline asm For: asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop); IR: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1 to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3 asm.fallthrough: Compiler need to generate: 1> a dummy constarint 'X' for each label. 2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number". Diagnostic 1> duplicate asm operand name are used in output, input and label. 2> goto out of scope. llvm-svn: 362045
* [X86] Fix the Sema checks for getmant builtins to only allow 4 and 8 for ↵Craig Topper2019-05-281-0/+8
| | | | | | | | | rounding immediates. These don't support embedded rounding so we shouldn't be setting HasRC. That way we only allow current direction and suppress all exceptions. llvm-svn: 361897
* If capturing a variable fails, add a capture anyway (and mark itRichard Smith2019-05-281-1/+8
| | | | | | invalid) so that we can avoid repeated diagnostics for the same capture. llvm-svn: 361891
* Implement __builtin_LINE() et. al. to support source location capture.Eric Fiselier2019-05-161-0/+32
| | | | | | | | | | | | | | | | | Summary: This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation). With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong Reviewed By: rsmith Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D37035 llvm-svn: 360937
* Add a new language mode for C2x; enable [[attribute]] support by default in C2x.Aaron Ballman2019-05-145-5/+5
| | | | llvm-svn: 360667
* Fix test to use -cc1.Leonard Chan2019-05-121-0/+13
| | | | llvm-svn: 360548
* Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an ↵Leonard Chan2019-05-072-1/+68
| | | | | | | | attribute declaration" Updated with fix for read of uninitialized memory. llvm-svn: 360109
* PR41183: Don't emit strict-prototypes warning for an implicit functionJames Y Knight2019-05-061-1/+7
| | | | | | | | | | | declaration. It should emit _only_ an implicit-function-declaration warning, not both of them. Differential Revision: https://reviews.llvm.org/D59711 llvm-svn: 360084
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-061-0/+7
| | | | | | | | | where either the modification or the other access is unreachable. This reverts r359984 (which reverted r359962). The bug in clang-tidy's test suite exposed by the original commit was fixed in r360009. llvm-svn: 360010
* Revert rL359962 : Use DiagRuntimeBehavior for -Wunsequenced to weed out ↵Simon Pilgrim2019-05-051-7/+0
| | | | | | | | | | false positives where either the modification or the other access is unreachable. ........ Try to fix buildbots llvm-svn: 359984
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-041-0/+7
| | | | | | where either the modification or the other access is unreachable. llvm-svn: 359962
* Revert "[Attribute/Diagnostics] Print macro if definition is an attribute ↵Leonard Chan2019-05-032-68/+1
| | | | | | | | declaration" This reverts commit fc40cbd9d8c63e65eed3590ba925321afe782e1d. llvm-svn: 359859
* Revert r359814 "[Sema] Emit warning for visibility attribute on ↵Nico Weber2019-05-031-6/+0
| | | | | | | | internal-linkage declaration" See cfe-commits thread for r359814. llvm-svn: 359858
* Fix -Wunsequenced false-positives in code controlled by a branch onRichard Smith2019-05-021-0/+2
| | | | | | | | | | __builtin_constant_p. If the operand of __builtin_constant_p is not constant and has side-effects, then code controlled by a branch on it is unreachable and we should not emit runtime behavior warnings in such code. llvm-svn: 359844
* [Attribute/Diagnostics] Print macro if definition is an attribute declarationLeonard Chan2019-05-022-1/+68
| | | | | | | | | | | | | If an address_space attribute is defined in a macro, print the macro instead when diagnosing a warning or error for incompatible pointers with different address_spaces. We allow this for all attributes (not just address_space), and for multiple attributes declared in the same macro. Differential Revision: https://reviews.llvm.org/D51329 llvm-svn: 359826
* [Sema] Emit warning for visibility attribute on internal-linkage declarationScott Linder2019-05-021-0/+6
| | | | | | | | GCC warns on these cases, but we currently just silently ignore the attribute. Differential Revision: https://reviews.llvm.org/D61097 llvm-svn: 359814
* [Diagnostics] Support -Wtype-limits for GCC compatibilityDavid Bolvansky2019-04-293-0/+5
| | | | | | | | | | | | | | | | | | Summary: GCC's -Wtype-limits (part of -Wextra): Warn if a comparison is always true or always false due to the limited range of the data type Reviewers: rsmith, aaron.ballman, lebedev.ri, thakis Reviewed By: rsmith Subscribers: lebedev.ri, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58841 llvm-svn: 359516
* [AArch64] Add support for MTE intrinsicsJaved Absar2019-04-261-0/+136
| | | | | | | | | | | | This provides intrinsics support for Memory Tagging Extension (MTE), which was introduced with the Armv8.5-a architecture. These intrinsics are available when __ARM_FEATURE_MEMORY_TAGGING is defined. Each intrinsic is described in detail in the ACLE Q1 2019 documentation: https://developer.arm.com/docs/101028/latest Reviewed By: Tim Nortover, David Spickett Differential Revision: https://reviews.llvm.org/D60485 llvm-svn: 359348
* [Builtins] Implement __builtin_is_constant_evaluated for use in C++2aEric Fiselier2019-04-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements `__builtin_is_constant_evaluated` as specifier by [P0595R2](https://wg21.link/p0595r2). It is built on the back of Bill Wendling's work for `__builtin_constant_p()`. More tests to come, but early feedback is appreciated. I plan to implement warnings for common mis-usages like those belowe in a following patch: ``` void foo(int x) { if constexpr (std::is_constant_evaluated())) { // condition is always `true`. Should use plain `if` instead. foo_constexpr(x); } else { foo_runtime(x); } } ``` Reviewers: rsmith, MaskRay, bruno, void Reviewed By: rsmith Subscribers: dexonsmith, zoecarver, fdeazeve, kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D55500 llvm-svn: 359067
* [APSInt][OpenMP] Fix isNegative, etc. for unsigned typesJoel E. Denny2019-04-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, APSInt inherits APInt::isNegative, which merely checks the sign bit without regard to whether the type is actually signed. isNonNegative and isStrictlyPositive call isNegative and so are also affected. This patch adjusts APSInt to override isNegative, isNonNegative, and isStrictlyPositive with implementations that consider whether the type is signed. A large set of Clang OpenMP tests are affected. Without this patch, these tests assume that `true` is not a valid argument for clauses like `collapse`. Indeed, `true` fails APInt::isStrictlyPositive but not APSInt::isStrictlyPositive. This patch adjusts those tests to assume `true` should be accepted. This patch also adds tests revealing various other similar fixes due to APSInt::isNegative calls in Clang's ExprConstant.cpp and SemaExpr.cpp: `++` and `--` overflow in `constexpr`, evaluated object size based on `alloc_size`, `<<` and `>>` shift count validation, and OpenMP array section validation. Reviewed By: lebedev.ri, ABataev, hfinkel Differential Revision: https://reviews.llvm.org/D59712 llvm-svn: 359012
* Add support for attributes on @implementations in Objective-CErik Pilkington2019-04-111-1/+2
| | | | | | | | | We want to make objc_nonlazy_class apply to implementations, but ran into this. There doesn't seem to be any reason that this isn't supported. Differential revision: https://reviews.llvm.org/D60542 llvm-svn: 358200
* [Sema] Avoid sending a dependent expression to the constant evaluator.Erik Pilkington2019-03-291-0/+33
| | | | | | Fixes llvm.org/PR41286 llvm-svn: 357304
* Emit -Wfortify-source using DiagRuntimeBehaviourErik Pilkington2019-03-261-0/+3
| | | | | | | | | | This fixes a false positive on the following, where st is configured to have different sizes based on some preprocessor logic: if (sizeof(buf) == sizeof(*st)) memcpy(&buf, st, sizeof(*st)); llvm-svn: 357041
* Permit redeclarations of a builtin to specify calling convention.Erich Keane2019-03-214-29/+31
| | | | | | | | | | | | | | | | | | | | After https://reviews.llvm.org/rL355317 we noticed that quite a decent amount of code redeclares builtins (memcpy in particular, I believe reduced from an MSVC header) with a calling convention specified. This gets particularly troublesome when the user specifies a new 'default' calling convention on the command line. When looking to add a diagnostic for this case, it was noticed that we had 3 other diagnostics that differed only slightly. This patch ALSO unifies those under a 'select'. Unfortunately, the order of words in ONE of these diagnostics was reversed ("'thiscall' calling convention" vs "calling convention 'thiscall'"), so this patch also standardizes on the former. Differential Revision: https://reviews.llvm.org/D59560 Change-Id: I79f99fe7c2301640755ffdd774b46eb44526bb22 llvm-svn: 356663
* Fix implicit ios -> watchOS availability version mapping forAlex Lorenz2019-03-201-0/+6
| | | | | | | | versions that have the major number only rdar://48018651 llvm-svn: 356605
OpenPOWER on IntegriCloud