summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [ARM] Add support for the s,j,x,N,O inline asm constraintsDavid Candler2019-09-051-0/+305
| | | | | | | | | | | | | | | | | | | | | | A number of inline assembly constraints are currently supported by LLVM, but rejected as invalid by Clang: Target independent constraints: s: An integer constant, but allowing only relocatable values ARM specific constraints: j: An immediate integer between 0 and 65535 (valid for MOVW) x: A 32, 64, or 128-bit floating-point/SIMD register: s0-s15, d0-d7, or q0-q3 N: An immediate integer between 0 and 31 (Thumb1 only) O: An immediate integer which is a multiple of 4 between -508 and 508. (Thumb1 only) This patch adds support to Clang for the missing constraints along with some checks to ensure that the constraints are used with the correct target and Thumb mode, and that immediates are within valid ranges (at least where possible). The constraints are already implemented in LLVM, but just a couple of minor corrections to checks (V8M Baseline includes MOVW so should work with 'j', 'N' and 'O' shouldn't be valid in Thumb2) so that Clang and LLVM are in line with each other and the documentation. Differential Revision: https://reviews.llvm.org/D65863 Change-Id: I18076619e319bac35fbb60f590c069145c9d9a0a llvm-svn: 371079
* [LifetimeAnalysis] Fix some false positivesGabor Horvath2019-09-031-5/+157
| | | | | | Differential Revision: https://reviews.llvm.org/D66806 llvm-svn: 370773
* [Wdocumentation] fixes an assertion failure with typedefed function and ↵Dmitri Gribenko2019-09-022-0/+39
| | | | | | | | | | | | | | | | | | | | | block pointer Summary: The assertion happens when compiling with -Wdocumentation with variable declaration to a typedefed function pointer. I not too familiar with the ObjC syntax but first two tests assert without this patch. Fixes https://bugs.llvm.org/show_bug.cgi?id=42844 Reviewers: gribozavr Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66706 llvm-svn: 370677
* [c++20] Implement semantic restrictions for C++20 designatedRichard Smith2019-08-302-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initializers. This has some interesting interactions with our existing extensions to support C99 designated initializers as an extension in C++. Those are resolved as follows: * We continue to permit the full breadth of C99 designated initializers in C++, with the exception that we disallow a partial overwrite of an initializer with a non-trivially-destructible type. (Full overwrite is OK, because we won't run the first initializer at all.) * The C99 extensions are disallowed in SFINAE contexts and during overload resolution, where they could change the meaning of valid programs. * C++20 disallows reordering of initializers. We only check for that for the simple cases that the C++20 rules permit (designators of the form '.field_name =' and continue to allow reordering in other cases). It would be nice to improve this behavior in future. * All C99 designated initializer extensions produce a warning by default in C++20 mode. People are going to learn the C++ rules based on what Clang diagnoses, so it's important we diagnose these properly by default. * In C++ <= 17, we apply the C++20 rules rather than the C99 rules, and so still diagnose C99 extensions as described above. We continue to accept designated C++20-compatible initializers in C++ <= 17 silently by default (but naturally still reject under -pedantic-errors). This is not a complete implementation of P0329R4. In particular, that paper introduces new non-C99-compatible syntax { .field { init } }, and we do not support that yet. This is based on a previous patch by Don Hinton, though I've made substantial changes when addressing the above interactions. Differential Revision: https://reviews.llvm.org/D59754 llvm-svn: 370544
* Refactor InitListChecker to check only a single (explicit) initializerRichard Smith2019-08-291-3/+3
| | | | | | | | | | list, rather than recursively checking multiple lists in C. This simplification is in preparation for making InitListChecker maintain more state that's specific to the explicit initializer list, particularly when handling designated initialization. llvm-svn: 370418
* [CFG] Fix CFG for statement-expressions in return values.Artem Dergachev2019-08-291-0/+11
| | | | | | | | | | | We're building the CFG from bottom to top, so when the return-value expression has a non-trivial CFG on its own, we need to continue building from the entry to the return-value expression CFG rather than from the block to which we've just appended the return statement. Fixes a false positive warning "control may reach end of non-void function". llvm-svn: 370406
* Replace some custom C11 extension warnings with the generic warning.Aaron Ballman2019-08-272-28/+41
| | | | llvm-svn: 370066
* Quote the token being diagnosed for C11 extensions.Aaron Ballman2019-08-271-27/+27
| | | | llvm-svn: 370059
* Fixing a weird copy-pasta to get bots back to green.Aaron Ballman2019-08-261-1/+1
| | | | llvm-svn: 369960
* Reword the C11 extension diagnostic.Aaron Ballman2019-08-261-27/+27
| | | | | | This makes it more consistent with other language extension diagnostics. llvm-svn: 369957
* Diagnose use of _Thread_local as an extension when not in C11 mode.Aaron Ballman2019-08-261-33/+46
| | | | llvm-svn: 369954
* [Wdocumentation] improve wording of a warning messageDmitri Gribenko2019-08-251-6/+6
| | | | | | | | | | | Based on @davezarzycki remarks in D64696 improved the wording of the warning message. Differential Revision: https://reviews.llvm.org/D66700 Patch by Mark de Wever. llvm-svn: 369873
* Fix a test to test what the name suggest.Gabor Horvath2019-08-231-1/+1
| | | | llvm-svn: 369820
* [LifetimeAnalysis] Make it possible to disable the new warningsGabor Horvath2019-08-231-0/+23
| | | | llvm-svn: 369817
* [Sema] Don't warn on printf('%hd', [char]) (PR41467)Nathan Huckleberry2019-08-233-6/+16
| | | | | | | | | | | | | | | | Summary: Link: https://bugs.llvm.org/show_bug.cgi?id=41467 Reviewers: rsmith, nickdesaulniers, aaron.ballman, lebedev.ri Reviewed By: nickdesaulniers, aaron.ballman, lebedev.ri Subscribers: lebedev.ri, nickdesaulniers, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66186 llvm-svn: 369791
* [Sema][Typo] Fix assertion failure for expressions with multiple typosDavid Goldman2019-08-201-0/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As Typo Resolution can create new TypoExprs while resolving typos, it is necessary to recurse through the expression to search for more typos. This should fix the assertion failure in `clang::Sema::~Sema()`: `DelayedTypos.empty() && "Uncorrected typos!"` Notes: - In case some TypoExprs are created but thrown away, Sema now has a Vector that is used to keep track of newly created typos. - For expressions with multiple typos, we only give suggestions if we are able to resolve all typos in the expression - This patch is similar to D37521 except that it does not eagerly commit to a correction for the first typo in the expression. Instead, it will search for corrections which fix all of the typos in the expression. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62648 llvm-svn: 369427
* [Attr] Support _attribute__ ((fallthrough))Nathan Huckleberry2019-08-201-0/+24
| | | | | | | | | | | | | | | | Summary: Fixed extraneous matches of non-NullStmt Reviewers: aaron.ballman, rsmith, efriedma, xbolva00 Reviewed By: aaron.ballman, rsmith, xbolva00 Subscribers: riccibruno, arphaman, ziangwan, ojeda, xbolva00, nickdesaulniers, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64838 llvm-svn: 369414
* [LifetimeAnalysis] Add support for free functionsGabor Horvath2019-08-201-4/+28
| | | | | | Differential Revision: https://reviews.llvm.org/D66303 llvm-svn: 369408
* Rudimentary support for Doxygen \retval commandStephan Bergmann2019-08-201-0/+5
| | | | | | | | | | ...so that at least a preceding \param etc. that lacks a description gets a -Wdocumentation warning (instead of erroneously treating the \retval ... text as its paragraph). Differential Revision: https://reviews.llvm.org/D66350 llvm-svn: 369345
* [Diagnostics] Improve -Wsizeof-pointer-divDavid Bolvansky2019-08-181-8/+16
| | | | | | | Emit diag note with a location of pointer declaration. Revisited/added tests. llvm-svn: 369206
* Rename this file from cx2.c to c2x.c; NFC.Aaron Ballman2019-08-151-0/+0
| | | | llvm-svn: 369035
* Allow standards-based attributes to have leading and trailing underscores.Aaron Ballman2019-08-151-0/+3
| | | | | | This gives library implementers a way to use standards-based attributes that do not conflict with user-defined macros of the same name. Attributes in C2x require this behavior normatively (C2x 6.7.11p4), but there's no reason to not have the same behavior in C++, especially given that such attributes may be used by a C library consumed by a C++ compilation. llvm-svn: 369033
* [LifetimeAnalysis] Support std::stack::top() and std::optional::value()Matthias Gehre2019-08-141-4/+23
| | | | | | | | | | | | | | Summary: Diagnose dangling pointers that come from std::stack::top() and std::optional::value(). Reviewers: gribozavr Subscribers: cfe-commits, xazax.hun Tags: #clang Differential Revision: https://reviews.llvm.org/D66164 llvm-svn: 368929
* [LifetimeAnalysis] Fix false negatives of statement local lifetime analysis ↵Gabor Horvath2019-08-141-9/+11
| | | | | | | | for some STL implementation Differential Revision: https://reviews.llvm.org/D66152 llvm-svn: 368871
* Fix multiple lifetime warning messages for range based for loopGabor Horvath2019-08-121-0/+7
| | | | llvm-svn: 368588
* Properly detect temporary gsl::Owners through reference initialization chains.Gabor Horvath2019-08-111-2/+8
| | | | llvm-svn: 368534
* Properly handle reference initialization when detecting gsl::Pointer ↵Gabor Horvath2019-08-111-3/+11
| | | | | | initialization chains llvm-svn: 368528
* Fix a false positive warning when initializing members with gsl::Owners.Gabor Horvath2019-08-101-0/+15
| | | | llvm-svn: 368501
* Attempt to reapply "Even more warnings utilizing gsl::Owner/gsl::Pointer ↵Gabor Horvath2019-08-091-1/+50
| | | | | | annotations" llvm-svn: 368499
* Revert Even more warnings utilizing gsl::Owner/gsl::Pointer annotationsGabor Horvath2019-08-091-50/+1
| | | | | | This reverts r368454 (git commit 7c3c8ba8daf40534e09f6fe8701b723e25e4e2dc) llvm-svn: 368463
* Revert Fix a build bot failure and multiple warnings instances for range ↵Gabor Horvath2019-08-091-7/+0
| | | | | | | | base for loops This reverts r368459 (git commit 2bf522aea62e4fb653cacb68072167d25149099e) llvm-svn: 368462
* Fix a build bot failure and multiple warnings instances for range base for loopsGabor Horvath2019-08-091-0/+7
| | | | llvm-svn: 368459
* Even more warnings utilizing gsl::Owner/gsl::Pointer annotationsGabor Horvath2019-08-091-1/+50
| | | | | | Differential Revision: https://reviews.llvm.org/D65127 llvm-svn: 368454
* More warnings regarding gsl::Pointer and gsl::Owner attributesGabor Horvath2019-08-091-15/+50
| | | | | | Differential Revision: https://reviews.llvm.org/D65120 llvm-svn: 368446
* Add SVE opaque built-in typesRichard Sandiford2019-08-091-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the SVE built-in types defined by the Procedure Call Standard for the Arm Architecture: https://developer.arm.com/docs/100986/0000 It handles the types in all relevant places that deal with built-in types. At the moment, some of these places bail out with an error, including: (1) trying to generate LLVM IR for the types (2) trying to generate debug info for the types (3) trying to mangle the types using the Microsoft C++ ABI (4) trying to @encode the types in Objective C (1) and (2) are fixed by follow-on patches but (unlike this patch) they deal mostly with target-specific LLVM details, so seemed like a logically separate change. There is currently no spec for (3) and (4), so reporting an error seems like the correct behaviour for now. The intention is that the types will become sizeless types: http://lists.llvm.org/pipermail/cfe-dev/2019-June/062523.html The main purpose of the sizeless type extension is to diagnose impossible or dangerous uses of the types, such as any that would require sizeof to have a meaningful defined value. Until then, the patch sets the alignments of the types to the values specified in the link above. It also sets the sizes of the types to zero, which is chosen to be consistently wrong and shouldn't affect correctly-written code (i.e. code that would compile even with the sizeless type extension). The patch adds the common subset of functionality needed to test the sizeless type extension on the one hand and to provide SVE intrinsic functions on the other. After this patch, the two pieces of work are essentially independent. The patch is based on one by Graham Hunter: https://reviews.llvm.org/D59245 Differential Revision: https://reviews.llvm.org/D62960 llvm-svn: 368413
* [FIX][NFC] Update clang sema testDiogo N. Sampaio2019-08-081-1/+1
| | | | | | | | Try to fix Sema test for default alignment for when compiling to ARM, but not to android, due r9427aa2d543b llvm-svn: 368301
* Delay diagnosing asm constraints that require immediates until after inliningBill Wendling2019-08-063-38/+0
| | | | | | | | | | | | | | | | Summary: An inline asm call may result in an immediate input value after inlining. Therefore, don't emit a diagnostic here if the input isn't an immediate. Reviewers: joerg, eli.friedman, rsmith Subscribers: asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, s.egerton, krytarowski, mgorny, riccibruno, eraman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60943 llvm-svn: 368104
* Teach some warnings to respect gsl::Pointer and gsl::Owner attributesGabor Horvath2019-08-061-0/+135
| | | | | | | | This patch extends some existing warnings to utilize the knowledge about the gsl::Pointer and gsl::Owner attributes. Differential Revision: https://reviews.llvm.org/D64256 llvm-svn: 368072
* [Sema] attempt to appease buildbots after r367940George Burgess IV2019-08-051-1/+1
| | | | | | | | | | | | A buildbot got angry about this new test, with error messages like: warn-nullchar-nullptr.c Line 16: use of undeclared identifier 'u' It looks like this `u'c'` syntax was introduced in C11; I'm guessing some bots may default to something before that. Let's see if explicitly specifying the standard version makes it happy... llvm-svn: 367947
* [Sema] Add -Wpointer-compareGeorge Burgess IV2019-08-051-0/+49
| | | | | | | | | | | | This patch adds a warning that diagnoses comparisons of pointers to '\0'. This is often indicative of a bug (e.g. the user might've forgotten to dereference the pointer). Patch by Elaina Guan! Differential Revision: https://reviews.llvm.org/D65595 llvm-svn: 367940
* Adds a warning when an inline Doxygen comment has no argumentDmitri Gribenko2019-08-051-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | Summary: It warns for for comments like /** \pre \em */ where \em has no argument This warning is enabled with the -Wdocumentation option. Reviewers: gribozavr, rsmith Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64696 Patch by Mark de Wever. llvm-svn: 367809
* [Sema] Disable -Wbitwise-op-parentheses and -Wlogical-op-parentheses by defaultFangrui Song2019-08-023-52/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The -Wparentheses warnings are enabled by default in clang but they are under -Wall in gcc (gcc/c-family/c.opt). Some of the operator precedence warnings are oftentimes criticized as noise (clang: default; gcc: -Wall). If a warning is very controversial, it is probably not a good idea to enable it by default. This patch disables the rather annoying ones: -Wbitwise-op-parentheses, e.g. i & i | i -Wlogical-op-parentheses, e.g. i && i || i After this change: ``` * = enabled by default -Wall -Wparentheses -Wlogical-op-parentheses -Wlogical-not-parentheses* -Wbitwise-op-parentheses -Wshift-op-parentheses* -Woverloaded-shift-op-parentheses* -Wparentheses-equality* -Wdangling-else* ``` -Woverloaded-shift-op-parentheses is typically followed by overload resolution failure. We can instead improve the error message, and probably delete -Woverloaded-shift-op-parentheses in the future. Keep it for now because it gives some diagnostics. Reviewers: akyrtzi, jyknight, rtrieu, rsmith, aaron.ballman Reviewed By: aaron.ballman Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65192 llvm-svn: 367690
* [Sema] Enable -Wimplicit-float-conversion for integral to floating point ↵Ziang Wan2019-08-011-17/+4
| | | | | | | | precision loss Fix one test case for it to be system-independent. llvm-svn: 367502
* [Sema] Enable -Wimplicit-float-conversion for integral to floating point ↵Ziang Wan2019-08-014-10/+73
| | | | | | | | | | | | | | | | 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. It is also silenced when c++11 narrowing warning is issued. Differential Revision: https://reviews.llvm.org/D64666 llvm-svn: 367497
* [AArch64] Add support for Transactional Memory Extension (TME)Momchil Velikov2019-07-312-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Re-commit r366322 after some fixes 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) Differential Revision: https://reviews.llvm.org/D64416 Patch by Javed Absar and Momchil Velikov llvm-svn: 367428
* [RISCV] Add support for floating point registers in inlineasmSimon Cook2019-07-311-0/+28
| | | | | | | | | This adds support for parsing/emitting in IR the floating-point RISC-V registers in inline assembly clobber lists. Differential Revision: https://reviews.llvm.org/D64737 llvm-svn: 367399
* [Fix] Customize warnings for missing built-in typesJohannes Doerfert2019-07-312-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we detect a built-in declaration for which we cannot derive a type matching the pattern in the Builtins.def file, we currently emit a warning that the respective header is needed. However, this is not necessarily the behavior we want as it has no connection to the location of the declaration (which can actually be in the header in question). Instead, this warning is generated - if we could not build the type for the pattern on file (for some reason). Here we should make the reason explicit. The actual problem is otherwise circumvented as the warning is misleading, see [0] for an example. - if we could not build the type for the pattern because we do not have a type on record, possible since D55483, we should not emit any warning. See [1] for a legitimate problem. This patch address both cases. For the "setjmp" family a new warning is introduced and for built-ins without type on record, so far "pthread_create", we do not emit the warning anymore. Also see: PR40692 [0] https://lkml.org/lkml/2019/1/11/718 [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235583 Differential Revision: https://reviews.llvm.org/D58091 llvm-svn: 367387
* [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expressionNathan Huckleberry2019-07-261-0/+56
| | | | | | | | | | | | | | | | | | | Summary: Do not automatically report self references of structs in statement expression as warnings. Instead wait for uninitialized cfg analysis. https://bugs.llvm.org/show_bug.cgi?id=42604 Reviewers: aaron.ballman, rsmith, nickdesaulniers Reviewed By: aaron.ballman, nickdesaulniers Subscribers: nathanchance, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64678 llvm-svn: 367134
* [Sema] add -Walloca to flag uses of `alloca`George Burgess IV2019-07-251-0/+20
| | | | | | | | | | | | | This CL adds an optional warning to diagnose uses of the `__builtin_alloca` family of functions. The use of these functions is discouraged by many, so it seems like a good idea to allow clang to warn about it. Patch by Elaina Guan! Differential Revision: https://reviews.llvm.org/D64883 llvm-svn: 367067
* Revert "[Sema] Enable -Wimplicit-float-conversion for integral to floating ↵Petr Hosek2019-07-253-39/+9
| | | | | | | | | | | point precision loss" This reverts commit r366972 which broke the following tests: Clang :: CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp Clang :: CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp llvm-svn: 366979
OpenPOWER on IntegriCloud