summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class
Commit message (Collapse)AuthorAgeFilesLines
* PR44721: Don't consider overloaded operators for built-in comparisonsRichard Smith2020-02-041-0/+12
| | | | | | | | | | | | | | | | | | | | when building a defaulted comparison. As a convenient way of asking whether `x @ y` is valid and building it, we previouly always performed overload resolution and built an overloaded expression, which would both end up picking a builtin operator candidate when given a non-overloadable type. But that's not quite right, because it can result in our finding a user-declared operator overload, which we should never do when applying operators non-overloadable types. Handle this more correctly: skip overload resolution when building `x @ y` if the operands are not overloadable. But still perform overload resolution (considering only builtin candidates) when checking validity, as we don't have any other good way to ask whether a binary operator expression would be valid. (cherry picked from commit 1f3f8c369a5067a132c871f33a955a7feaea8534)
* PR44723: Trigger return type deduction for operator<=>s whose returnRichard Smith2020-01-311-0/+33
| | | | | | | | | | types are needed to compute the return type of a defaulted operator<=>. This raises the question of what to do if return type deduction fails. The standard doesn't say, and implementations vary, so for now reject that case eagerly to keep our options open. (cherry picked from commit 42d4a55f227a1cc78ab8071062d869abe88655d9)
* PR44627: Consider reversing == and <=> candidates found by ADL.Richard Smith2020-01-301-1/+1
| | | | (cherry picked from commit 1db66e705f4dbe7dbe17edac804289ef59d5f616)
* [Concepts] Deprecate -fconcepts-ts, enable Concepts under -std=c++2aSaar Raz2020-01-241-3/+2
| | | | | | | | | Now with concepts support merged and mostly complete, we do not need -fconcepts-ts (which was also misleading as we were not implementing the TS) and can enable concepts features under C++2a. A warning will be generated if users still attempt to use -fconcepts-ts. (cherry picked from commit 67c608a9695496cfc9d3fdf9d0b12b554ac6b4df)
* [c++20] Compute exception specifications for defaulted comparisons.Richard Smith2019-12-152-10/+10
| | | | | | | | This requires us to essentially fully form the body of the defaulted comparison, but from an unevaluated context. Naively this would require generating the function definition twice; instead, we ensure that the function body is implicitly defined before performing the check, and walk the actual body where possible.
* [c++20] Implement P1946R0: allow defaulted comparisons to take theirRichard Smith2019-12-102-4/+28
| | | | arguments by value.
* [c++20] Delete defaulted comparison functions if they would invoke anRichard Smith2019-12-103-0/+98
| | | | inaccessible comparison function.
* [c++20] Implement P1185R2 (as modified by P2002R0).Richard Smith2019-12-101-0/+146
| | | | | | For each defaulted operator<=> in a class that doesn't explicitly declare any operator==, also inject a matching implicit defaulted operator==.
* [c++20] Return type deduction for defaulted three-way comparisons.Richard Smith2019-12-101-0/+125
|
* [c++20] Fix handling of unqualified lookups from a defaulted comparisonRichard Smith2019-12-091-0/+76
| | | | | | | | | | function. We need to perform unqualified lookups from the context of a defaulted comparison, but not until we implicitly define the function, at which point we can't do those lookups any more. So perform the lookup from the end of the class containing the =default declaration and store the lookup results on the defaulted function until we synthesize the body.
* [c++20] Defaulted comparison support for array members.Richard Smith2019-12-095-37/+92
|
* [c++20] Synthesis of defaulted comparison functions.Richard Smith2019-12-087-20/+222
| | | | | | Array members are not yet handled. In addition, defaulted comparisons can't yet find comparison operators by unqualified lookup (only by member lookup and ADL). These issues will be fixed in follow-on changes.
* [c++20] Determine whether a defaulted comparison should be deleted orRichard Smith2019-12-067-47/+502
| | | | constexpr.
* [c++20] Enforce rule that a union-like class or class with referenceRichard Smith2019-10-271-0/+70
| | | | members cannot have defaulted comparisons.
* [c++2a] Allow comparison functions to be explicitly defaulted.Richard Smith2019-10-223-0/+96
| | | | | | This adds some initial syntactic checking that only the appropriate function signatures can be defaulted. No implicit definitions are generated yet.
* When typo-correcting a function name, consider correcting to a type nameRichard Smith2019-05-091-2/+2
| | | | | | for a function-style cast. llvm-svn: 360302
* Add missing diagnostic for anonymous struct/union definitions that don'tRichard Smith2019-04-241-1/+1
| | | | | | introduce any names. llvm-svn: 359051
* DR674, PR38883, PR40238: Qualified friend lookup should look for aRichard Smith2019-01-071-2/+2
| | | | | | | | | | | | | | | | | | template specialization if there is no matching non-template function. This exposed a couple of related bugs: - we would sometimes substitute into a friend template instead of a suitable non-friend declaration; this would now crash because we'd decide the specialization of the friend is a redeclaration of itself - ADL failed to properly handle the case where an invisible local extern declaration redeclares an invisible friend Both are fixed herein: in particular, we now never make invisible friends or local extern declarations visible to name lookup unless they are the only declaration of the entity. (We already mostly did this for local extern declarations.) llvm-svn: 350505
* Related to PR37768: improve diagnostics for class name shadowing.Richard Smith2018-06-202-3/+49
| | | | | | | | | | | | Diagnose the name of the class being shadowed by using declarations, and improve the diagnostics for the case where the name of the class is shadowed by a non-static data member in a class with constructors. In the latter case, we now always give the "member with the same name as its class" diagnostic regardless of the relative order of the member and the constructor, rather than giving an inscrutible diagnostic if the constructor appears second. llvm-svn: 335182
* Adjust and fix failing CXX tests after r332799Eric Fiselier2018-05-191-8/+8
| | | | llvm-svn: 332800
* Implement DR2229, which prohibits unnamed bit-fields from having qualifiers ↵Aaron Ballman2018-03-171-1/+1
| | | | | | in C++. llvm-svn: 327781
* Don't warn about runtime behavior problems in variable initializers that weRichard Smith2017-09-231-1/+1
| | | | | | | | know are going to be constant-evaluated. Any relevant diagnostics should be produced by constant expression evaluation. llvm-svn: 314067
* revert changes from r311851.Faisal Vali2017-08-271-14/+3
| | | | | | | | The right answers here (and how clang needs to be tweaked) require further analysis (ongoing cwg thread). sorry. llvm-svn: 311855
* Don't see through 'using member-declarations' when determining the relation ↵Faisal Vali2017-08-271-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | of any potential implicit object expression to the parent class of the member function containing the function call. Prior to this patch clang would not error here: template <class T> struct B; template <class T> struct A { void foo(); void foo2(); void test1() { B<T>::foo(); // OK, foo is declared in A<int> - matches type of 'this'. B<T>::foo2(); // This should be an error! // foo2 is found in B<int>, 'base unrelated' to 'this'. } }; template <class T> struct B : A<T> { using A<T>::foo2; }; llvm-svn: 311851
* Fix all tests under test/CXX (and test/Analysis) to pass if clang's defaultRichard Smith2016-08-311-1/+1
| | | | | | C++ language standard is not C++98. llvm-svn: 280309
* Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith2016-06-252-3/+19
| | | | | | | variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
* Lit C++11 Compatibility Patch #8Charles Li2016-04-142-3/+16
| | | | | | 24 tests have been updated for C++11 compatibility. llvm-svn: 266387
* PR26048, PR26050: put non-type template parameters and indirect field declsRichard Smith2016-01-061-4/+2
| | | | | | | | into IDNS_Tag in C++, because they conflict with redeclarations of tags. (This doesn't affect elaborated-type-specifier lookup, which looks for IDNS_Type in C++). llvm-svn: 256985
* Fix half of PR26048. We don't yet diagnose the case where the anonymous ↵Richard Smith2016-01-063-2/+28
| | | | | | union member is declared first and the tag name is declared second. llvm-svn: 256979
* [Lit Test] Updated 20 Lit tests to be C++11 compatible.Charles Li2015-12-101-1/+6
| | | | | | | | This is the 5th Lit test patch. Expanded expected diagnostics to vary by C++ dialect. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 255196
* [Sema] Don't crash when friending an unqualified templated constructorDavid Majnemer2015-09-301-0/+6
| | | | | | | | | | Unqualified templated constructors cannot be friended and our lack of a diagnostic led to violated invariants. Instead, raise a diagnostic when processing the friend declaration. This fixes PR20251. llvm-svn: 248953
* DR1909: Diagnose all invalid cases of a class member sharing its name with ↵Richard Smith2015-07-061-6/+35
| | | | | | the class. llvm-svn: 241425
* When we see something that looks like a constructor with a return type, only ↵Richard Smith2015-07-061-5/+2
| | | | | | issue one error, not two. llvm-svn: 241424
* Don't crash if a declarator in a friend decl doesn't have a name.Nico Weber2015-01-161-0/+4
| | | | | | | | | | | There was already an explicit check for that for the first decl. Move that to a different place so that it's called for the following decls too. Also don't randomly set the BitfieldSize ExprResult to true (this sets a pointer to true internally). Found by SLi's bot. llvm-svn: 226306
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-0/+30
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* Implement DR1460: fix handling of default initializers in unions; don't allowRichard Smith2013-12-101-0/+10
| | | | | | | | | more than one such initializer in a union, make mem-initializers override default initializers for other union members, handle anonymous unions with anonymous struct members better. Fix a couple of semi-related bugs exposed by the tests for same. llvm-svn: 196892
* Provide better diagnostic wording for initializers on staticHans Wennborg2013-11-211-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data member definitions when the variable has an initializer in its declaration. For the following code: struct S { static const int x = 42; }; const int S::x = 42; This patch changes the diagnostic from: a.cc:4:14: error: redefinition of 'x' const int S::x = 42; ^ a.cc:2:20: note: previous definition is here static const int x = 42; ^ to: a.cc:4:18: error: static data member 'x' already has an initializer const int S::x = 42; ^ a.cc:2:24: note: previous initialization is here static const int x = 42; ^ Differential Revision: http://llvm-reviews.chandlerc.com/D2235 llvm-svn: 195306
* Teach typo correction to look inside of classes like it does namespaces.Kaelyn Uhrain2013-09-261-4/+4
| | | | | | | | | | | | | | | Unlike with namespaces, searching inside of classes requires also checking the access to correction candidates (i.e. don't suggest a correction to a private class member for a correction occurring outside that class and its methods or friends). Included is a small (one line) fix for a bug, that was uncovered while cleaning up the unit tests, where the decls from a TypoCorrection candidate were preserved in new TypoCorrection candidates that are derived (copied) from the old TypoCorrection--notably when creating a new candidate by changing the NestedNameSpecifier associated with the base idenitifer. llvm-svn: 191449
* C++11: don't warn about the deprecated 'register' keyword if it's combined withRichard Smith2013-06-171-1/+1
| | | | | | an asm label. llvm-svn: 184069
* Add -Wdeprecated warnings and fixits for things deprecated in C++11:Richard Smith2013-06-131-0/+4
| | | | | | | | | - 'register' storage class - dynamic exception specifications Only the former check is enabled by default for now (the latter might be quite noisy). llvm-svn: 183881
* Parsing support for thread_local and _Thread_local. We give them the sameRichard Smith2013-04-121-2/+10
| | | | | | semantics as __thread for now. llvm-svn: 179424
* Move -Wstatic-float-init fixit into a note & don't recover as if constexprDavid Blaikie2013-01-292-2/+2
| | | | llvm-svn: 173841
* Sync 'in class initialization of static const double' extension up with GCC,Richard Smith2013-01-252-2/+2
| | | | | | | | | | | | | and split it out of -Wgnu into its own warning flag. * In C++11, this is now a hard error (GCC has no extension here in C++11 mode). The error can be disabled with -Wno-static-float-init, and has a fixit to add 'constexpr'. * In C++98, this is still an ExtWarn, but is now controlled by -Wstatic-float-init as well as -Wgnu. llvm-svn: 173414
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-081-25/+28
| | | | | | | | | | | | | | 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. llvm-svn: 169667
* Implement C++03 [dcl.init]p5's checking for value-initialization of referencesRichard Smith2012-12-081-0/+6
| | | | | | | | properly, rather than faking it up by pretending that a reference member makes the default constructor non-trivial. That leads to rejects-valids when putting such types inside unions. llvm-svn: 169662
* Prior to adding the new "expected-no-diagnostics" directive to ↵Andy Gibbs2012-10-195-0/+5
| | | | | | VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive. llvm-svn: 166280
* PR13890: Warn on abstract final classes.David Blaikie2012-09-211-0/+8
| | | | llvm-svn: 164359
* Update source location in test.Benjamin Kramer2012-07-301-3/+2
| | | | llvm-svn: 160964
* Don't use the implicit int rule for error recovery in C++. Instead, try toRichard Smith2012-05-151-2/+3
| | | | | | disambiguate whether the type name was forgotten or mistyped. llvm-svn: 156854
* Fold the six functions checking explicitly-defaulted special member functionsRichard Smith2012-05-151-1/+1
| | | | | | | | | | | | 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
OpenPOWER on IntegriCloud