summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate
Commit message (Collapse)AuthorAgeFilesLines
* PR10828: Produce a warning when a no-arguments function is declared in blockRichard Smith2012-01-051-1/+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
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-293-4/+3
| | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. llvm-svn: 147357
* Pass context and access to Parser::ParseExplicitInstantiation() forArgyrios Kyrtzidis2011-12-231-0/+8
| | | | | | | | good parser error recovery and for not crashing. We still have a accepts-invalid-code bug. llvm-svn: 147216
* C++ constant expression handling: eagerly instantiate static const integral dataRichard Smith2011-12-211-1/+1
| | | | | | | | members of class templates so that their values can be used in ICEs. This required reverting r105465, to get such instantiated members to be included in serialized ASTs. llvm-svn: 147023
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-153-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement the Microsoft __if_exists/if_not_exists extension in initializer-list.Francois Pichet2011-12-121-0/+6
| | | | | | | | | | | | | | | Necessary to parse Microsoft ATL code. Example: int array[] = { 0, __if_exists(CLASS::Type) {2, } 3 }; will declare an array of 2 or 3 elements depending on if CLASS::Type exists or not. llvm-svn: 146447
* Add notes for suppressing and (if it's a zero-arg function returning bool) ↵David Blaikie2011-12-091-2/+2
| | | | | | fixing the function-to-bool conversion warning. llvm-svn: 146280
* Add a warning for implicit conversion from function literals (and staticLang Hames2011-12-051-2/+2
| | | | | | | | | | | | | methods) to bool. E.g. void foo() {} if (f) { ... // <- Warns here. } Only applies to non-weak functions, and does not apply if the function address is taken explicitly with the addr-of operator. llvm-svn: 145849
* In Microsoft mode, don't perform typo correction in a template member ↵Francois Pichet2011-12-031-0/+20
| | | | | | | | | | function dependent context because it interferes with the "lookup into dependent bases of class templates" feature. Basically typo correction will try to offer a correction instead of looking into type dependent base classes. I found this problem while parsing Microsoft ATL code with clang. llvm-svn: 145772
* In Microsoft mode, make "Unqualified lookup into dependent bases of class ↵Francois Pichet2011-11-251-1/+26
| | | | | | | | | | templates" works inside a friend function definition at class scope. Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext. This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang. llvm-svn: 145127
* Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the sameRichard Smith2011-11-211-1/+3
| | | | | | | | | | | | | semantics and defaults as the corresponding g++ arguments. The historical g++ argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions no longer document that option. Add -cc1 argument -fconstexpr-depth N to implement the corresponding functionality. The -ftemplate-depth=N part of this fixes PR9890. llvm-svn: 145045
* In Microsoft mode, make "Unqualified lookup into dependent bases of class ↵Francois Pichet2011-11-171-1/+28
| | | | | | | | | | templates" works inside default argument instantiation. This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated. This fixes 2 errors when parsing MFC code with clang. llvm-svn: 144881
* In Microsoft mode, make "Unqualified lookup into dependent bases of class ↵Francois Pichet2011-11-151-0/+23
| | | | | | templates" works inside static functions. llvm-svn: 144729
* When we're checking access in a dependent context, don't try to lookDouglas Gregor2011-11-141-0/+15
| | | | | | at the bases of an undefined class. Fixes <rdar://problem/10438657>. llvm-svn: 144582
* Move "Unqualified lookup into dependent bases of class templates" Microsoft ↵Francois Pichet2011-11-111-1/+20
| | | | | | specific behavior from -fms-extensions to -fms-compatibility. llvm-svn: 144341
* Mark the overloaded atomic builtins as having custom type checking,Douglas Gregor2011-11-081-0/+8
| | | | | | | | | which they do. This avoids all of the default argument promotions that we (1) don't want, and (2) undo during that custom type checking, and makes sure that we don't run into trouble during template instantiation. Fixes PR11320. llvm-svn: 144110
* Drastically simplify the mapping from the declaration corresponding toDouglas Gregor2011-11-071-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | the injected-class-name of a class (or class template) to the declaration that results from substituting the given template arguments. Previously, we would actually perform a substitution into the injected-class-name type and then retrieve the resulting declaration. However, in certain, rare circumstances involving deeply-nested member templates, we would get the wrong substitution arguments. This new approach just matches up the declaration with a declaration that's part of the current context (or one of its parents), which will either be an instantiation (during template instantiation) or the declaration itself (during the definition of the template). This is both more efficient (we're avoiding a substitution) and more correct (we can't get the template arguments wrong in the member-template case). Fixes <rdar://problem/9676205>. Reinstated, now that we have the fix in r143967. llvm-svn: 143968
* Tighten up the conditions under which we consider ourselves to beDouglas Gregor2011-11-071-0/+22
| | | | | | | entering the context of a nested-name-specifier. Fixes <rdar://problem/10397846>. llvm-svn: 143967
* Revert r143551. It is causing g++.dg/template/crash52.C test failure.Devang Patel2011-11-041-20/+0
| | | | llvm-svn: 143725
* Drastically simplify the mapping from the declaration corresponding toDouglas Gregor2011-11-021-0/+20
| | | | | | | | | | | | | | | | | | | | | | the injected-class-name of a class (or class template) to the declaration that results from substituting the given template arguments. Previously, we would actually perform a substitution into the injected-class-name type and then retrieve the resulting declaration. However, in certain, rare circumstances involving deeply-nested member templates, we would get the wrong substitution arguments. This new approach just matches up the declaration with a declaration that's part of the current context (or one of its parents), which will either be an instantiation (during template instantiation) or the declaration itself (during the definition of the template). This is both more efficient (we're avoiding a substitution) and more correct (we can't get the template arguments wrong in the member-template case). Fixes <rdar://problem/9676205>. llvm-svn: 143551
* When we see an out-of-line definition of a member class template thatDouglas Gregor2011-11-011-0/+13
| | | | | | | does not match any declaration in the class (or class template), be sure to mark it as invalid. Fixes PR10924 / <rdar://problem/10119422>. llvm-svn: 143504
* Rework the AST for the initializer of a delegating constructor, soDouglas Gregor2011-11-011-0/+13
| | | | | | | | | that it retains source location information for the type. Aside from general goodness (being able to walk the types described in that information), we now have a proper representation for dependent delegating constructors. Fixes PR10457 (for real). llvm-svn: 143410
* Fix crash due to missing array-to-pointer decay when instantiating an unresolvedRichard Smith2011-10-261-0/+10
| | | | | | member expression. Refactoring to follow. llvm-svn: 143017
* Check for unexpanded parameter packs in the name that guards aDouglas Gregor2011-10-251-1/+10
| | | | | | | | | Microsoft __if_exists/__if_not_exists statement. Also note that we weren't traversing DeclarationNameInfo *at all* within the RecursiveASTVisitor, which would be rather fatal for variadic templates. llvm-svn: 142906
* Implement support for dependent Microsoft __if_exists/__if_not_existsDouglas Gregor2011-10-251-2/+2
| | | | | | | | | | statements. As noted in the documentation for the AST node, the semantics of __if_exists/__if_not_exists are somewhat different from the way Visual C++ implements them, because our parsed-template representation can't accommodate VC++ semantics without serious contortions. Hopefully this implementation is "good enough". llvm-svn: 142901
* Rework Microsoft __if_exists/__if_not_exists parsing and semanticDouglas Gregor2011-10-241-0/+53
| | | | | | | | | | | | | | | | | analysis to separate dependent names from non-dependent names. For dependent names, we'll behave differently from Visual C++: - For __if_exists/__if_not_exists at class scope, we'll just warn and then ignore them. - For __if_exists/__if_not_exists in statements, we'll treat the inner statement as a compound statement, which we only instantiate in templates where the dependent name (after instantiation) exists. This behavior is different from VC++, but it's as close as we can get without encroaching ridiculousness. The latter part (dependent statements) is not yet implemented. llvm-svn: 142864
* When performing name lookup for the previous declaration of a field,Douglas Gregor2011-10-212-0/+11
| | | | | | | | be sure to consider all of the possible lookup results. We were assert()'ing (but behaving correctly) for unresolved values. Fixes PR11134 / <rdar://problem/10290422>. llvm-svn: 142652
* Diagnose class template (partial) specializations that occur in theDouglas Gregor2011-10-201-0/+10
| | | | | | | *wrong* class scope. This is one of the problems behind <rdar://problem/9676205>. llvm-svn: 142588
* When we parse something that looks like a templated friend tag butDouglas Gregor2011-10-201-0/+6
| | | | | | | | actually just has an extraneous 'template<>' header, strip off the 'template<>' header and treat it as a normal friend tag. Fixes PR10660 / <rdar://problem/9958322>. llvm-svn: 142587
* Switch to the C++11 warning flags in tests. David Blaikie2011-10-181-1/+1
| | | | | | Patch by Ahmed Charles! llvm-svn: 142340
* When transforming the arguments for a C++ "new" expression, make sureDouglas Gregor2011-10-181-1/+8
| | | | | | | to drop the implicitly-generated value initialization expression used for initializing scalars. Fixes <rdar://problem/10283928>. llvm-svn: 142330
* Refactor the checking for explicit template instantiations being performed inRichard Smith2011-10-182-4/+4
| | | | | | | | | the right namespace in C++11 mode. Teach the code to prefer the 'must be in precisely this namespace' diagnostic whenever that's true, and fix a defect which resulted in the -Wc++11-compat warning in C++98 mode sometimes being omitted. llvm-svn: 142329
* When declaring an out-of-line template, attempt to rebuild any typesDouglas Gregor2011-10-141-0/+20
| | | | | | | within the template parameter list that may have changed now that we know the current instantiation. Fixes <rdar://problem/10194295>. llvm-svn: 141954
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-1314-14/+14
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* When we determine that a function template specialization produced asDouglas Gregor2011-10-122-5/+7
| | | | | | | | | | | | | | | part of template argument deduction is ill-formed, we mark it as invalid and treat it as a deduction failure. If we happen to find that specialization again, treat it as a deduction failure rather than silently building a call to the declaration. Fixes PR11117, a marvelous bug where deduction failed after creating an invalid specialization, causing overload resolution to pick a different candidate. Then we performed a similar overload resolution later, and happily picked the invalid specialization to call... resulting in a silent link failure. llvm-svn: 141809
* Switch diagnostic text from "C++0x" over to "C++11".Douglas Gregor2011-10-123-3/+3
| | | | | | | | We'd also like for "C++11" or "c++11" to be used for the warning groups, but without removing the old warning flags. Patches welcome; I've run out of time to work on this today. llvm-svn: 141801
* Catch placeholder types in DefaultLvalueConversionJohn McCall2011-10-111-13/+13
| | | | | | | | | | | and DefaultFunctionArrayLvalueConversion. To prevent significant regression for should-this-be-a-call fixits, and to repair some such regression from the introduction of bound member placeholders, make those placeholder checks try to build calls appropriately. Harden the build-a-call logic while we're at it. llvm-svn: 141738
* For the various CF and NS attributes, don't complain if the parameterDouglas Gregor2011-10-091-0/+13
| | | | | | or return types are dependent. Fixes PR9049. llvm-svn: 141518
* Mark the ExtWarn for in-class initialization of static const float members ↵Richard Smith2011-09-291-1/+1
| | | | | | as a GNU extension. Don't extend the scope of this extension to all literal types in C++0x mode. llvm-svn: 140820
* constexpr: semantic checking for constexpr variables.Richard Smith2011-09-291-1/+1
| | | | | | We had an extension which allowed const static class members of floating-point type to have in-class initializers, 'as a C++0x extension'. However, C++0x does not allow this. The extension has been kept, and extended to all literal types in C++0x mode (with a fixit to add the 'constexpr' specifier). llvm-svn: 140801
* Diagnose attempts to use 'using typename' with a non-identifier name,Douglas Gregor2011-09-261-0/+13
| | | | | | from Stepan Dyatkovskiy. Fixes PR10925. llvm-svn: 140528
* Don't finalize checking of base and member initializers for aDouglas Gregor2011-09-221-0/+18
| | | | | | constructor template. Fixes PR10457. llvm-svn: 140350
* Diagnose attempts to write a templated data member, from StepanDouglas Gregor2011-09-211-0/+16
| | | | | | Dyatkovskiy! Fixes PR10896. llvm-svn: 140250
* PR10864: make sure we correctly delay type-checking for inline asm tied ↵Eli Friedman2011-09-141-0/+13
| | | | | | operands with dependent type. Patch by Likai Liu. llvm-svn: 139716
* When type-checking a call to an overloaded, builtin atomic operation,Douglas Gregor2011-09-091-0/+8
| | | | | | | construct a new DeclRefExpr rather than re-using the existing DeclRefExpr. Patch by Likai Liu, fixes PR8345. llvm-svn: 139373
* In Microsoft mode, if we are inside a template class member function and we ↵Francois Pichet2011-09-071-0/+31
| | | | | | | | can't resolve a function call then create a type-dependent CallExpr even if the function has no type dependent arguments. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes. With this patch in, clang will generate only 37 errors (down from 212) when parsing a typical MFC source file. llvm-svn: 139210
* Don't assert on taking the address of a non-type template parameter. Fixes ↵Eli Friedman2011-08-261-0/+3
| | | | | | PR10766. llvm-svn: 138648
* Fix a crash-on-invalid.Matt Beaumont-Gay2011-08-251-0/+7
| | | | | | | | Much to everyone's surprise, the default constructor for TypeResult produces an instance with Invalid == false. This seems like a decision we may want to revisit. llvm-svn: 138601
* Whitelist operator== and operator!= as valid for unused value warnings,Chandler Carruth2011-08-171-1/+1
| | | | | | | | even when overloaded and user-defined. These operators are both more valuable to warn on (due to likely typos) and extremely unlikely to be reasonable for use to trigger side-effects. llvm-svn: 137823
* Treating the unused equality comparisons as something other than part ofChandler Carruth2011-08-171-4/+6
| | | | | | | | | | | | | | | | | | | | | -Wunused was a mistake. It resulted in duplicate warnings and lots of other hacks. Instead, this should be a special sub-category to -Wunused-value, much like -Wunused-result is. Moved to -Wunused-comparison, moved the implementation to piggy back on the -Wunused-value implementation instead of rolling its own, different mechanism for catching all of the "interesting" statements. I like the unused-value mechanism for this better, but its currently missing several top-level statements. For now, I've FIXME-ed out those test cases. I'll enhance the generic infrastructure to catch these statements in a subsequent patch. This patch also removes the cast-to-void fixit hint. This hint isn't available on any of the other -Wunused-value diagnostics, and if we want it to be, we should add it generically rather than in one specific case. llvm-svn: 137822
OpenPOWER on IntegriCloud