summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/instantiate-init.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR36055: fix computation of *-dependence in nested initializer lists.Richard Smith2018-02-071-0/+14
| | | | | | | | | | | | | | | | When we synthesize an implicit inner initializer list when analyzing an outer initializer list, we add it to the outer list immediately, and then fill in the inner list. This gives the outer list no chance to update its *-dependence bits with those of the completed inner list. To fix this, re-add the inner list to the outer list once it's completed. Note that we do not recompute the *-dependence bits from scratch when we complete an outer list; this would give the wrong result for the case where a designated initializer overwrites a dependent initializer with a non-dependent one. The resulting list in that case should still be dependent, even though all traces of the dependence were removed from the semantic form. llvm-svn: 324537
* PR23135: Don't instantiate constexpr functions referenced in unevaluated ↵Richard Smith2017-01-071-2/+1
| | | | | | | | | | | | | | | | | | | | | operands where possible. This implements something like the current direction of DR1581: we use a narrow syntactic check to determine the set of places where a constant expression could be evaluated, and only instantiate a constexpr function or variable if it's referenced in one of those contexts, or is odr-used. It's not yet clear whether this is the right set of syntactic locations; we currently consider all contexts within templates that would result in odr-uses after instantiation, and contexts within list-initialization (narrowing conversions take another victim...), as requiring instantiation. We could in principle restrict the former cases more (only const integral / reference variable initializers, and contexts in which a constant expression is required, perhaps). However, this is sufficient to allow us to accept libstdc++ code, which relies on GCC's behavior (which appears to be somewhat similar to this approach). llvm-svn: 291318
* Handle use of default member initializers before end of outermost classReid Kleckner2014-11-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, when we have this situation: struct A { template <typename T> struct B { int m1 = sizeof(A); }; B<int> m2; }; We can't parse m1's initializer eagerly because we need A to be complete. Therefore we wait until the end of A's class scope to parse it. However, we can trigger instantiation of B before the end of A, which will attempt to instantiate the field decls eagerly, and it would build a bad field decl instantiation that said it had an initializer but actually lacked one. Fixed by deferring instantiation of default member initializers until they are needed during constructor analysis. This addresses a long standing FIXME in the code. Fixes PR19195. Reviewed By: rsmith Differential Revision: http://reviews.llvm.org/D5690 llvm-svn: 222192
* Return statements are initialization; don't forget to revert the initializer toRichard Smith2014-08-211-0/+9
| | | | | | its syntactic form before re-analyzing it during template instantiation. llvm-svn: 216224
* Properly track l-paren of a CXXFucntionalCastExpr.Eli Friedman2013-08-151-0/+15
| | | | | | | | | | In addition to storing more useful information in the AST, this fixes a semantic check in template instantiation which checks whether the l-paren location is valid. Fixes PR16903. llvm-svn: 188495
* Improve 'failed template argument deduction' diagnostic for the case where weRichard Smith2013-01-311-1/+1
| | | | | | | | have a direct mismatch between some component of the template and some component of the argument. The diagnostic now says what the mismatch was, but doesn't yet say which part of the template doesn't match. llvm-svn: 174039
* Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,Eli Friedman2012-12-131-1/+1
| | | | | | and make sure additional uses don't get introduced. <rdar://problem/12858424>. llvm-svn: 170081
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-2/+13
| | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
* Improve the instantiation of static data members inDouglas Gregor2011-06-031-4/+15
| | | | | | | Sema::RequireCompleteExprType() a bit more, setting the point of instantiation if needed, and skipping explicit specializations entirely. llvm-svn: 132547
* When performing template argument deduction given a function argumentDouglas Gregor2011-06-031-0/+23
| | | | | | | | | of incomplete array type, attempt to complete the array type. This was made much easier by Chandler's addition of RequireCompleteExprType(), which I've tweaked (slightly) to improve the consistency of the DeclRefExpr. Fixes PR7985. llvm-svn: 132530
* Enhance Clang to start instantiating static data member definitionsChandler Carruth2011-05-271-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | within class templates when they are necessary to complete the type of the member. The canonical example is code like: template <typename T> struct S { static const int arr[]; static const int x; static int f(); }; template <typename T> const int S<T>::arr[] = { 1, 2, 3 }; template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]); template <typename T> int S<T>::f() { return x; } int x = S<int>::f(); We need to instantiate S<T>::arr's definition to pick up its initializer and complete the array type. This involves new code to specially handle completing the type of an expression where the type alone is insufficient. It also requires *updating* the expression with the newly completed type. Fortunately, all the other infrastructure is already in Clang to do the instantiation, do the completion, and prune out the unused bits of code that result from this instantiation. This addresses the initial bug in PR10001, and will be a step to fleshing out other cases where we need to work harder to complete an expression's type. Who knew we still had missing C++03 "features"? llvm-svn: 132172
* When pulling apart an initializer that involves a CXXConstructExpr, doDouglas Gregor2010-03-241-0/+18
| | | | | | | not pick apart a CXXTemporaryObjectExpr because such an object construction was explicitly written in the source code. Fixes PR6657. llvm-svn: 99427
* Use CXXTemporaryObjectExpr for explicitly-constructed temporaries. WeDouglas Gregor2010-03-021-0/+11
| | | | | | | used to do this, but it got lost when we switched functional-style cast syntax over to using the new initialization code. Fixes PR6457. llvm-svn: 97568
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Implement support for C++ direct initializers that involve dependentDouglas Gregor2009-08-261-0/+28
types or type-dependent expressions. llvm-svn: 80143
OpenPOWER on IntegriCloud