summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Disable our non-standard delayed parsing of exception specifications. DelayingRichard Smith2012-05-021-30/+0
| | | | | | | the parsing of such things appears to be a conforming extension, but it breaks libstdc++4.7's std::pair. llvm-svn: 155975
* PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes anotherRichard Smith2012-04-291-0/+13
| | | | | | | victim. Don't crash if we have a delay-parsed exception specification for a class member which is invalid in a way which precludes building a FunctionDecl. llvm-svn: 155788
* Don't try to delay parsing the exception specification for a data member of aRichard Smith2012-04-241-1/+9
| | | | | | class; we would never actually parse it and attach it to the type. llvm-svn: 155426
* PR12629: Cope with parenthesized function types when attaching a delayedRichard Smith2012-04-241-1/+10
| | | | | | exception specification to a function. llvm-svn: 155424
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-161-0/+27
| | | | | | | | | exception specifications on member functions until after the closing '}' for the containing class. This allows, for example, a member function to throw an instance of its own class. Fixes PR12564 and a fairly embarassing oversight in our C++98/03 support. llvm-svn: 154844
* Improve diagnostics for invalid use of non-static members / this:Richard Smith2012-04-051-2/+2
| | | | | | | | | | | | * s/nonstatic/non-static/ in the diagnostics, since the latter form outvoted the former by 28-2 in our diagnostics. * Fix the "use of member in static member function" diagnostic to correctly detect this situation inside a block or lambda. * Produce a more specific "invalid use of non-static member" diagnostic for the case where a nested class member refers to a member of a lexically-surrounding class. llvm-svn: 154073
* Don't assert when trying to diagnose why a class with a constructor template isRichard Smith2012-02-261-0/+4
| | | | | | non-trivial. llvm-svn: 151486
* Make sure we still reject static data members in anonymous unions in C++11.Richard Smith2012-02-161-0/+12
| | | | llvm-svn: 150724
* C++11 allows unions to have static data members. Remove the correspondingRichard Smith2012-02-162-1/+38
| | | | | | restriction and add some tests. llvm-svn: 150721
* Deal with a horrible C++11 special case. If a non-literal type has a constexprRichard Smith2012-02-131-3/+3
| | | | | | | | | | | constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. llvm-svn: 150419
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-131-4/+3
| | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
* PR11684, core issue 1417:Richard Smith2012-02-101-1/+1
| | | | | | | | | | | | | | o Correct the handling of the restrictions on usage of cv-qualified and ref-qualified function types. o Fix a bug where such types were rejected in template type parameter default arguments, due to such arguments not being treated as a template type arg context. o Remove the ExtWarn for usage of such types as template arguments; that was a standard defect, not a GCC extension. o Improve the wording and unify the code for diagnosing cv-qualifiers with the code for diagnosing ref-qualifiers. llvm-svn: 150244
* Remove the "unsupported" error for lambda expressions. It's annoying,Douglas Gregor2012-02-091-1/+1
| | | | | | and rapidly becoming untrue. llvm-svn: 150165
* Various interrelated cleanups for lambdas:Douglas Gregor2012-02-091-2/+2
| | | | | | | | | | | | | | - Complete the lambda class when we finish the lambda expression (previously, it was left in the "being completed" state) - Actually return the LambdaExpr object and bind to the resulting temporary when needed. - Detect when cleanups are needed while capturing a variable into a lambda (e.g., due to default arguments in the copy constructor), and make sure those cleanups apply for the whole of the lambda expression. llvm-svn: 150123
* Misc improvements to the diagnostic when a variable is odr-used in a context ↵Eli Friedman2012-02-073-2/+20
| | | | | | | | that is not allowed to capture variables. Fixes PR11883. llvm-svn: 149937
* Further testing for instantiation of out-of-line constexpr static data memberRichard Smith2012-01-191-0/+5
| | | | | | template definitions. llvm-svn: 148506
* An instantiation of a constexpr static data member in a class template isRichard Smith2012-01-191-0/+14
| | | | | | constexpr. llvm-svn: 148505
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-154-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
OpenPOWER on IntegriCloud