summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/basic
Commit message (Collapse)AuthorAgeFilesLines
...
* PR17731: When determining whether a tag and a non-tag were declared in the sameRichard Smith2013-10-301-0/+45
| | | | | | | scope, be careful about function-scope declarations (which are not declared in their semantic context). llvm-svn: 193671
* 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
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-0/+73
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:Richard Smith2013-08-131-26/+27
| | | | | | | | | | | | | When a local extern declaration redeclares some other entity, the type of that entity is merged with the prior type if the prior declaration is visible (in C) or is declared in the same scope (in C++). - Make LookupRedeclarationWithLinkage actually work in C++, use it in the right set of cases, and make it track whether it found a shadowed declaration. - Track whether we found a declaration in the same scope (for C++) including across serialization and template instantiation. llvm-svn: 188307
* Sema: Do not merge new decls with invalid, old declsDavid Majnemer2013-07-071-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sema::MergeFunctionDecl attempts merging two decls even if the old decl is invalid. This can lead to interesting circumstances where we successfully merge the decls but the result makes no sense. Take the following for example: template <typename T> int main(void); int main(void); Sema will not consider these to be overloads of the same name because main can't be overloaded, which means that this must be a redeclaration. In this case the templated decl is compatible with the non-templated decl allowing the Sema::CheckFunctionDeclaration machinery to move on and do bizarre things like setting the previous decl of a non-templated decl to a templated decl! The way I see it, we should just bail from MergeFunctionDecl if the old decl is invalid. This fixes PR16531. llvm-svn: 185779
* Sema: Fix a crash when main is redeclared as a function-template.David Majnemer2013-07-061-0/+9
| | | | | | | | | | This boils down to us sending invalid function decls to CheckFunctionDeclaration becauswe we did not consider that CheckMain could cause the decl to be invalid. Instead, interogate the new decl's main-validity and *then* send it over to get CheckFunctionDeclaration'd if it was still valid after calling CheckMain. llvm-svn: 185745
* C++1y constexpr extensions, round 1: Allow most forms of declaration andRichard Smith2013-04-221-2/+12
| | | | | | | | statement in constexpr functions. Everything which doesn't require variable mutation is also allowed as an extension in C++11. 'void' becomes a literal type to support constexpr functions which return 'void'. llvm-svn: 180022
* The 'constexpr implies const' rule for non-static member functions is gone inRichard Smith2013-04-211-5/+5
| | | | | | | | | 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. llvm-svn: 179969
* Skip transparent contexts when looking for using directives in name lookup.Douglas Gregor2013-04-091-4/+8
| | | | | | Fixes the bootstrap regression I introduced in r179067. llvm-svn: 179079
* <rdar://problem/13540899> Collect using directives from all of the semantic ↵Douglas Gregor2013-04-081-0/+19
| | | | | | | | | | | | contexts not represented by scopes. This fixes a regression I introduced in r178136, where we would not consider the using directives from the semantic declaration contexts that aren't represented by the lexical scopes (Scope) when performing unqualified name lookup. This lead to horribly funny diagnostics like "no identifier named 'foo'; did you mean 'foo'?". llvm-svn: 179067
* Only merge down a variable type if the previous declaration wasJohn McCall2013-04-011-0/+43
| | | | | | | | | visible. There's a lot of potential badness in how we're modelling these things, but getting this much correct is reasonably easy. rdar://13535367 llvm-svn: 178488
* <rdar://problem/13317030> Consider using directives when performing ↵Douglas Gregor2013-03-271-0/+30
| | | | | | unqualified name lookup into declarations contexts represented by the qualified-id but not in the actual scope hierarchy. llvm-svn: 178136
* Remove FIXMEs: these are covered by a core issue which we don't yet implementRichard Smith2013-03-261-2/+0
| | | | | | (but we happen to get this part right). llvm-svn: 177958
* Implement special-case name lookup for inheriting constructors: memberRichard Smith2013-03-261-1/+93
| | | | | | | using-declarations with names which look constructor-like are interpreted as constructor names. llvm-svn: 177957
* Add quotation marks to template names in diagnostics.David Blaikie2013-03-051-1/+1
| | | | llvm-svn: 176474
* PR15100: look through type sugar when determining whether we have one of theRichard Smith2013-01-291-0/+23
| | | | | | forms of 'main' which we accept as an extension. llvm-svn: 173758
* Fold tests for C++ 'main' into a single file.Richard Smith2013-01-2910-54/+78
| | | | llvm-svn: 173756
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-081-1/+1
| | | | | | | | | | | | | | 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
* Fix more try scoping bugs introduced by r167650.David Blaikie2012-11-121-0/+23
| | | | | | | Introduces more clear scoping flags & flag combinations which should hopefully be more understandable. llvm-svn: 167766
* Handle redeclarations of catch variables in catch blocks.David Blaikie2012-11-101-0/+12
| | | | | | Fix to regression caused by r167650, caught by Richard Smith in code review. llvm-svn: 167653
* PR14296: function parameter name collisions in function try/catchDavid Blaikie2012-11-101-0/+25
| | | | | | | | | | | | C++11 3.3.3/2 "A parameter name shall not be redeclared in the outermost block of the function definition nor in the outermost block of any handler associated with a function-try-block." It's not totally clear to me whether the "FIXME" case is covered by this, but Richard Smith thinks it probably should be. It's just a bit more involved to fix that case. llvm-svn: 167650
* Prior to adding the new "expected-no-diagnostics" directive to ↵Andy Gibbs2012-10-1917-0/+17
| | | | | | VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive. llvm-svn: 166280
* Instantiate class template specializations during ADL.John McCall2012-08-241-0/+24
| | | | llvm-svn: 162586
* We don't need a lengthy quote from the wrong standard.Douglas Gregor2012-05-011-20/+0
| | | | llvm-svn: 155942
* Add test cases for r155935.Douglas Gregor2012-05-012-0/+110
| | | | llvm-svn: 155940
* If a type is non-literal by virtue of being incomplete produce notesRichard Smith2012-04-251-3/+3
| | | | | | explaining that. llvm-svn: 155598
* When determining whether an identifier followed by a '<' in a memberDouglas Gregor2012-03-101-0/+25
| | | | | | | | access expression is the start of a template-id, ignore function templates found in the context of the entire postfix-expression. Fixes PR11856. llvm-svn: 152520
* Make RequireLiteralType work correctly with incomplete array types. PR12037.Eli Friedman2012-02-201-0/+17
| | | | llvm-svn: 151005
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-131-21/+27
| | | | | | | | | | | | | | | | | | | | 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
* CWG issue 1405: mutable members are allowed in literal types, but can't undergoRichard Smith2012-02-091-18/+0
| | | | | | lvalue-to-rvalue conversions in constant expressions. llvm-svn: 150145
* Disallow constexpr main.Richard Smith2012-02-041-0/+6
| | | | llvm-svn: 149770
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-181-2/+2
| | | | | | | | | | values and non-type template arguments of integral and enumeration types. This change causes some legal C++98 code to no longer compile in C++11 mode, by enforcing the C++11 rule that narrowing integral conversions are not permitted in the final implicit conversion sequence for the above cases. llvm-svn: 148439
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* David Blaikie and Chandler would like us to diagnoseRichard Smith2012-01-061-1/+1
| | | | | | | | int f(); in function scopes under -Wvexing-parse, so now we do. llvm-svn: 147649
* Tweak to r147599 for PR10828: Move the check from the parser into sema, and useRichard Smith2012-01-061-1/+1
| | | | | | | the Semantic Powers to only warn on class types (or dependent types), where the constructor or destructor could do something interesting. llvm-svn: 147642
* PR10828: Produce a warning when a no-arguments function is declared in blockRichard Smith2012-01-051-2/+1
| | | | | | | | | | | | | | | | | scope, when no other indication is provided that the user intended to declare a function rather than a variable. Remove some false positives from the existing 'parentheses disambiguated as a function' warning by suppressing it when the declaration is marked as 'typedef' or 'extern'. Add a new warning group -Wvexing-parse containing both of these warnings. The new warning is enabled by default; despite a number of false positives (and one bug) in clang's test-suite, I have only found genuine bugs with it when running it over a significant quantity of real C++ code. llvm-svn: 147599
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-5/+4
| | | | | | | | | | | | | | | | | | | | | variable is initialized by a non-constant expression, and pass in the variable being declared so that earlier-initialized fields' values can be used. Rearrange VarDecl init evaluation to make this possible, and in so doing fix a long-standing issue in our C++ constant expression handling, where we would mishandle cases like: extern const int a; const int n = a; const int a = 5; int arr[n]; Here, n is not initialized by a constant expression, so can't be used in an ICE, even though the initialization expression would be an ICE if it appeared later in the TU. This requires computing whether the initializer is an ICE eagerly, and saving that information in PCH files. llvm-svn: 146856
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-154-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* When we notice that a member function is defined with "= delete" or "=Douglas Gregor2011-11-071-0/+1
| | | | | | | | | | | | default", make a note of which is used when creating the initial declaration. Previously, we would wait until later to handle default/delete as a definition, but this is too late: when adding the declaration, we already treated the declaration as "user-provided" when in fact it was merely "user-declared". Fixes PR10861 and PR10442, along with a bunch of FIXMEs. llvm-svn: 144011
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-134-4/+4
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* constexpr: don't consider class types with mutable members to be literal types.Richard Smith2011-10-121-0/+19
| | | | | | | The standard doesn't allow this, but mutable constexpr variables break the semantics so badly that we can't reasonably accept them. llvm-svn: 141768
* constexpr: semantic checking for constexpr functions and constructors. Based inRichard Smith2011-10-011-0/+108
| | | | | | | | | | | | | part on patches by Peter Collingbourne. We diverge from the C++11 standard in a few areas, mostly related to checking constexpr function declarations, and not just definitions. See WG21 paper N3308=11-0078 for details. Function invocation substitution is not available in this patch; constexpr functions cannot yet be used from within constant expressions. llvm-svn: 140926
* De-Unicode-ify.NAKAMURA Takumi2011-08-121-1/+1
| | | | llvm-svn: 137430
* When performing the lookup in the current scope for a member access toDouglas Gregor2011-08-101-0/+18
| | | | | | | | | | | | a member template, e.g., x.f<int> if we have found a template in the type of x, but the lookup in the current scope is ambiguous, just ignore the lookup in the current scope. Fixes <rdar://problem/9915664>. llvm-svn: 137255
* Update this test to reflect the new (deterministic) order in r134038.Chandler Carruth2011-06-281-2/+2
| | | | | | | This was part of Kaelyn's original patch that got dropped while I was working on it, but after I ran my tests. =/ Sorry. llvm-svn: 134039
* Modify test case to allow buildbots to make forward progress. This test shouldChad Rosier2011-06-281-2/+2
| | | | | | | now (incorrectly) pass. Once the appropriate fixes have been made this test should be reverted. llvm-svn: 134035
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-3/+10
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* Teach Sema::ActOnUninitializedDecl() not to try to interpret when oneDouglas Gregor2011-05-211-0/+3
| | | | | | | | should use a constructor to default-initialize a variable. InitializationSequence knows the rules for default initialization, better. Fixes <rdar://problem/8501008>. llvm-svn: 131796
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-0/+26
| | | | llvm-svn: 129567
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+68
| | | | | | draft standard (N3291). llvm-svn: 129541
OpenPOWER on IntegriCloud