summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
* Merging r311115:Hans Wennborg2017-08-181-0/+6
| | | | | | | | | | | | ------------------------------------------------------------------------ r311115 | rsmith | 2017-08-17 12:35:50 -0700 (Thu, 17 Aug 2017) | 2 lines PR34161: support evaluation of 'void()' expressions in C++14 onwards. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@311194 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r310804:Hans Wennborg2017-08-145-18/+18
| | | | | | | | | | | | ------------------------------------------------------------------------ r310804 | rsmith | 2017-08-13 15:26:53 -0700 (Sun, 13 Aug 2017) | 2 lines Replace remaining user-visible mentions of C++1z with C++17. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@310862 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r310516:Hans Wennborg2017-08-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r310516 | hans | 2017-08-09 13:12:53 -0700 (Wed, 09 Aug 2017) | 13 lines Make -std=c++17 an alias of -std=c++1z As suggested on PR33912. Trying to keep this small to make it easy to merge to the 5.0 branch. We can do a follow-up with more thorough renaming (diagnostic text, options, ids, etc.) later. (For C++14 this was done in r215982, and I think a smaller patch for the 3.5 branch: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140818/113013.html) Differential Revision: https://reviews.llvm.org/D36532 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@310848 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r310691:Hans Wennborg2017-08-111-0/+23
| | | | | | | | | | | | ------------------------------------------------------------------------ r310691 | rsmith | 2017-08-10 19:04:19 -0700 (Thu, 10 Aug 2017) | 2 lines PR33489: A function-style cast to a deduced class template specialization type is type-dependent if it can't be resolved due to a type-dependent argument. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@310719 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r309569:Hans Wennborg2017-08-111-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r309569 | alexfh | 2017-07-31 08:21:26 -0700 (Mon, 31 Jul 2017) | 39 lines Fix -Wshadow false positives with function-local classes. Summary: Fixes http://llvm.org/PR33947. https://godbolt.org/g/54XRMT void f(int a) { struct A { void g(int a) {} A() { int a; } }; } 3 : <source>:3:16: warning: declaration shadows a local variable [-Wshadow] void g(int a) {} ^ 1 : <source>:1:12: note: previous declaration is here void f(int a) { ^ 4 : <source>:4:15: warning: declaration shadows a local variable [-Wshadow] A() { int a; } ^ 1 : <source>:1:12: note: previous declaration is here void f(int a) { ^ 2 warnings generated. The local variable `a` of the function `f` can't be accessed from a method of the function-local class A, thus no shadowing occurs and no diagnostic is needed. Reviewers: rnk, rsmith, arphaman, Quuxplusone Reviewed By: rnk, Quuxplusone Subscribers: Quuxplusone, cfe-commits Differential Revision: https://reviews.llvm.org/D35941 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@310674 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r309975: (except the docs/ part)Hans Wennborg2017-08-041-1/+24
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r309975 | rsmith | 2017-08-03 12:24:27 -0700 (Thu, 03 Aug 2017) | 4 lines Don't emit undefined-internal warnings for CXXDeductionGuideDecls. Patch by ~paul (cynecx on phabricator)! Some test massaging by me. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@310067 91177308-0d34-0410-b5e6-96231b3b80d8
* Add GCC's noexcept-type alias for c++1z-compat-manglingRaphael Isemann2017-07-181-0/+1
| | | | | | | | | | | | | | Summary: GCC has named this `-Wnoexcept-type`, so let's add an alias to stay compatible with the GCC flags. Reviewers: rsmith, dexonsmith Reviewed By: dexonsmith Subscribers: cfe-commits, karies, v.g.vassilev, ahatanak Differential Revision: https://reviews.llvm.org/D34439 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308340 91177308-0d34-0410-b5e6-96231b3b80d8
* Use ARC parsing rules for ns_returns_retained in MRC so that code canJohn McCall2017-07-151-1/+1
| | | | | | | | be shared without warnings. Build AttributedTypes to leave breadcrumbs for tools like the static analyzer. Warn about attempting to use the attribute with incompatible return types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308092 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Include the implicit object parameter type when looking up ↵Eric Fiselier2017-07-101-4/+261
| | | | | | | | | coroutine_traits for member functions. This patch was originally from Toby Allsopp, but I hijacked it and fixed it up with his permission. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307513 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS] Don't statically initialize dllimport member function pointersReid Kleckner2017-07-071-0/+7
| | | | | | | | | | | | | | | | | | | | Summary: r306137 made dllimport pointers to member functions non-constant. This is correct because a load must be executed to resolve any dllimported data. However, r306137 did not account for the use of dllimport member function pointers used as template arguments. This change re-lands r306137 with a template instantiation fix. This fixes PR33570. Reviewers: rnk, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34714 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307446 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Don't allow -Wunguarded-availability to be silenced with redeclsErik Pilkington2017-07-051-4/+4
| | | | | | Differential revision: https://reviews.llvm.org/D33816 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307175 91177308-0d34-0410-b5e6-96231b3b80d8
* Address comments that escaped D33333Erich Keane2017-07-051-42/+41
| | | | | | | | | Patch By: Jen Yu Differential Revision:https://reviews.llvm.org/D34671 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307172 91177308-0d34-0410-b5e6-96231b3b80d8
* [AMDGPU] Fix size and alignment of size_t and pointer typesYaxun Liu2017-07-051-0/+47
| | | | | | | Differential Revision: https://reviews.llvm.org/D34995 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307121 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules ts] Declarations from a module interface unit are only visible outsideRichard Smith2017-07-051-1/+7
| | | | | | | the module if declared in an export block. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307115 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Make BreakContinueFinder handle nested loops.Eli Friedman2017-07-041-0/+12
| | | | | | | | | | | | | | We don't care about break or continue statements that aren't associated with the current loop, so make sure the visitor doesn't find them. Fixes https://bugs.llvm.org/show_bug.cgi?id=32648 . Differential Revision: https://reviews.llvm.org/D34568 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307051 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Implement -Wcast-qual for C++Roman Lebedev2017-07-031-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This way, the behavior of that warning flag more closely resembles that of GCC. Do note that there is at least one false-negative (see FIXME in tests). Fixes PR4802. Testing: ``` ninja check-clang-sema check-clang-semacxx ``` Reviewers: dblaikie, majnemer, rnk Reviewed By: dblaikie, rnk Subscribers: mclow.lists, cfe-commits, alexfh, rnk Differential Revision: https://reviews.llvm.org/D33102 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307045 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold exception-warnings.cpp into warn-throw-out-noexcept-func.cppStephan Bergmann2017-06-302-36/+37
| | | | | | | I had failed to notice the latter existed when I recently introduced the former. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306799 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Issue diagnostics if a new/delete expression generates a call toAkira Hatanaka2017-06-291-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | a c++17 aligned allocation/deallocation function that is unavailable in the standard library on Apple platforms. The aligned functions are implemented only in the following versions or later versions of the OSes, so clang issues diagnostics if the deployment target being targeted is older than these: macosx: 10.13 ios: 11.0 tvos: 11.0 watchos: 4.0 The diagnostics are issued whenever the aligned functions are selected except when the selected function has a definition in the same file. If there is a user-defined function available somewhere else, option -Wno-aligned-allocation-unavailable can be used to silence the diagnostics. rdar://problem/32664169 Differential Revision: https://reviews.llvm.org/D34574 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306722 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed -Wexceptions derived-to-base false positivesStephan Bergmann2017-06-291-0/+36
| | | | | | | | | | | | | | ...as introduced with recent <https://reviews.llvm.org/D33333> "Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier". (The equivalent of the goodReference case hit when building LibreOffice.) (These warnings are apparently only emitted when no errors have yet been encountered, so it didn't work to add the test code to the end of the existing clang/test/SemaCXX/exceptions.cpp.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306715 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash in clang while handling __has_trivial_destructor.Karthik Bhat2017-06-281-2/+23
| | | | | | | | | | | Fix crash in clang when an array of unknown bounds of an incomplete type is passed to __has_trivial_destructor. Patch by Puneetha https://reviews.llvm.org/D34198 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306519 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r301742, which caused us to try to evaluate all full-expressions.Richard Smith2017-06-261-0/+56
| | | | | | | | | | | | | | | Also add testcases for a bunch of expression forms that cause our evaluator to crash. See PR33140 and PR32864 for crashes that this was causing. This reverts r305287, which reverted r305239, which reverted r301742. The previous revert claimed that buildbots were broken, but did not add any testcases and the buildbots have lost all memory of what was wrong here. Changes to test/OpenMP are not reverted; another change has triggered those tests to change their output in the same way that r301742 did. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306346 91177308-0d34-0410-b5e6-96231b3b80d8
* Check that the initializer of a non-dependent constexpr variable is constant ↵Richard Smith2017-06-261-3/+13
| | | | | | even within templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306327 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Fix a crash-on-invalid when a template parameter list has a classAkira Hatanaka2017-06-262-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | definition or non-reference class type. The crash occurs when there is a template parameter list in a class that is missing the closing angle bracket followed by a definition of a struct. For example: class C0 { public: template<typename T, typename T1 = T // missing closing angle bracket struct S0 {}; C0() : m(new S0<int>) {} S0<int> *m; }; This happens because the parsed struct is added to the scope of the enclosing class without having its access specifier set, which results in an assertion failure in SemaAccess.cpp later. This commit fixes the crash by adding the parsed struct to the enclosing file scope and marking structs as invalid if they are defined in template parameter lists. rdar://problem/31783961 rdar://problem/19570630 Differential Revision: https://reviews.llvm.org/D33606 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306317 91177308-0d34-0410-b5e6-96231b3b80d8
* Add test for 306149, warn on throw from noexceptErich Keane2017-06-231-0/+265
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306156 91177308-0d34-0410-b5e6-96231b3b80d8
* Function with unparsed body is a definitionSerge Pavlov2017-06-211-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While a function body is being parsed, the function declaration is not considered as a definition because it does not have a body yet. In some cases it leads to incorrect interpretation, the case is presented in https://bugs.llvm.org/show_bug.cgi?id=14785: ``` template<typename T> struct Somewhat { void internal() const {} friend void operator+(int const &, Somewhat<T> const &) {} }; void operator+(int const &, Somewhat<char> const &x) { x.internal(); } ``` When statement `x.internal()` in the body of global `operator+` is parsed, the type of `x` must be completed, so the instantiation of `Somewhat<char>` is started. It instantiates the declaration of `operator+` defined inline, and makes a check for redefinition. The check does not detect another definition because the declaration of `operator+` is still not defining as does not have a body yet. To solves this problem the function `isThisDeclarationADefinition` considers a function declaration as a definition if it has flag `WillHaveBody` set. This change fixes PR14785. Differential Revision: https://reviews.llvm.org/D30375 This is a recommit of 305379, reverted in 305381, with small changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305903 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for Bug 33471: Preventing operator auto from resolving to a template ↵Erich Keane2017-06-201-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operator. As the bug report says, struct A { template<typename T> operator T(); }; void foo() { A().operator auto(); } causes: "undeduced type in IR-generation UNREACHABLE executed at llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp:208!" The problem is that in this case, "T" is being deduced as "auto", which I believe is incorrect. The 'operator auto' implementation in Clang is standards compliant, however there is a defect report against core (1670). Differential Revision: https://reviews.llvm.org/D34370 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305812 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a subgroup of c++1z-compat to enable and disable the warning aboutAkira Hatanaka2017-06-201-1/+2
| | | | | | | | | | c++17's non-throwing exception specification in function signature. rdar://problem/32628743 Differential Revision: https://reviews.llvm.org/D34251 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305772 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverted 305379 (Function with unparsed body is a definition)Serge Pavlov2017-06-141-12/+0
| | | | | | | | It broke clang-x86_64-linux-selfhost-modules-2 and some other buildbots. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305381 91177308-0d34-0410-b5e6-96231b3b80d8
* Function with unparsed body is a definitionSerge Pavlov2017-06-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | While a function body is being parsed, the function declaration is not considered as a definition because it does not have a body yet. In some cases it leads to incorrect interpretation, the case is presented in https://bugs.llvm.org/show_bug.cgi?id=14785: ``` template<typename T> struct Somewhat { void internal() const {} friend void operator+(int const &, Somewhat<T> const &) {} }; void operator+(int const &, Somewhat<char> const &x) { x.internal(); } ``` When statement `x.internal()` in the body of global `operator+` is parsed, the type of `x` must be completed, so the instantiation of `Somewhat<char>` is started. It instantiates the declaration of `operator+` defined inline, and makes a check for redefinition. The check does not detect another definition because the declaration of `operator+` is still not defining as does not have a body yet. To solves this problem the function `isThisDeclarationADefinition` considers a function declaration as a definition if it has flag `WillHaveBody` set. This change fixes PR14785. Differential Revision: https://reviews.llvm.org/D30375 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305379 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix co_await for range statementEric Fiselier2017-06-141-0/+165
| | | | | | | | | | | | | | | | | Summary: Currently we build the co_await expressions on the wrong implicit statements of the implicit ranged for; Specifically we build the co_await expression wrapping the range declaration, but it should wrap the begin expression. This patch fixes co_await on range for. Reviewers: rsmith, GorNishanov Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34021 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305363 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix spurious Wunused-lambda-capture warningYi Kong2017-06-131-0/+5
| | | | | | | | | | | | | | | | | Summary: Clang emits unused-lambda-capture warning for captures in generic lambdas even though they are actually used. Fixes PR31815. Reviewers: malcolm.parsons, aaron.ballman, rsmith Reviewed By: malcolm.parsons Subscribers: ahatanak, cfe-commits Differential Revision: https://reviews.llvm.org/D33526 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305315 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema][C++1z] Ensure binding in dependent range for have non-null typeErik Pilkington2017-06-121-0/+6
| | | | | | | | Fixes PR32172 Differential revision: https://reviews.llvm.org/D34096 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305195 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't crash when forming a destructor name on an incomplete type.John McCall2017-06-111-0/+7
| | | | | | | | Fixes PR25156. Patch by Don Hinton! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305169 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[clang] Implement -Wcast-qual for C++"Roman Lebedev2017-06-101-140/+0
| | | | | | Breaks -Werror builders. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305148 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Implement -Wcast-qual for C++Roman Lebedev2017-06-101-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This way, the behavior of that warning flag more closely resembles that of GCC. Do note that there is at least one false-negative (see FIXME in tests). Fixes PR4802. Testing: ``` ninja check-clang-sema check-clang-semacxx ``` Reviewers: dblaikie, majnemer, rnk Reviewed By: dblaikie, rnk Subscribers: cfe-commits, alexfh, rnk Differential Revision: https://reviews.llvm.org/D33102 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305147 91177308-0d34-0410-b5e6-96231b3b80d8
* 27037: Use correct CVR qualifier on an upcast on method pointer callRichard Smith2017-06-091-0/+13
| | | | | | | | | Patch by Taiju Tsuiki! Differential Revision: https://reviews.llvm.org/D33875 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305126 91177308-0d34-0410-b5e6-96231b3b80d8
* Weaken restriction in r304862 to allow implicit deduction guides to referenceRichard Smith2017-06-081-0/+8
| | | | | | | | the injected-class-name of a specialization that uses a partial / explicit specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304957 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++1z] Support deducing B in noexcept(B).Richard Smith2017-06-071-1/+1
| | | | | | | | | This is not required by the standard (yet), but there seems to be reasonable support for this being a defect according to CWG discussion, and libstdc++ 7.1 relies on it working. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304946 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a couple of class template argument deduction crashes with libc++'s tuple.Richard Smith2017-06-071-0/+24
| | | | | | | | | | | | | | | | | RecursiveASTVisitor was not properly recursing through a SubstTemplateTypeParmTypes, resulting in crashes in pack expansion where we couldn't always find an unexpanded pack within a pack expansion. We also have an issue where substitution of deduced template arguments for an implicit deduction guide creates the "impossible" case of naming a non-dependent member of the current instantiation, but within a specialization that is actually instantiated from a different (partial/explicit) specialization of the template. We resolve this by declaring that constructors that do so can only be used to deduce specializations of the primary template. I'm running this past CWG to see if people agree this is the right thing to do. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304862 91177308-0d34-0410-b5e6-96231b3b80d8
* PR33318: Add missing full-expression checking to static_assert expression.Richard Smith2017-06-061-0/+4
| | | | | | | | This fixes missing lambda-captures for variables referenced only inside a static_assert (!), among other things. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304760 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement isDefined by call to isThisDeclarationADefinition.Serge Pavlov2017-06-041-3/+3
| | | | | | | | | | | | Modifies FunctionDecl::isThisDeclarationADefinition so that it covers all the cases checked by FunctionDecl::isDefined. Implements the latter method by call to isThisDeclarationADefinition. This change is a part of the patch D30170. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304684 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix rebuilding of dependent coroutine parametersEric Fiselier2017-06-031-0/+13
| | | | | | | | | | | | | | | | Summary: We were not handling correctly rebuilding of parameter and were not creating copies for them. Now we will always rebuild parameter moves in TreeTransform's TransformCoroutineBodyStmt. Reviewers: rsmith, GorNishanov Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33797 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304620 91177308-0d34-0410-b5e6-96231b3b80d8
* [SemaCXX] Add diagnostics to require_constant_initializationKeno Fischer2017-06-011-9/+63
| | | | | | | | | | | | | Summary: This hooks up the detailed diagnostics of why constant initialization was not possible if require_constant_initialization reports an error. I have updated the test to account for the new notes. Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24371 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304451 91177308-0d34-0410-b5e6-96231b3b80d8
* PR33232: implement support for MSVC's __is_trivially_destructible trait.Richard Smith2017-06-011-0/+96
| | | | | | | | | | | | | | | | | | Unlike the GCC-compatible __has_trivial_destructor trait, this one computes the right answer rather than performing the quirky set of checks described in GCC's documentation (https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html). MSVC also has a __has_trivial_destructor trait which is the same as its (and now Clang's) __is_trivially_destructible trait; we might want to consider changing the behavior of __has_trivial_destructor if we're targeting an MSVC platform, but I'm not doing so for now. While implementing this I found that we were incorrectly rejecting __is_destructible queries on arrays of unknown bound of incomplete types; that too is fixed, and I've added similar tests for other traits for good measure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304376 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix checking for prvalue-ness of `await_suspend` return typeEric Fiselier2017-05-311-2/+20
| | | | | | | | | | | | | | | | | Summary: @rsmith Does this correctly address the issues mentioned in https://reviews.llvm.org/D33625#inline-292971 ? Reviewers: rsmith, EricWF Reviewed By: EricWF Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D33636 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304373 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix assertion during -Wuninitialized analysisEric Fiselier2017-05-312-1/+45
| | | | | | | | | | | | | | Summary: @rsmith Is there a better place to put this test? Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D33660 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304331 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Diagnose invalid result types for `await_resume` and ↵Eric Fiselier2017-05-281-0/+37
| | | | | | | | | | | | | | | | | | | | | | `await_suspend` and add missing conversions. Summary: The expression `await_ready` is required to be contextually convertible to bool and `await_suspend` must be a prvalue of either `void` or `bool`. This patch adds diagnostics for when those requirements are violated. It also correctly performs the contextual conversion to bool on the result of `await_ready` Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33625 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304094 91177308-0d34-0410-b5e6-96231b3b80d8
* Create valid LValue to represent null pointers in constant exprsTim Northover2017-05-261-0/+8
| | | | | | | | | | | | We were leaving the SubobjectDesignator in a surprising situation, where it was allegedly valid but didn't actually refer to a type. This caused a crash later on. This patch fills out the SubobjectDesignator with the pointee type (as happens in other evaluations of constant pointers) so that we don't crash later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303957 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch from using a DiagnosticTrap and a note for "while defining a specialRichard Smith2017-05-254-20/+14
| | | | | | | | | | | | | | | | | | | | | | | | member function" context notes to registering an entry on the context stack. Also reorder the steps within defining special members to be consistent. This has a few benefits: if multiple diagnostics are produced while checking such a member, the note is now attached to the first such diagnostic rather than the last, this prepares us for persisting these diagnostics between the point at which we require the implicit instantiation of a template and the point at which that instantiation is actually performed, and this fixes some cases where we would fail to produce a full note stack leading back to user code in the case of such a diagnostic. The reordering exposed a case where we could recursively attempt to define a defaulted destructor while we're already defining one (and other such cases also appear to be possible, with or without this change), so this change also reuses the "willHaveBody" flag on function declarations to track that we're in the middle of synthesizing a body for the function and bails out if we try to define a function that we're already defining. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303930 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Diagnose when promise types fail to declare either return_void ↵Eric Fiselier2017-05-252-22/+17
| | | | | | | | | | | | | | | | | | | or return_value. Summary: According to the PDTS it's perfectly legal to have a promise type that defines neither `return_value` nor `return_void`. However a coroutine that uses such a promise type will almost always have UB, because it can never `co_return`. This patch changes Clang to diagnose such cases as an error. It also cleans up some of the diagnostic messages relating to member lookup in the promise type. Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33534 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303868 91177308-0d34-0410-b5e6-96231b3b80d8