summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix checking for permitted results of constant expressions.Richard Smith2019-09-291-0/+19
| | | | | | | | | In the presence of mutable state, we need to check whether temporaries involved in a constant expression have permissible values at the end of the overall evaluation, rather than at the end of the evaluation of the initializer of the temporary. llvm-svn: 373160
* For P0784R7: add support for explicit destructor calls andRichard Smith2019-09-271-0/+177
| | | | | | pseudo-destructor calls in constant evaluation. llvm-svn: 373122
* [clang] [AST] Treat "inline gnu_inline" the same way as "extern inline ↵Martin Storsjo2019-09-272-3/+12
| | | | | | | | | | | | | | | | | gnu_inline" in C++ mode This matches how GCC handles it, see e.g. https://gcc.godbolt.org/z/HPplnl. GCC documents the gnu_inline attribute with "In C++, this attribute does not depend on extern in any way, but it still requires the inline keyword to enable its special behavior." The previous behaviour of gnu_inline in C++, without the extern keyword, can be traced back to the original commit that added support for gnu_inline, SVN r69045. Differential Revision: https://reviews.llvm.org/D67414 llvm-svn: 373078
* For P0784R7: add support for new (std::nothrow).Richard Smith2019-09-271-0/+18
| | | | llvm-svn: 373037
* For P0784R7: Add support for dynamic allocation with new / delete duringRichard Smith2019-09-272-1/+310
| | | | | | constant evaluation. llvm-svn: 373036
* [NFC] Update test after r372708David Bolvansky2019-09-241-1/+1
| | | | llvm-svn: 372709
* NFC: Fix a poorly-written testErik Pilkington2019-09-231-7/+7
| | | | | | The author of r364954 foolishly forgot that == binds tighter than ?: llvm-svn: 372631
* Fix __is_fundamental to accept nullptr_tZoe Carver2019-09-231-0/+1
| | | | | | | | | | | | | | Summary: This patch updates the __is_fundamental builtin type trait to return true for nullptr_t. Reviewers: rsmith, EricWF, efriedma, craig.topper, erichkeane Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67899 llvm-svn: 372624
* Fix __is_signed builtinZoe Carver2019-09-231-21/+23
| | | | | | | | | | | | | | Summary: This patch fixes the __is_signed builtin type trait to work with floating point types and enums. Now, the builtin will return true if it is passed a floating point type and false for an enum type. Reviewers: EricWF, rsmith, erichkeane, craig.topper, efriedma Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67897 llvm-svn: 372621
* [Diagnostics] Warn if '<<' in bool context with -Wint-in-bool-context (GCC ↵David Bolvansky2019-09-231-1/+1
| | | | | | | | compatibility) Extracted from D63082, addressed review comments related to a warning message. llvm-svn: 372612
* For P0784R7: add support for constexpr destructors, and call them asRichard Smith2019-09-233-4/+130
| | | | | | | | | | | appropriate during constant evaluation. Note that the evaluator is sometimes invoked on incomplete expressions. In such cases, if an object is constructed but we never reach the point where it would be destroyed (and it has non-trivial destruction), we treat the expression as having an unmodeled side-effect. llvm-svn: 372538
* [NFC] Fixed failed testDavid Bolvansky2019-09-221-1/+1
| | | | llvm-svn: 372533
* [clang] fixing conditional explicit for out-of-line definition PR42980Gauthier Harnisch2019-09-221-0/+18
| | | | | | | | | | | | | | | | Summary: not every read in CXXConstructorDecl::getExplicitSpecifierInternal() was made on the canonical declaration. Reviewers: rsmith, aaron.ballman Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67889 llvm-svn: 372530
* Fix bad APInt compare.Richard Trieu2019-09-211-0/+1
| | | | | | | APInt comparison require both to have the same bitwidth. Since only the value is needed, use the compare function APInt::isSameValue instead. llvm-svn: 372454
* Merge and improve code that detects same value in comparisons.Richard Trieu2019-09-212-0/+87
| | | | | | | | | | | | -Wtautological-overlap-compare and self-comparison from -Wtautological-compare relay on detecting the same operand in different locations. Previously, each warning had it's own operand checker. Now, both are merged together into one function that each can call. The function also now looks through member access and array accesses. Differential Revision: https://reviews.llvm.org/D66045 llvm-svn: 372453
* Improve -Wtautological-overlap-compareRichard Trieu2019-09-211-2/+3
| | | | | | | | | Allow this warning to detect a larger number of constant values, including negative numbers, and handle non-int types better. Differential Revision: https://reviews.llvm.org/D66044 llvm-svn: 372448
* Fix assertion failure when constant evaluation of a switch jumps over anRichard Smith2019-09-201-0/+13
| | | | | | uninitialized variable in an init-statement of a 'for' or 'if'. llvm-svn: 372437
* [Consumed] Treat by-value class arguments as consuming by default, like ↵Nicholas Allegra2019-09-191-0/+27
| | | | | | | | rvalue refs. Differential Revision: https://reviews.llvm.org/D67743 llvm-svn: 372361
* [c++20] P1331R2: Allow transient use of uninitialized objects inRichard Smith2019-09-183-12/+87
| | | | | | constant evaluation. llvm-svn: 372237
* Ignore exception specifier mismatch when merging redeclarationsReid Kleckner2019-09-171-1/+28
| | | | | | | | | | | | | | | | | | Exception specifiers are now part of the function type in C++17. Normally, it is illegal to redeclare the same function or specialize a template with a different exception specifier, but under -fms-compatibility, we accept it with a warning. Without this change, the function types would not match due to the exception specifier, and clang would claim that the types were "incompatible". Now we emit the warning and merge the redeclaration as we would in C++14 and earlier. Fixes PR42842, which is about compiling _com_ptr_t in C++17. Based on a patch by Alex Fusco <alexfusco@google.com>! Differential Revision: https://reviews.llvm.org/D67590 llvm-svn: 372178
* For PR17164: split -fno-lax-vector-conversion into three differentRichard Smith2019-09-133-22/+64
| | | | | | | | | | | | | | | | | | | | | levels: -- none: no lax vector conversions [new GCC default] -- integer: only conversions between integer vectors [old GCC default] -- all: all conversions between same-size vectors [Clang default] For now, Clang still defaults to "all" mode, but per my proposal on cfe-dev (2019-04-10) the default will be changed to "integer" as soon as that doesn't break lots of testcases. (Eventually I'd like to change the default to "none" to match GCC and general sanity.) Following GCC's behavior, the driver flag -flax-vector-conversions is translated to -flax-vector-conversions=integer. This reinstates r371805, reverted in r371813, with an additional fix for lldb. llvm-svn: 371817
* Revert "For PR17164: split -fno-lax-vector-conversion into three different"Jonas Devlieghere2019-09-133-64/+22
| | | | | | | This breaks the LLDB build. I tried reaching out to Richard, but haven't gotten a reply yet. llvm-svn: 371813
* For PR17164: split -fno-lax-vector-conversion into three differentRichard Smith2019-09-133-22/+64
| | | | | | | | | | | | | | | | | | levels: -- none: no lax vector conversions [new GCC default] -- integer: only conversions between integer vectors [old GCC default] -- all: all conversions between same-size vectors [Clang default] For now, Clang still defaults to "all" mode, but per my proposal on cfe-dev (2019-04-10) the default will be changed to "integer" as soon as that doesn't break lots of testcases. (Eventually I'd like to change the default to "none" to match GCC and general sanity.) Following GCC's behavior, the driver flag -flax-vector-conversions is translated to -flax-vector-conversions=integer. llvm-svn: 371805
* [MS] Warn when shadowing template parameters under -fms-compatibilityReid Kleckner2019-09-121-0/+18
| | | | | | | | | | | | | | | | | | | | Summary: C++ does not allow shadowing template parameters, but previously we allowed it under -fms-extensions. Now this behavior is controlled by -fms-compatibility, and we emit a -Wmicrosoft-template warning when it happens. Fixes PR43265 Reviewers: thakis, hans Subscribers: amccarth, rsmith, STL_MSFT, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67463 llvm-svn: 371753
* Don't warn about selectany on implicitly inline variablesReid Kleckner2019-09-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This avoids a -Wignored-attribute warning on the code pattern Microsoft recommends for integral const static data members defined in headers here: https://docs.microsoft.com/en-us/cpp/build/reference/microsoft-extensions-to-c-and-cpp?view=vs-2019 The attribute is redundant, but it is necessary when compiling in C++14 modes with /Za, which disables MSVC's extension that treats such variables as implicitly inline. Fixes PR43270 Reviewers: epastor, thakis, hans Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67426 llvm-svn: 371749
* [MS] Consder constexpr globals to be inline, as in C++17Reid Kleckner2019-09-113-36/+98
| | | | | | | | | | | | | | | | Summary: Microsoft seems to do this regardless of the language mode, so we must also do it in order to be ABI compatible. Fixes PR36125 Reviewers: thakis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47956 llvm-svn: 371642
* PR43242: Fix crash when typo-correcting to an operator() that should notRichard Smith2019-09-091-0/+4
| | | | | | have been visible. llvm-svn: 371468
* Reland [LifetimeAnalysis] Support more STL idioms (template forward ↵Matthias Gehre2019-09-062-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | declaration and DependentNameType) Reland after https://reviews.llvm.org/D66806 fixed the false-positive diagnostics. Summary: This fixes inference of gsl::Pointer on std::set::iterator with libstdc++ (the typedef for iterator on the template is a DependentNameType - we can only put the gsl::Pointer attribute on the underlaying record after instantiation) inference of gsl::Pointer on std::vector::iterator with libc++ (the class was forward-declared, we added the gsl::Pointer on the canonical decl (the forward decl), and later when the template was instantiated, there was no attribute on the definition so it was not instantiated). and a duplicate gsl::Pointer on some class with libstdc++ (we first added an attribute to a incomplete instantiation, and then another was copied from the template definition when the instantiation was completed). We now add the attributes to all redeclarations to fix thos issues and make their usage easier. Reviewers: gribozavr Subscribers: Szelethus, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66179 llvm-svn: 371182
* [Diagnostics] Minor improvements for -Wxor-used-as-powDavid Bolvansky2019-09-051-17/+49
| | | | | | Extracted from D66397; implemented suggestion for 2^64; tests revisited. llvm-svn: 371122
* Diagnose _Atomic as a C11 extension.Aaron Ballman2019-09-042-39/+48
| | | | llvm-svn: 370982
* [c++20] P1143R2: Add support for the C++20 'constinit' keyword.Richard Smith2019-09-041-0/+11
| | | | | | | | | | | | | This is mostly the same as the [[clang::require_constant_initialization]] attribute, but has a couple of additional syntactic and semantic restrictions. In passing, I added a warning for the attribute form being added after we have already seen the initialization of the variable (but before we see the definition); that case previously slipped between the cracks and the attribute was silently ignored. llvm-svn: 370972
* Revert "[Clang Interpreter] Initial patch for the constexpr interpreter"Roman Lebedev2019-09-043-7/+121
| | | | | | | | | Breaks BUILD_SHARED_LIBS build, introduces cycles in library dependency graphs. (clangInterp depends on clangAST which depends on clangInterp) This reverts r370839, which is an yet another recommit of D64146. llvm-svn: 370874
* [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-09-043-121/+7
| | | | | | | | | | | | | | | | | | Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 370839
* Fixit for -Wfinal-dtor-non-final-classDavid Bolvansky2019-09-031-1/+0
| | | | llvm-svn: 370740
* Added fixit notes for -Wfinal-dtor-non-final-classDavid Bolvansky2019-09-031-0/+3
| | | | llvm-svn: 370737
* Rename -Wc++20-designator to -Wc++2a-designator for consistency and addRichard Smith2019-09-021-9/+10
| | | | | | some test coverage for the flag. llvm-svn: 370689
* Split -Wreorder into different warnings for reordering a constructorRichard Smith2019-09-021-4/+4
| | | | | | mem-initializer list and for reordering a designated initializer list. llvm-svn: 370688
* Revert [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-09-023-7/+121
| | | | | | This reverts r370636 (git commit 8327fed9475a14c3376b4860c75370c730e08f33) llvm-svn: 370642
* [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-09-023-121/+7
| | | | | | | | | | | | | | | | | | Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 370636
* [clang] Warning for non-final classes with final destructorsDavid Bolvansky2019-08-312-0/+18
| | | | | | | | | | | | Marking a class' destructor final prevents the class from being inherited from. However, it is a subtle and awkward way to express that at best, and unintended at worst. It may also generate worse code (in other compilers) than marking the class itself final. For these reasons, this revision adds a warning for nonfinal classes with final destructors, with a note to suggest marking the class final to silence the warning. See https://reviews.llvm.org/D66621 for more background. Patch by logan-5 (Logan Smith) Differential Revision: https://reviews.llvm.org/D66711 llvm-svn: 370594
* Revert [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-08-313-7/+121
| | | | | | This reverts r370584 (git commit afcb3de117265a69d21e5673356e925a454d7d02) llvm-svn: 370588
* [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-08-313-121/+7
| | | | | | | | | | | | | | | | | | Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 370584
* [c++20] Disallow template argument deduction from a braced-init-listRichard Smith2019-08-311-2/+13
| | | | | | | | | | | | containing designators. The C++20 wording doesn't actually say what happens in this case, but treating this as a non-deduced context seems like the most natural behavior. (We might want to consider deducing through array designators as an extension in the future, but will need to be careful to deduce the array bound properly if we do so. That's not permitted herein.) llvm-svn: 370555
* [c++20] Implement semantic restrictions for C++20 designatedRichard Smith2019-08-3011-28/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-08-303-7/+121
| | | | | | This reverts r370531 (git commit d4c1002e0bbbbab50f6891cdd2f5bd3a8f3a3584) llvm-svn: 370535
* [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-08-303-121/+7
| | | | | | | | | | | | | | | | | | Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 370531
* Revert [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-08-303-7/+121
| | | | | | This reverts r370476 (git commit a5590950549719d0d9ea69ed164b0c8c0f4e02e6) llvm-svn: 370481
* [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-08-303-121/+7
| | | | | | | | | | | | | | | | | | Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 370476
* Fix silent wrong-code bugs and crashes with designated initialization.Richard Smith2019-08-291-0/+147
| | | | | | | | | | | | | | | | | | | | | We failed to correctly handle the 'holes' left behind by designated initializers in VerifyOnly mode. This would result in us thinking that a designated initialization would be valid, only to find that it is not actually valid when we come to build it. In a +Asserts build, that would assert, and in a -Asserts build, that would silently lose some part of the initialization or crash. With this change, when an InitListExpr contains any designators, we now always build a structured list so that we can track the locations of the 'holes' that we need to go back and fill in. We could in principle do better: we only need the structured form if there is a designator that jumps backwards (and can otherwise check for the holes as we progress through the initializer list), but dealing with that turns out to be rather complicated, so it's not done as part of this patch. llvm-svn: 370419
* Diagnose both _Complex and _Imaginary as C99 extensions.Aaron Ballman2019-08-273-16/+14
| | | | llvm-svn: 370100
OpenPOWER on IntegriCloud