Commit Graph

222 Commits

Author SHA1 Message Date
Daniel Dunbar 619bf84ad4 The -disable-free hack didn't work...
llvm-svn: 75401
2009-07-11 23:05:12 +00:00
Daniel Dunbar 09bb21f80c Fix comment, and reduce computational expense of this test.
- I don't see any need for it to be this expensive.

llvm-svn: 75395
2009-07-11 22:44:48 +00:00
Daniel Dunbar cfd6800c76 Add -disable-free to this test in the hopes if having it pass on Linux for now.
llvm-svn: 75390
2009-07-11 22:00:53 +00:00
Anders Carlsson 7ca3f6feea Fix type of 'this' and add a decltype test.
llvm-svn: 75291
2009-07-10 21:35:09 +00:00
Douglas Gregor ff6cbdf806 Keep track of more information within the template instantiation stack, e.g.,
by distinguishing between substitution that occurs for template
argument deduction vs. explicitly-specifiad template arguments. This
is used both to improve diagnostics and to make sure we only provide
SFINAE in those cases where SFINAE should apply.

In addition, deal with the sticky issue where SFINAE only considers
substitution of template arguments into the *type* of a function
template; we need to issue hard errors beyond this point, as
test/SemaTemplate/operator-template.cpp illustrates.

llvm-svn: 74651
2009-07-01 22:01:06 +00:00
Fariborz Jahanian c1fc3ec878 Patch to implement template types in ctor-initializer list.
Also has fix for bugzilla-4469.

llvm-svn: 74631
2009-07-01 19:21:19 +00:00
Douglas Gregor dda7ced32e When recursively instantiating function templates, keep track of the
instantiation stack so that we provide a full instantiation
backtrace. Previously, we performed all of the instantiations implied
by the recursion, but each looked like a "top-level" instantiation.

The included test case tests the previous fix for the instantiation of
DeclRefExprs. Note that the "instantiated from" diagnostics still
don't tell us which template arguments we're instantiating with.

llvm-svn: 74540
2009-06-30 17:20:14 +00:00
Douglas Gregor 15448f8d23 Improve support for overloaded operator templates.
llvm-svn: 74390
2009-06-27 21:05:07 +00:00
Eli Friedman 173e0b7a96 Fix a bogus error overloading an operator where the only class
parameter has a dependent type.

llvm-svn: 74380
2009-06-27 05:59:59 +00:00
Douglas Gregor 4adbc6d947 Implicit instantiation for function template specializations.
For a FunctionDecl that has been instantiated due to template argument
deduction, we now store the primary template from which it was
instantiated and the deduced template arguments. From this
information, we can instantiate the body of the function template.

llvm-svn: 74232
2009-06-26 00:10:03 +00:00
Douglas Gregor ad3f2fcf43 Improved semantic analysis and AST respresentation for function
templates.

For example, this now type-checks (but does not instantiate the body
of deref<int>):

  template<typename T> T& deref(T* t) { return *t; }

  void test(int *ip) {
    int &ir = deref(ip);
  }

Specific changes/additions:
  * Template argument deduction from a call to a function template.
  * Instantiation of a function template specializations (just the
  declarations) from the template arguments deduced from a call.
  * FunctionTemplateDecls are stored directly in declaration contexts
  and found via name lookup (all forms), rather than finding the
  FunctionDecl and then realizing it is a template. This is
  responsible for most of the churn, since some of the core
  declaration matching and lookup code assumes that all functions are
  FunctionDecls.

llvm-svn: 74213
2009-06-25 22:08:12 +00:00
Douglas Gregor b52fabb2a8 Start propagating template parameter lists to the right places to
handle function templates. There's no actual code for function
templates yet, but at least we complain about typedef templates.

llvm-svn: 74021
2009-06-23 23:11:28 +00:00
Douglas Gregor 412190b067 Some semantic tests for implicit instantiations
llvm-svn: 73924
2009-06-22 23:57:29 +00:00
Douglas Gregor 71a5718f2d Robustify a bunch of C++-related declaration actions.
llvm-svn: 73918
2009-06-22 23:20:33 +00:00
Douglas Gregor 77b50e1126 Implement implicit instantiation of the member functions of a class template
specialization. At present, all implicit instantiations occur at the
end of the translation unit.

