summaryrefslogtreecommitdiffstats
path: root/test/CXX/dcl.decl/dcl.fct.def
Commit message (Collapse)AuthorAgeFilesLines
* P1286R2: Remove restriction that the exception specification of aRichard Smith2019-05-061-8/+19
| | | | | | defaulted special member matches the implicit exception specification. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360011 91177308-0d34-0410-b5e6-96231b3b80d8
* [cxx2a] P0641R2: (Some) type mismatches on defaulted functions onlyRichard Smith2018-09-281-2/+49
| | | | | | | | | | | | | | | | render the function deleted instead of rendering the program ill-formed. This change also adds an enabled-by-default warning for the case where an explicitly-defaulted special member function of a non-template class is implicitly deleted by the type checking rules. (This fires either due to this language change or due to pre-C++20 reasons for the member being implicitly deleted). I've tested this on a large codebase and found only bugs (where the program means something that's clearly different from what the programmer intended), so this is enabled by default, but we should revisit this if there are problems with this being enabled by default. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343285 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the likely resolution of core issue 253.Nico Weber2016-02-191-0/+1
| | | | | | | | | | | | | | | | | | | C++11 requires const objects to have a user-provided constructor, even for classes without any fields. DR 253 relaxes this to say "If the implicit default constructor initializes all subobjects, no initializer should be required." clang is currently the only compiler that implements this C++11 rule, and e.g. libstdc++ relies on something like DR 253 to compile in newer versions. This change makes it possible to build code that says `const vector<int> v;' again when using libstdc++5.2 and _GLIBCXX_DEBUG (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284). Fixes PR23381. http://reviews.llvm.org/D16552 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261297 91177308-0d34-0410-b5e6-96231b3b80d8
* Move fixit for const init from note to diag, weaken to warning in MS mode.Nico Weber2015-04-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r235046 turned "extern __declspec(selectany) int a;" from a declaration into a definition to fix PR23242 (required for compatibility with mc.exe output). However, this broke parsing Windows headers: A d3d11 headers contain something like struct SomeStruct {}; extern const __declspec(selectany) SomeStruct some_struct; This is now a definition, and const objects either need an explicit default ctor or an initializer so this errors out with d3d11.h(1065,48) : error: default initialization of an object of const type 'const CD3D11_DEFAULT' without a user-provided default constructor (cl.exe just doesn't implement this rule, independent of selectany.) To work around this, weaken this error into a warning for selectany decls in microsoft mode, and recover with zero-initialization. Doing this is a bit hairy since it adds a fixit on an error emitted by InitializationSequence – this means it needs to build a correct AST, which in turn means InitializationSequence::Failed() cannot return true when this fixit is applied. As a workaround, the patch adds a fixit member to InitializationSequence, and InitializationSequence::Perform() prints the diagnostic if the fixit member is set right after its call to Diagnose. That function is usually called when InitializationSequences are used – InitListChecker::PerformEmptyInit() doesn't call it, but the InitListChecker case never performs default-initialization, so this is technically OK. This is the alternative, original fix for PR20208 that got reviewed in the thread "[patch] Improve diagnostic on default-initializing const variables (PR20208)". This change basically reverts r213725, adds the original fix for PR20208, and makes the error a warning in Microsoft mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235166 91177308-0d34-0410-b5e6-96231b3b80d8
* First half of CWG1962: decltype(__func__) should not be a reference type,Richard Smith2014-11-111-0/+18
| | | | | | | because __func__ is supposed to act like a local static variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221698 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve diagnostic on default-initializing const variables (PR20208).Nico Weber2014-07-231-2/+2
| | | | | | | | | This tweaks the diagnostic wording slighly, and adds a fixit on a note. An alternative would be to add the fixit directly on the diagnostic, see the review thread linked to from the bug for a few notes on that approach. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213725 91177308-0d34-0410-b5e6-96231b3b80d8
* The 'constexpr implies const' rule for non-static member functions is gone inRichard Smith2013-04-211-2/+2
| | | | | | | | | | C++1y, so stop adding the 'const' there. Provide a compatibility warning for code relying on this in C++11, with a fix-it hint. Update our lazily-written tests to add the const, except for those ones which were testing our implementation of this rule. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179969 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-081-3/+2
| | | | | | | | | | | | | | | Remove pre-standard restriction on explicitly-defaulted copy constructors with 'incorrect' parameter types, and instead just make those special members non-trivial as the standard requires. This required making CXXRecordDecl correctly handle classes which have both a trivial and a non-trivial special member of the same kind. This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the new triviality computation technology. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169667 91177308-0d34-0410-b5e6-96231b3b80d8
* Per [dcl.fct.def.default]p1, don't allow variadic special members to be ↵Richard Smith2012-12-071-0/+26
| | | | | | defaulted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169574 91177308-0d34-0410-b5e6-96231b3b80d8
* Explicitly defaulted constructors cannot be used for default initialization.Aaron Ballman2012-07-311-3/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161088 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12937: Explicitly deleting an explicit template specialization.David Blaikie2012-06-251-0/+8
| | | | | | | | | | | | | | | This works around a quirk in the way that explicit template specializations are handled in Clang. We generate an implicit declaration from the original template which the explicit specialization is considered to redeclare. This trips up the explicit delete logic. This change only works around that strange representation. At some point it'd be nice to remove those extra declarations to make the AST more accurately reflect the C++ semantics. Review by Doug Gregor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159167 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold the six functions checking explicitly-defaulted special member functionsRichard Smith2012-05-151-1/+59
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156802 91177308-0d34-0410-b5e6-96231b3b80d8
* Special members which are defaulted or deleted on their first declaration areRichard Smith2012-02-261-1/+2
| | | | | | | | | | | | | | trivial if the implicit declaration would be. Don't forget to set the Trivial flag on the special member as well as on the class. It doesn't seem ideal that we have two separate mechanisms for storing this information, but this patch does not attempt to address that. This leaves us in an interesting position where the has_trivial_X trait for a class says 'yes' for a deleted but trivial X, but is_trivially_Xable says 'no'. This seems to be what the standard requires. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151465 91177308-0d34-0410-b5e6-96231b3b80d8
* PR11614: Mark defaulted special constructors as constexpr if their implicitRichard Smith2011-12-221-0/+55
definition would satisfy the constexpr requirements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147128 91177308-0d34-0410-b5e6-96231b3b80d8