summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate
Commit message (Collapse)AuthorAgeFilesLines
* A couple minor bug-fixes for template instantiation for expressions which ↵Eli Friedman2012-02-292-0/+20
| | | | | | are sometimes potentially evaluated. llvm-svn: 151707
* Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, ↵Eli Friedman2012-02-161-1/+1
| | | | | | so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>. llvm-svn: 150663
* If a static data member of a class template which could be used in a constantRichard Smith2012-02-151-0/+8
| | | | | | | | expression is referenced, defined, then referenced again, make sure we instantiate it the second time it's referenced. This is the static data member analogue of r150518. llvm-svn: 150560
* If a constexpr function template specialization is referenced, and then theRichard Smith2012-02-141-0/+59
| | | | | | | | template is defined, and then the specialization is referenced again, don't forget to instantiate the template on the second reference. Use the source location of the first reference as the point of instantiation, though. llvm-svn: 150518
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Track whether a function type has a trailing return type as type sugar. Use thisRichard Smith2012-02-101-0/+15
| | | | | | | | | | | to pretty-print such function types better, and to fix a case where we were not instantiating templates in lexical order. In passing, move the Variadic bit from Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits. Also ensure that we always substitute the return type of a function when substituting explicitly-specified arguments, since that can cause us to bail out with a SFINAE error before we hit a hard error in parameter substitution. llvm-svn: 150241
* --lies.Richard Smith2012-02-101-2/+0
| | | | llvm-svn: 150240
* Make sure we convert struct layout pragmas to attributes for class templates ↵Eli Friedman2012-02-101-0/+10
| | | | | | the same way we do for non-template classes. <rdar://problem/10791194>. llvm-svn: 150221
* Fixed instantiation of DependentScopeDeclRefExpr.Abramo Bagnara2012-02-062-0/+23
| | | | llvm-svn: 149868
* Added tests for template keyword presence.Abramo Bagnara2012-01-281-0/+119
| | | | llvm-svn: 149177
* When we're substituting into a function parameter pack and expect toDouglas Gregor2012-01-251-3/+2
| | | | | | | get a function parameter pack (but don't due to weird substitutions), complain. Fixes the last bit of PR11848. llvm-svn: 148960
* Fix PR11848: decree that an alias template contains an unexpanded parameter packRichard Smith2012-01-251-0/+33
| | | | | | | | | | | | | iff its substitution contains an unexpanded parameter pack. This has the effect that we now reject declarations such as this (which we used to crash when expanding): template<typename T> using Int = int; template<typename ...Ts> void f(Int<Ts> ...ints); The standard is inconsistent on how this case should be treated. llvm-svn: 148905
* Promote the extension warning for attempts to catch a reference orDouglas Gregor2012-01-241-1/+1
| | | | | | | | | | pointer to incomplete type from an ExtWarn to an error. We put the ExtWarn in place as part of a workaround for Boost (PR6527), but it (1) doesn't actually match a GCC extension and (2) has been fixed for two years in Boost, and (3) causes us to emit code that fails badly at run time, so it's a bad idea to keep it. Fixes PR11803. llvm-svn: 148838
* Pedantic diagnostic correction: in C++, we have integral constant expressions,Richard Smith2012-01-151-1/+1
| | | | | | | | not integer constant expressions. In passing, fix the 'folding is an extension' diagnostic to not claim we're accepting the code, since that's not true in -pedantic-errors mode, and add this diagnostic to -Wgnu. llvm-svn: 148209
* 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
OpenPOWER on IntegriCloud