llvm-svn: 73915
2009-06-22 23:06:13 +00:00
Douglas Gregor f187420feb Diagnose class members that shadow a template parameter. Fixes
<rdar://problem/6952203>. 

To do this, we actually remove a not-quite-correct optimization in the
C++ name lookup routines. We'll revisit this optimization for the
general case once more C++ is working.

llvm-svn: 73659
2009-06-17 23:37:01 +00:00
Douglas Gregor 758a869b14 Support dependent extended vector types and template instantiation
thereof. Patch by Anders Johnsen!

llvm-svn: 73641
2009-06-17 21:51:59 +00:00
Douglas Gregor 33834516f3 Update LLVM.
Implement support for C++ Substitution Failure Is Not An Error
(SFINAE), which says that errors that occur during template argument
deduction do *not* produce diagnostics and do not necessarily make a
program ill-formed. Instead, template argument deduction silently
fails. This is currently implemented for template argument deduction
during matching of class template partial specializations, although
the mechanism will also apply to template argument deduction for
function templates. The scheme is simple:

  - If we are in a template argument deduction context, any diagnostic
    that is considered a SFINAE error (or warning) will be
    suppressed. The error will be propagated up the call stack via the
    normal means.
  - By default, all warnings and errors are SFINAE errors. Add the
    NoSFINAE class to a diagnostic in the .td file to make it a hard
    error (e.g., for access-control violations).

Note that, to make this fully work, every place in Sema that emits an
error *and then immediately recovers* will need to check
Sema::isSFINAEContext() to determine whether it must immediately
return an error rather than recovering.

llvm-svn: 73332
2009-06-14 07:33:30 +00:00
Douglas Gregor a5d5c749b1 Move a bunch of tests into temp.param, and write a few tests for paragraphs that hadn't been touched before
llvm-svn: 73288
2009-06-13 06:59:07 +00:00
Eli Friedman 9a0e23c495 Fix for PR4382: allow instantiating dependent nested name specifiers.
I'm not completely sure this is the right way to fix this issue, but it seems 
reasonable, and it's consistent with the non-template code for this 
construct.

llvm-svn: 73285
2009-06-13 04:51:30 +00:00
Anders Carlsson 20ee0ed4ea If a CXXRecordDecl is a class template, the 'this' type should be the injected class name type. Fixes pr4383.
llvm-svn: 73284
2009-06-13 02:59:33 +00:00
Anders Carlsson 15201f19ba More work on type parameter packs.
llvm-svn: 73281
2009-06-13 02:08:00 +00:00
Douglas Gregor 91772d1d76 When some template parameters of a class template partial
specialization cannot be deduced, produce a warning noting that the
affected class template partial specialization will never be used.

llvm-svn: 73274
2009-06-13 00:26:55 +00:00
Anders Carlsson 327865db53 A parameter pack must always come last in a class template.
llvm-svn: 73269
2009-06-12 23:20:15 +00:00
Anders Carlsson f986ba7528 Address more comments from Doug.
llvm-svn: 73267
2009-06-12 23:09:56 +00:00
Anders Carlsson d382435014 Parameter packs can't have default arguments.
llvm-svn: 73262
2009-06-12 22:30:13 +00:00
Douglas Gregor 30b0197169 Finish implementing checking of class template partial specializations
llvm-svn: 73260
2009-06-12 22:21:45 +00:00
Douglas Gregor 09a3023e65 Diagnose C++ [temp.class.spec]p9b3, where a class template partial
specialization's arguments are identical to the implicit template
arguments of the primary template. Typically, this is meant to be a
declaration/definition of the primary template, so we give that
advice.

llvm-svn: 73259
2009-06-12 22:08:06 +00:00
Douglas Gregor 8cfd2ba76d Diagnose the incorrect use of non-type template arguments for class
template partial specializations.

llvm-svn: 73254
2009-06-12 21:21:02 +00:00
Anders Carlsson 01e9e93485 Parse support for C++0x type parameter packs.
llvm-svn: 73247
2009-06-12 19:58:00 +00:00
Douglas Gregor d52220513f Verify that the template parameters of a class template partial
specialization do not have default arguments 
(C++ [temp.class.spec]p10). 

