summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[Diagnostic] add a warning which warns about misleading indentation"Tom Stellard2019-11-251-184/+0
| | | | | | This reverts commit 7b86188b50bf6e537fe98b326f258fbd23108b83. This commit introduced bot falures for multi-stage bots with -Werror.
* Revert "[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy"Tom Stellard2019-11-251-23/+0
| | | | | | This reverts commit 9353c5dd0664ea444236e527bf93566e11dc34df. This commit introduced bot falures for multi-stage bots with -Werror.
* [Diagnostic] add a warning which warns about misleading indentationTyker2019-11-251-0/+184
| | | | | | | | | | | | Summary: Add a warning for misleading indentation similar to GCC's -Wmisleading-indentation Reviewers: aaron.ballman, xbolva00 Reviewed By: aaron.ballman, xbolva00 Subscribers: arphaman, Ka-Ka, thakis Differential Revision: https://reviews.llvm.org/D70638
* [Diagnostics] Make behaviour of Clang's -Wdeprecated-copy same as in GCCDávid Bolvanský2019-11-231-0/+6
| | | | Do not warn for functions that are explicitly marked delete or default, which follows the behavior of the GCC warning.
* [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copyDávid Bolvanský2019-11-221-0/+23
| | | | | | | | | | | | | | | | | Summary: GCC 9 added -Wdeprecated-copy (as part of -Wextra). This diagnostic is already implemented in Clang too, just hidden under -Wdeprecated (not on by default). This patch adds -Wdeprecated-copy and makes it compatible with GCC 9+. This diagnostic is heavily tested in deprecated.cpp, so I added simple tests just to check we warn when new flag/-Wextra is enabled. Reviewers: rsmith, dblaikie Reviewed By: dblaikie Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70342
* [coroutines] Remove assert on CoroutineParameterMoves in ↵Brian Gesiak2019-11-221-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Sema::buildCoroutineParameterMoves Summary: The assertion of CoroutineParameterMoves happens when build coroutine function with arguments multiple time while fails to build promise type. Fix: use return false instead. Test Plan: check-clang Reviewers: modocache, GorNishanov, rjmccall Reviewed By: modocache Subscribers: rjmccall, EricWF, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69022 Patch by junparser (JunMa)!
* Add -Wtautological-compare to -WallWeverything2019-11-121-0/+1
| | | | | | | | Some warnings in -Wtautological-compare subgroups are DefaultIgnore. Adding this group to -Wmost, which is part of -Wall, will aid in their discoverability. Differential Revision: https://reviews.llvm.org/D69292
* [Diagnostics] Try to improve warning message for -Wreturn-typeDávid Bolvanský2019-11-094-25/+25
| | | | | | | | | | | | | | Summary: I agree with https://easyaspi314.github.io/gcc-vs-clang.html?fbclid=IwAR1VA0qxiWVUusOQUv5z7JESS7ZpeJy-UqAI5mnJscofGLqXcqeErIUB2gU, current warning message is not very good. We should try to improve it.. Reviewers: rsmith, aaron.ballman, easyaspi314 Reviewed By: aaron.ballman Subscribers: arphaman, Quuxplusone, mehdi_amini, hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D69762
* Revert "Reapply "Fix crash on switch conditions of non-integer types in ↵Melanie Blower2019-11-081-2/+1
| | | | | | | templates"" This reverts commit 759948467ea3181615d44d80f74ffeb260180fd0. There were build bot failures in clang-tidy
* Reapply "Fix crash on switch conditions of non-integer types in templates"Melanie Blower2019-11-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch reapplies commit 76945821b9cad3. The first version broke buildbots due to clang-tidy test fails. The fails are because some errors in templates are now diagnosed earlier (does not wait till instantiation). I have modified the tests to add checks for these diagnostics/prevent these diagnostics. There are no additional code changes. Summary of code changes: Clang currently crashes for switch statements inside a template when the condition is a non-integer field member because contextual implicit conversion is skipped when parsing the condition. This conversion is however later checked in an assert when the case statement is handled. The conversion is skipped when parsing the condition because the field member is set as type-dependent based on its containing class. This patch sets the type dependency based on the field's type instead. This patch fixes Bug 40982. Reviewers: rnk, gribozavr2 Patch by: Elizabeth Andrews (eandrews) Differential revision: https://reviews.llvm.org/D69950
* [SEH] Defer checking filter expression types until instantiatonReid Kleckner2019-11-071-0/+14
| | | | | | | | | | | While here, wordsmith the error a bit. Now clang says: error: filter expression has non-integral type 'Foo' Fixes PR43779 Reviewers: amccarth Differential Revision: https://reviews.llvm.org/D69969
* Revert "[Sema] Suppress -Wchar-subscripts if the index is a literal char"Edward Jones2019-11-071-13/+0
| | | | This reverts commit 7adab7719e55e1b29bfd521dcc73f202139e8f41.
* [Sema] Suppress -Wchar-subscripts if the index is a literal charEdward Jones2019-11-071-0/+13
| | | | | | | | Assume that the user knows what they're doing if they provide a char literal as an array index. This more closely matches the behavior of GCC. Differential Revision: https://reviews.llvm.org/D58896
* [Diagnostics] Improve some error messages related to bad use of dynamic_castDávid Bolvanský2019-11-041-6/+6
|
* [Diagnostics] Warn for std::is_constant_evaluated in constexpr modeDávid Bolvanský2019-10-312-1/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: constexpr int fn1() { if constexpr (std::is_constant_evaluated()) // condition is always true! return 0; else return 1; } constexpr int fn2() { if (std::is_constant_evaluated()) return 0; else return 1; } Solves PR42977 Reviewers: rsmith, aaron.ballman Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69518
* Fix __attribute__((enable_if)) to treat arguments with side-effects asRichard Smith2019-10-301-1/+29
| | | | | | | | non-constant. We previously failed the entire condition evaluation if an unmodeled side-effect was encountered in an argument, even if that argument was unused in the attribute's condition.
* Thread safety analysis: Peel away NoOp implicit casts in initializersAaron Puchert2019-10-301-0/+14
| | | | | | | | | | | | Summary: This happens when someone initializes a variable with guaranteed copy elision and an added const qualifier. Fixes PR43826. Reviewers: aaron.ballman, rsmith Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D69533
* Accept __is_same_as as a GCC-compatibility synonym for the proper trait name ↵Richard Smith2019-10-291-0/+4
| | | | __is_same.
* Fix argument numbering confusion when diagnosing a non-viable operator().Richard Smith2019-10-291-0/+7
| | | | | This could lead to crashes if operator() is a variadic template, as we could end up asking for an out-of-bounds argument.
* PR43775: don't produce a bogus 'auto' -Wc++98-compat warning for CTADRichard Smith2019-10-271-0/+17
|
* PR43762: when implicitly changing the active union member for anRichard Smith2019-10-271-0/+42
| | | | | assignment during constant evaluation, only start the lifetime of trivially-default-constructible union members.
* When diagnosing an ambiguity, only note the candidates that contributeRichard Smith2019-10-249-15/+14
| | | | to the ambiguity, rather than noting all viable candidates.
* [c++2a] Allow comparison functions to be explicitly defaulted.Richard Smith2019-10-222-1/+34
| | | | | | This adds some initial syntactic checking that only the appropriate function signatures can be defaulted. No implicit definitions are generated yet.
* New tautological warning for bitwise-or with non-zero constant always true.Richard Trieu2019-10-191-0/+12
| | | | | | | | | | | | | | | | | | Taking a value and the bitwise-or it with a non-zero constant will always result in a non-zero value. In a boolean context, this is always true. if (x | 0x4) {} // always true, intended '&' This patch creates a new warning group -Wtautological-bitwise-compare for this warning. It also moves in the existing tautological bitwise comparisons into this group. A few other changes were needed to the CFGBuilder so that all bool contexts would be checked. The warnings in -Wtautological-bitwise-compare will be off by default due to using the CFG. Fixes: https://bugs.llvm.org/show_bug.cgi?id=42666 Differential Revision: https://reviews.llvm.org/D66046 llvm-svn: 375318
* [c++20] Add rewriting from comparison operators to <=> / ==.Richard Smith2019-10-192-5/+5
| | | | | | | | | | | | | | | | | This adds support for rewriting <, >, <=, and >= to a normal or reversed call to operator<=>, for rewriting != to a normal or reversed call to operator==, and for rewriting <=> and == to reversed forms of those same operators. Note that this is a breaking change for various C++17 code patterns, including some in use in LLVM. The most common patterns (where an operator== becomes ambiguous with a reversed form of itself) are still accepted under this patch, as an extension (with a warning). I'm hopeful that we can get the language rules fixed before C++20 ships, and the extension warning is aimed primarily at providing data to inform that decision. llvm-svn: 375306
* PR43674: fix incorrect constant evaluation of 'switch' where no caseRichard Smith2019-10-151-0/+6
| | | | | | label corresponds to the condition. llvm-svn: 374954
* PR43080: Do not build context-sensitive expressions during name classification.Richard Smith2019-10-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | Summary: We don't know what context to use until the classification result is consumed by the parser, which could happen in a different semantic context. So don't build the expression that results from name classification until we get to that point and can handle it properly. This covers everything except C++ implicit class member access, which is a little awkward to handle properly in the face of the protected member access check. But it at least fixes all the currently-filed instances of PR43080. Reviewers: efriedma Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68896 llvm-svn: 374826
* Suppress false-positive -Wdeprecated-volatile warning from ↵Richard Smith2019-10-111-0/+2
| | | | | | __is_*_assignable(volatile T&, U). llvm-svn: 374580
* PR43629: Fix crash evaluating constexpr placement new on a subobject ofRichard Smith2019-10-101-0/+10
| | | | | | an out-of-lifetime object. llvm-svn: 374465
* [clang] prevent crash for nonnull attribut in constant context (Bug 43601)Gauthier Harnisch2019-10-101-3/+4
| | | | | | | | | | | | | | | | | | Summary: bug : https://bugs.llvm.org/show_bug.cgi?id=43601 Reviewers: rnk Reviewed By: rnk Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68716 llvm-svn: 374285
* [c++20] P1152R4: warn on any simple-assignment to a volatile lvalueRichard Smith2019-10-091-13/+36
| | | | | | | | | | | | whose value is not ignored. We don't warn on all the cases that are deprecated: specifically, we choose to not warn for now if there are parentheses around the assignment but its value is not actually used. This seems like a more defensible rule, particularly for cases like sizeof(v = a), where the parens are part of the operand rather than the sizeof syntax. llvm-svn: 374135
* [c++20] Implement most of P1152R4.Richard Smith2019-10-091-1/+68
| | | | | | | | | | | | | | Diagnose some now-deprecated uses of volatile types: * as function parameter types and return types * as the type of a structured binding declaration * as the type of the lvalue operand of an increment / decrement / compound assignment operator This does not implement a check for the deprecation of simple assignments whose results are used; that check requires somewhat more complexity and will be addressed separately. llvm-svn: 374133
* [c++20] Check for a class-specific operator delete when deleting anRichard Smith2019-10-071-0/+19
| | | | | | object of class type with a virtual destructor. llvm-svn: 373875
* Fix behavior of __builtin_bit_cast when the From and To types are theRichard Smith2019-10-071-0/+16
| | | | | | | | | | same. We were missing the lvalue-to-rvalue conversion entirely in this case, and in fact still need the full CK_LValueToRValueBitCast conversion to perform a load with no TBAA. llvm-svn: 373874
* [Sema] Avoids an assertion failure when an invalid conversion declaration is ↵Richard Smith2019-10-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | used Summary: When using a user-defined conversion function template with a deduced return type the compiler gives a set of warnings: ``` bug.cc:252:44: error: cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'auto (Ts &&...) const' template <typename... Ts> operator auto()(Ts &&... xs) const; ^~~~~~~~~~~~~~~~~~~ bug.cc:252:29: error: conversion function cannot convert to a function type template <typename... Ts> operator auto()(Ts &&... xs) const; ^ error: pointer to function type cannot have 'const' qualifier ``` after which it triggers an assertion failure. It seems the last error is incorrect and doesn't have any location information. This patch stops the compilation after the second warning. Fixes bug 31422. Patch by Mark de Wever! Reviewers: rsmith Reviewed By: rsmith Subscribers: bbannier, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64820 llvm-svn: 373862
* [NFCI] Slightly improve warning messageDavid Bolvansky2019-10-051-1/+1
| | | | llvm-svn: 373818
* PR43519: don't inject a diagnostic when constant-evaulation of aRichard Smith2019-10-031-0/+5
| | | | | | | | | | pointer-to-member call can't determine a callee. We will have produced a diagnostic already if the callee is known to be unevaluatable, and diagnosing here rejects valid code during potential constant expression checking. llvm-svn: 373553
* For P0784R7: support placement new-expressions in constant evaluation.Richard Smith2019-10-031-0/+83
| | | | | | | | | For now, we restrict this support to use from within the standard library implementation, since we're required to make parts of the standard library that use placement new work, but not permitted to make uses of placement new from user code work. llvm-svn: 373547
* For P0784R7: allow direct calls to operator new / operator delete fromRichard Smith2019-10-031-0/+85
| | | | | | std::allocator::{allocate,deallocate} in constant evaluation. llvm-svn: 373546
* Revert r368237 - Update fix-it hints for std::move warnings.Richard Trieu2019-10-022-50/+44
| | | | | | | | r368237 attempted to improve fix-its for move warnings, but introduced some regressions to -Wpessimizing-move. Revert that change and add the missing test cases to the pessimizing move test to prevent future regressions. llvm-svn: 373421
* Fix crash on constant-evaluation of pseudo-destruction of a pointer.Richard Smith2019-10-021-0/+9
| | | | | | | We got confused and thought we might be pseudo-destroying the pointee instead. llvm-svn: 373418
* [NFC] Updated tests after rL373371David Bolvansky2019-10-011-4/+0
| | | | | | Forgot to run check-clang-semacxx. llvm-svn: 373375
* [c++20] Add a C++20 version of the existing turing machine test.Richard Smith2019-10-011-0/+66
| | | | | | | | Unlike the C++11 version, this one uese mutable state and dynamic allocation instead of a carefully balanced and ever-accumulating pile of temporaries. llvm-svn: 373281
* During constant evaluation, handle CXXBindTemporaryExprs forRichard Smith2019-10-011-0/+5
| | | | | | array-of-class types, not just for class types. llvm-svn: 373279
* [c++20] Fix crash when constant-evaluating an assignment with aRichard Smith2019-10-011-0/+23
| | | | | | reference member access on its left-hand side. llvm-svn: 373276
* Fix crash on value-dependent delete-expressions.Richard Smith2019-09-301-0/+6
| | | | | | | We used to miscompute the 'value-dependent' bit, and would crash if we tried to evaluate a delete expression that should be value-dependent. llvm-svn: 373272
* [NFC] Fix tests, second tryDavid Bolvansky2019-09-301-4/+4
| | | | llvm-svn: 373258
* [NFCI] Updated broken testDavid Bolvansky2019-09-301-0/+4
| | | | llvm-svn: 373256
* Don't crash if a variable with a constexpr destructor has aRichard Smith2019-09-291-0/+9
| | | | | | value-dependent initializer. llvm-svn: 373173
* For now, disallow lifetime-extended temporaries with non-trivial (butRichard Smith2019-09-291-0/+19
| | | | | | | | | | | | constexpr) destructors from being used in the values of constexpr variables. The standard rules here are unclear at best, so rejecting the problematic cases seems prudent. Prior to this change, we would fail to run the destructors for these temporaries, even if they had side-effects, which is certainly not the right behavior. llvm-svn: 373161
OpenPOWER on IntegriCloud