summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate
Commit message (Collapse)AuthorAgeFilesLines
...
* Lit C++11 Compatibility Patch #8Charles Li2016-04-143-10/+44
| | | | | | 24 tests have been updated for C++11 compatibility. llvm-svn: 266387
* Lit C++11 Compatibility Patch #7Charles Li2016-04-134-14/+72
| | | | | | | 13 tests have been updated for C++11 compatibility. Differential Revision: http://reviews.llvm.org/D19068 llvm-svn: 266239
* Fix a crash on invalid with template handlingRichard Trieu2016-04-051-0/+6
| | | | | | | | This is a fix for https://llvm.org/bugs/show_bug.cgi?id=25561 which was a crash on invalid. Change the handling of invalid decls to have a catch-all case to prevent unexpecting decls from triggering an assertion. llvm-svn: 265467
* Add missing triple to instantiate-sizeof.cpp testReid Kleckner2016-03-111-1/+1
| | | | llvm-svn: 263285
* Allow sizeof(UnrelatedClass::field) in C++11 class template methodsReid Kleckner2016-03-111-1/+26
| | | | | | | | | | | | | | | | | This feature works outside of templates by forming a DeclRefExpr to a FieldDecl instead of a MemberExpr, which requires a base object in addition to the FieldDecl. Previously, while building up the template AST before instantiation, we formed a CXXDependentScopeMemberExpr, which always instantiates to a MemberExpr. Now, in unevaluated contexts we form a DependentScopeDeclRefExpr, which is a more flexible node that can instantiate to either a MemberExpr or a DeclRefExpr depending on lookup results. Fixes PR26893. llvm-svn: 263279
* Implement P0036R0: remove support for empty unary folds of +, *, |, &.Richard Smith2016-03-041-7/+8
| | | | llvm-svn: 262747
* Fix assertion failure on MaybeODRUseExprs.Manman Ren2016-02-241-0/+10
| | | | | | | | | | | | | | | | | | In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument, we should create a ConstantEvaluated ExpressionEvaluationContext. Without this, it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and MaybeODRUseExprs will not be cleared when popping the context, causing assertion failure. This is similar to how we handle the context before SubstExpr with the default argument, in SubstDefaultTemplateArgument. Part of PR13986. rdar://24480205 Differential Revision: http://reviews.llvm.org/D17576 llvm-svn: 261803
* Fix PR26134: When substituting into default template arguments, keep ↵Faisal Vali2016-01-191-0/+28
| | | | | | | | | | | | | | | CurContext unchanged. Or, do not set Sema's CurContext to the template declaration's when substituting into default template arguments of said template declaration. If we do push the template declaration context on to Sema, and the template declaration is at namespace scope, Sema can get confused and try and do odr analysis when substituting into default template arguments, even though the substitution could be occurring within a dependent context. I'm not sure why this was being done, perhaps there was concern that if a default template argument referred to a previous template parameter, it might not be found during substitution - but all regression tests pass, and I can't craft a test that would cause it to fails (if some one does, please inform me, and i'll craft a different fix for the PR). This patch removes a single line of code, but unfortunately adds more than it removes, because of the tests. Some day I still hope to commit a patch that removes far more lines than it adds, while leaving clang better for it ;) Sorry that r253590 ("Change the expression evaluation context from Unevaluated to ConstantEvaluated while substituting into non-type template argument defaults") caused the PR! llvm-svn: 258110
* Fix assert hit when tree-transforming template template parameter packs.Manuel Klimek2016-01-111-1/+11
| | | | | | | | | Covers significantly more code in the template template pack argument test and fixes the resulting assert problem. Differential Revision: http://reviews.llvm.org/D15743 llvm-svn: 257326
* Only instantiate a default argument once.John McCall2016-01-061-0/+19
| | | | | | | | | | | | | | | | | | | By storing the instantiated expression back in the ParmVarDecl, we remove the last need for separately storing the sub-expression of a CXXDefaultArgExpr. This makes PCH/Modules merging quite simple: CXXDefaultArgExpr records are serialized as references to the ParmVarDecl, and we ignore redundant attempts to overwrite the instantiated expression. This has some extremely marginal impact on user-facing semantics. However, the major effect is that it avoids IRGen errors about conflicting definitions due to lambdas in the argument being instantiated multiple times while sharing the same mangling. It should also slightly improve memory usage and module file size. rdar://23810407 llvm-svn: 256983
* Implement [temp.deduct.type]p6: if the nested-name-specifier of a type isRichard Smith2015-12-301-0/+11
| | | | | | dependent, the type is a non-deduced context. llvm-svn: 256651
* Test for diagnostic quality improvement in r256049.Richard Smith2015-12-191-0/+7
| | | | llvm-svn: 256083
* [modules] Don't try to use the definition of a class ifRichard Smith2015-12-181-1/+1
| | | | | | | RequireCompleteType(..., 0) says we're not permitted to do so. The definition might not be visible, even though we know what it is. llvm-svn: 256045
* Correctly type-check the default arguments of local functionsJohn McCall2015-12-111-0/+27
| | | | | | | | when eagerly instantiating them. rdar://23721638 llvm-svn: 255325
* [Lit Test] Updated 20 Lit tests to be C++11 compatible.Charles Li2015-12-106-15/+77
| | | | | | | | 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
* [Lit Test] Updated 34 Lit tests to be C++11 compatible.Charles Li2015-11-175-4/+35
| | | | | | | Added expected diagnostics new to C++11. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 253371
* [Lit Test] Updated 26 Lit tests to be C++11 compatible.Charles Li2015-11-114-16/+56
| | | | | | | Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11. llvm-svn: 252785
* Re-land r250592 without rejecting field refs in unevaluated contextsReid Kleckner2015-10-201-1/+64
| | | | | | | | | | | This time, I went with the first approach from http://reviews.llvm.org/D6700, where clang actually attempts to form an implicit member reference from an UnresolvedLookupExpr. We know that there are only two possible outcomes at this point, a DeclRefExpr of the FieldDecl or an error, but its safer to reuse the existing machinery for this. llvm-svn: 250856
* [MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enumDavid Majnemer2015-10-081-2/+2
| | | | | | | | | | | | | | | | | | consider the following: enum E *p; enum E { e }; The above snippet is not ANSI C because 'enum E' has not bee defined when we are processing the declaration of 'p'; however, it is a popular extension to make the above work. This would fail using the Microsoft enum semantics because the definition of 'E' would implicitly have a fixed underlying type of 'int' which would trigger diagnostic messages about a mismatch between the declaration and the definition. Instead, treat fixed underlying types as not fixed for the purposes of the diagnostic. llvm-svn: 249674
* Update a few more tests in response to the MS ABI enum semanticsDavid Majnemer2015-10-081-2/+2
| | | | | | | Our self hosting buildbots found a few more tests which weren't updated to reflect that the enum semantics are part of the Microsoft ABI. llvm-svn: 249670
* Revert r107690 (for PR7417) and add a testcase that it breaks. The approach ofRichard Smith2015-10-052-5/+17
| | | | | | | | | that change turns out to not be reasonable: mutating the AST of a parsed template during instantiation is not a sound thing to do, does not work across chained PCH / modules builds, and is in any case a special-case workaround to a more general problem that should be solved centrally. llvm-svn: 249342
* PR24921: checking explicitly-specified template arguments when matching aRichard Smith2015-10-021-0/+7
| | | | | | | partial specialization can perform conversions on the argument. Be sure we start again from the original argument when checking each possible template. llvm-svn: 249114
* [Sema] Avoid crashing during this-> insertion recoveryReid Kleckner2015-09-301-0/+22
| | | | | | | | | We get into this bad state when someone defines a new member function for a class but forgets to add the declaration to the class body. Calling the new member function from a member function template of the class will crash during instantiation. llvm-svn: 248925
* PR14858: Initial support for proper sizeof... handling within alias templates.Richard Smith2015-09-231-0/+20
| | | | | | | This doesn't quite get alias template equivalence right yet, but handles the egregious cases where we would silently give the wrong answers. llvm-svn: 248431
* Support __builtin_ms_va_list.Charles Davis2015-09-171-3/+32
| | | | | | | | | | | | | | | | | | Summary: This change adds support for `__builtin_ms_va_list`, a GCC extension for variadic `ms_abi` functions. The existing `__builtin_va_list` support is inadequate for this because `va_list` is defined differently in the Win64 ABI vs. the System V/AMD64 ABI. Depends on D1622. Reviewers: rsmith, rnk, rjmccall CC: cfe-commits Differential Revision: http://reviews.llvm.org/D1623 llvm-svn: 247941
* Fix assertion failure in TransformOpaqueValueExprHubert Tong2015-09-011-0/+6
| | | | | | | | | | | | | | | | | | | | Summary: `OpaqueValueExpr`s may not have a source expression (as in the case when they are created due to a default argument error). This can cause an assertion failure in `TransformOpaqueValueExpr` during template instantiation. This patch fixes the assertion failure. Reviewers: hfinkel, rsmith Subscribers: fraggamuffin, cfe-commits Differential Revision: http://reviews.llvm.org/D11582 Patch by Rachel Craik! llvm-svn: 246600
* Instantiate function declarations in instantiated functions.Serge Pavlov2015-08-232-0/+15
| | | | | | | | | | | | | | | | | If a function declaration is found inside a template function as in: template<class T> void f() { void g(int x = T::v) except(T::w); } it must be instantiated along with the enclosing template function, including default arguments and exception specification. Together with the patch committed in r240974 this implements DR1484. Differential Revision: http://reviews.llvm.org/D11194 llvm-svn: 245810
* PR24483: Delete some dead/incorrect code that triggered assertions.Richard Smith2015-08-201-0/+6
| | | | llvm-svn: 245609
* [Sema] Be consistent about diagnostic wording: always use "cannot".Davide Italiano2015-08-152-3/+3
| | | | | | Discussed with Richard Smith. llvm-svn: 245162
* [SemaTemplate] Detect instantiation of unparsed exceptions.Davide Italiano2015-07-251-0/+17
| | | | | | | | This fixes the clang crash reported in PR24000. Differential Revision: http://reviews.llvm.org/D11341 llvm-svn: 243196
* PR10405 - Desugar FunctionType and TemplateSpecializationType if any type ↵Nikola Smiljanic2015-07-161-2/+2
| | | | | | that appears inside needs to be desugared. llvm-svn: 242371
* DR1909: Diagnose all invalid cases of a class member sharing its name with ↵Richard Smith2015-07-061-0/+6
| | | | | | the class. llvm-svn: 241425
* Instantiation of local class members.Serge Pavlov2015-06-291-0/+54
| | | | | | | | | | | | If a function containing a local class is instantiated, instantiate all of local class member, including default arguments and exception specifications. This change fixes PR21332 and thus implements DR1484. Differential Revision: http://reviews.llvm.org/D9990 llvm-svn: 240974
* Fix crash-on-invalid bug in template instantiation.Manuel Klimek2015-06-261-0/+9
| | | | | | | | Get rid of code-path that (according to Richard Smith) is not needed but leads to a crasher bug when assuming a template has been fully instantiated and thus has a definition. llvm-svn: 240752
* [ms] Don't try to delay lookup for failures in SFINAE context (PR23823)Hans Wennborg2015-06-121-0/+10
| | | | | | | | | | | | | The underlying problem in PR23823 already existed before my recent change in r239558, but that change made it worse (failing not only for undeclared symbols, but also failed overload resolution). This makes Clang not try to delay the lookup in SFINAE context. I assume no current code is relying on SFINAE working with lookups that need to be delayed, because that never seems to have worked. Differential Revision: http://reviews.llvm.org/D10417 llvm-svn: 239639
* [ms] Do lookup in dependent base classes also when overload resolution fails ↵Hans Wennborg2015-06-111-0/+16
| | | | | | | | | | | | | | | | | | | (PR23810) This patch does two things in order to enable compilation of the problematic code in PR23810: 1. In Sema::buildOverloadedCallSet, it postpones lookup for MS mode when no viable candidate is found in the overload set. Previously, lookup would only be postponed here if the overload set was empty. 2. Make BuildRecoveryCallExpr call Sema::DiagnoseEmptyLookup under more circumstances. There is a comment in DiagnoseTwoPhaseLookup that says "Don't diagnose names we find in classes; we get much better diagnostics for these from DiagnoseEmptyLookup." The problem was that DiagnoseEmptyLookup might not get called later, and we failed to recover. Differential Revision: http://reviews.llvm.org/D10369 llvm-svn: 239558
* Limit set of types instantiated in FindInstantiatedDecl.Serge Pavlov2015-05-151-0/+37
| | | | | | | | Starting from r236426 FindInstantiatedDecl may instantiate types that are referenced before definition. This change limit the set of types that can be instantiated by this function. llvm-svn: 237434
* PR20625: Instantiate static constexpr member function of a local struct in a ↵Richard Smith2015-05-111-0/+15
| | | | | | | | | | | | | | | function template earlier. This is necessary in order to allow the use of a constexpr member function, or a member function with deduced return type, of a local class within a surrounding instantiated function template specialization. Patch by Michael Park! This re-commits r236063, which was reverted in r236134, along with a fix for a delayed template parsing bug that was exposed by this change. llvm-svn: 237064
* Instantiate incomplete class used in template method.Serge Pavlov2015-05-041-0/+129
| | | | | | | | | | | If a class is absent from instantiation and is incomplete, instantiate it as an incomplete class thus avoiding compiler crash. This change fixes PR18653. Differential Revision: http://reviews.llvm.org/D8281 llvm-svn: 236426
* Revert r236063 due to regression with -fdelayed-template-parsing.Richard Smith2015-04-291-13/+0
| | | | llvm-svn: 236134
* PR20625: Instantiate static constexpr member function of a local struct in a ↵Richard Smith2015-04-291-0/+13
| | | | | | | | | | | | function template earlier. This is necessary in order to allow the use of a constexpr member function, or a member function with deduced return type, of a local class within a surrounding instantiated function template specialization. Patch by Michael Park! llvm-svn: 236063
* Combine instantiation context of field initializer with context of class.Serge Pavlov2015-04-281-0/+19
| | | | | | | | | | | | | | Inclass initializer is instantiated in its own LocalInstantiationScope. It causes problems when instantiating local classes - when instantiation scope is searched for DeclContext of the field, the search fails. As a solution, the instantiation scope of field initializer is combined with its outer scope. This patch fixes PR23194. Differential Revision: http://reviews.llvm.org/D9258 llvm-svn: 236005
* Improve the error message for assigning to read-only variables.Richard Trieu2015-04-111-1/+3
| | | | | | | | | | Previously, many error messages would simply be "read-only variable is not assignable" This change provides more information about why the variable is not assignable, as well as note to where the const is located. Differential Revision: http://reviews.llvm.org/D4479 llvm-svn: 234677
* Use the most recent previous decl to check if inline is added after a definitionReid Kleckner2015-04-081-0/+16
| | | | | | | | | | | | | | | | | | | | | | | This affects this test case: void foo(); template <typename T> class C { friend inline void foo(); }; inline void foo() {} C<int> c; Here, we instantiate the foo friend decl and add it to foo's redecl chain. However, our previous decl pointer happens to reference the first declaration of foo, which is not marked inline. When we check to see if foo was already defined, we implicitly search all previous decls. We should do the same for the inline check, instead of just checking this particular previous decl. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D8872 llvm-svn: 234374
* [MSVC] Explicit specializations can be declared in any namespace (fix for ↵Alexey Bataev2015-03-201-0/+33
| | | | | | | | | | | | | | http://llvm.org/PR13738) MS compiler emits no errors in case of explicit specializations outside declaration enclosing namespaces, even when language extensions are disabled. The patch is to suppress errors and emit extension warnings if explicit specializations are not declared in the corresponding namespaces. This fixes PR13738. Patch by Alexey Frolov. Differential Revision: http://reviews.llvm.org/D8283 llvm-svn: 232800
* Revert "Improve declaration / expression disambiguation around ↵Justin Bogner2015-02-231-2/+2
| | | | | | | | | | | ptr-operators, and use" This seems to break mixing function-style and c-style casts, and is breaking bootstrapping llvm. This reverts r230261. llvm-svn: 230274
* Improve declaration / expression disambiguation around ptr-operators, and useRichard Smith2015-02-231-2/+2
| | | | | | | | the presence of an abstract declarator with a ptr-operator as proof that a construct cannot parse as an expression to improve diagnostics along error recovery paths. llvm-svn: 230261
* [MSVC] Improved lookup into dependent/non-dependent bases of dependent classAlexey Bataev2015-02-191-6/+63
| | | | | | | | Patch improves lookup into dependendt bases of dependent class and adds lookup into non-dependent bases. Differential Revision: http://reviews.llvm.org/D7173 llvm-svn: 229817
* Weaken an assertion that isn't true for invalid input.Nico Weber2015-01-301-0/+5
| | | | llvm-svn: 227540
* Fix assert instantiating string init of static variableBen Langmuir2015-01-261-0/+12
| | | | | | | | ... when the variable's type is a typedef of a ConstantArrayType. Just look through the typedef (and any other sugar). We only use the constant array type here to get the element count. llvm-svn: 227115
OpenPOWER on IntegriCloud