summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [c++2a] Allow comparison functions to be explicitly defaulted.Richard Smith2019-10-221-1/+1
| | | | | | This adds some initial syntactic checking that only the appropriate function signatures can be defaulted. No implicit definitions are generated yet.
* P1286R2: Remove restriction that the exception specification of aRichard Smith2019-05-061-3/+20
| | | | | | defaulted special member matches the implicit exception specification. llvm-svn: 360011
* PR38627: Fix handling of exception specification adjustment forRichard Smith2018-09-051-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. llvm-svn: 341499
* Add a note that points to the linkage specifier for the C++ linkage errorsAlex Lorenz2016-11-021-1/+1
| | | | | | | | | | | | This commit improves the "must have C++ linkage" error diagnostics that are emitted for C++ declarations like templates and literal operators by adding an additional note that points to the appropriate extern "C" linkage specifier. rdar://19021120 Differential Revision: https://reviews.llvm.org/D26189 llvm-svn: 285823
* DR1330: instantiate exception-specifications when "needed". We previously didRichard Smith2016-10-181-15/+19
| | | | | | | | | | | | | | | | | | | | not instantiate exception specifications of functions if they were only used in unevaluated contexts (other than 'noexcept' expressions). In C++17 onwards, this becomes essential since the exception specification is now part of the function's type. Note that this means that constructs like the following no longer work: struct A { static T f() noexcept(...); decltype(f()) *p; }; ... because the decltype expression now needs the exception specification of 'f', which has not yet been parsed. llvm-svn: 284549
* When two function types have equivalent (but distinct) noexcept ↵Richard Smith2016-10-181-6/+3
| | | | | | specifications, create separate type sugar nodes. This is necessary so that substitution into the exception specification will substitute into the correct expression. llvm-svn: 284519
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-161-5/+5
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* Fix crash when emitting error.Richard Trieu2016-10-011-0/+8
| | | | | | | | | | | | With templated classes, is possible to not be able to determine is a member function is a special member function before the class is instantiated. Only these special member functions can be defaulted. In some cases, knowing whether a function is a special member function can't be determined until instantiation, so an uninstantiated function could possibly be defaulted too. Add a case to the error diagnostic when the function marked with a default is not known to be a special member function. llvm-svn: 282989
* Revert r282547 and add test to show correct behavior.Richard Trieu2016-09-271-25/+24
| | | | llvm-svn: 282555
* Fix defaulted member functions for templated classes.Richard Trieu2016-09-271-0/+28
| | | | | | | | | | In some cases, non-special member functions were being marked as being defaulted in templated classes. This can cause interactions with later code that expects the default function to be one of the specific member functions. Fix the check so that templated class members are checked the same way as non-templated class members are. llvm-svn: 282547
* [Sema] Only define function as move assignment when neededErik Pilkington2016-06-201-0/+12
| | | | | | | | Fixes PR27941, a crash on invalid. Differential revision: http://reviews.llvm.org/D20923 llvm-svn: 273193
* Teach Sema::MergeFunctionDecl to properly check for an out-of-line ↵Vassil Vassilev2016-05-181-0/+8
| | | | | | | | | | | | definition of a function that is declared as =default in its class definition. First part of PR27699. Patch by Cristina Cristescu! Reviewed by Richard Smith and me. llvm-svn: 269935
* Sema: Recover when a function template is in an extern "C" blockDavid Majnemer2015-01-151-1/+1
| | | | llvm-svn: 226135
* PR15597: Fix a confusion between the implicit exception specification and theRichard Smith2013-03-271-1/+14
| | | | | | | | uninstantiated exception specification when a special member within a class template is both defaulted and given an exception specification on its first declaration. llvm-svn: 178103
* Add the testcase from PR13573, this used to crash.Benjamin Kramer2013-02-241-0/+5
| | | | | | The error is a bit strange tbh, but better than crashing. llvm-svn: 175996
* Fixes crash when illegal function definitions are deleted or defaulted. ↵Aaron Ballman2013-01-161-0/+21
| | | | | | Fixes PR14577. llvm-svn: 172676
* PR13527: don't assert if a function is explicitly defaulted when it's alreadyRichard Smith2012-08-061-0/+32
| | | | | | been defined. llvm-svn: 161315
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* Allow friend declarations of defaulted special member functions. OnlyRichard Smith2012-06-081-0/+6
| | | | | | definitions of such members are prohibited, not mere declarations. llvm-svn: 158186
* Fold the six functions checking explicitly-defaulted special member functionsRichard Smith2012-05-151-6/+6
| | | | | | | | | | | | into one. These were all performing almost identical checks, with different bugs in each of them. This fixes PR12806 (we weren't setting the exception specification for an explicitly-defaulted, non-user-provided default constructor) and enforces 8.4.2/2's rule that an in-class defaulted member must exactly match the implicit parameter type. llvm-svn: 156802
* Fix another issue introduced by the proposed wording for core issue 1358: sinceRichard Smith2012-02-141-1/+9
| | | | | | | | | | the instantiation of a constexpr function temploid is now always constexpr, a defaulted constexpr function temploid is often ill-formed by the rule in [dcl.fct.def.default]p2 that an explicitly-defaulted constexpr function must have a constexpr implicit definition. To avoid making loads of completely reasonable code ill-formed, do not apply that rule to templates. llvm-svn: 150453
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-1/+1
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Implement some tests for defaulted constructors. To do this I had toAlexis Hunt2011-05-171-0/+45
suppress an error we were previously emitting on valid union code. llvm-svn: 131440
OpenPOWER on IntegriCloud