llvm-svn: 73245
2009-06-12 19:43:02 +00:00
Anders Carlsson b0e8e228ff Fix PR4365.
llvm-svn: 73240
2009-06-12 18:53:02 +00:00
Anders Carlsson a767eeed19 Deducation and instantiation of block types.
llvm-svn: 73232
2009-06-12 16:23:10 +00:00
Douglas Gregor 74eba0b679 Once we have deduced the template arguments of a class template
partial specialization, substitute those template arguments back into
the template arguments of the class template partial specialization to
see if the results still match the original template arguments.

This code is more general than it needs to be, since we don't yet
diagnose C++ [temp.class.spec]p9. However, it's likely to be needed
for function templates.

llvm-svn: 73196
2009-06-11 18:10:32 +00:00
Anders Carlsson 40ed344c92 Add a null check that fixes the crash in PR4362, and make sure to instantiate non-type template arguments.
llvm-svn: 73193
2009-06-11 16:06:49 +00:00
Eli Friedman dd49ee3fb4 Make sure to calculate value-dependence correctly when deal with ICEs.
(Actually, this isn't precisely correct, but it doesn't make 
sense to query whether an expression that isn't an ICE is 
value-dependent anyway.)

llvm-svn: 73179
2009-06-11 01:11:20 +00:00
Eli Friedman 88681cce60 Move test to be with the other typename tests.
llvm-svn: 73178
2009-06-11 01:01:02 +00:00
Douglas Gregor 637d9984f0 Template argument deduction for member pointers.
Also, introduced some of the framework for performing instantiation as
part of template argument deduction.

llvm-svn: 73175
2009-06-10 23:47:09 +00:00
Douglas Gregor 0bdc1f5eef Handle member pointer types with dependent class types (e.g., int
T::*) and implement template instantiation for member pointer types.

llvm-svn: 73151
2009-06-09 22:17:39 +00:00
Douglas Gregor ed74eb81e1 Example metaprogram for reversing and searching in a type list
llvm-svn: 73147
2009-06-09 21:22:32 +00:00
Douglas Gregor 4fbe3e3014 Implement template argument deduction for class template
specialization types. As the example shows, we can now compute the
length of a type-list using a template metaprogram and class template
partial specialization.

llvm-svn: 73136
2009-06-09 16:35:58 +00:00
Anders Carlsson 096e6eeb68 Address comments from Doug.
llvm-svn: 73077
2009-06-08 19:22:23 +00:00
Douglas Gregor 6f998fcb1d Test template argument deduction on function types a little more
llvm-svn: 73072
2009-06-08 16:04:08 +00:00
Anders Carlsson 2128ec7cdd Template argument deduction for function types.
llvm-svn: 73070
2009-06-08 15:19:08 +00:00
Anders Carlsson 0880e9f58d Instantiation support for more Obj-C expressions, string literals, @selector and @protocol expressions.
llvm-svn: 73036
2009-06-07 19:51:47 +00:00
Anders Carlsson 315d2294f8 Template instantiation support for Obj-C @encode expressions.
llvm-svn: 73034
2009-06-07 18:45:35 +00:00
Anders Carlsson 03c9e87410 Fix another crash and actually make the test case work.
llvm-svn: 72913
2009-06-05 02:45:24 +00:00
Anders Carlsson dd096d888b Fix a case when the TemplateArgs vector can be empty.
llvm-svn: 72911
2009-06-05 02:12:32 +00:00
Douglas Gregor b7ae10f764 Several improvements to template argument deduction:
- Once we have deduced template arguments for a class template partial
    specialization, we use exactly those template arguments for instantiating
    the definition of the class template partial specialization.
  - Added template argument deduction for non-type template parameters.
  - Added template argument deduction for dependently-sized array types.

With these changes, we can now implement, e.g., the remove_reference
type trait. Also, Daniel's Ackermann template metaprogram now compiles
properly.

llvm-svn: 72909
2009-06-05 00:53:49 +00:00
Anders Carlsson 35533d11b3 Template argument deduction for incomplete and constant array types. Doug, please review.
llvm-svn: 72844
2009-06-04 04:11:30 +00:00