Commit Graph

59 Commits

Author SHA1 Message Date
Douglas Gregor 0004417e81 Use the new statement/expression profiling code to unique dependent
template arguments, as in template specialization types. This permits
matching out-of-line definitions of members for class templates that
involve non-type template parameters.

llvm-svn: 77462
2009-07-29 16:09:57 +00:00
Douglas Gregor 8ce432e9eb Add a template test that requires canonical expression comparison
llvm-svn: 77325
2009-07-28 16:39:54 +00:00
Owen Anderson e05f2ed478 Update for LLVM API change.
llvm-svn: 77249
2009-07-27 21:00:51 +00:00
Daniel Dunbar 595c98729b Make having no RUN line a failure.
Doug, please look at decltype-crash and instantiate-function-1.mm, I'm not sure
if they are actually testing the right thing / anything.

llvm-svn: 77070
2009-07-25 12:47:38 +00:00
John McCall 02dee0a46a Semantic checking for main().
Fix some invalid main() methods in the test suite that were nicely
exposed by the new checks.

llvm-svn: 77047
2009-07-25 04:36:53 +00:00
Douglas Gregor a6ef8f0813 Template instantiation for static data members that are defined out-of-line.
Note that this also fixes a bug that affects non-template code, where we 
were not treating out-of-line static data members are "file-scope" variables,
and therefore not checking their initializers.

llvm-svn: 77002
2009-07-24 20:34:43 +00:00
Douglas Gregor e93e46c690 Implement support for out-of-line definitions of the class members of class
templates, e.g.,

  template<typename T>
  struct Outer {
    struct Inner;
  };

  template<typename T>
  struct Outer<T>::Inner {
    // ...
  };

Implementing this feature required some extensions to ActOnTag, which
now takes a set of template parameter lists, and is the precursor to
removing the ActOnClassTemplate function from the parser Action
interface. The reason for this approach is simple: the parser cannot
tell the difference between a class template definition and the
definition of a member of a class template; both have template
parameter lists, and semantic analysis determines what that template
parameter list means.

There is still some cleanup to do with ActOnTag and
ActOnClassTemplate. This commit provides the basic functionality we
need, however.

llvm-svn: 76820
2009-07-22 23:48:44 +00:00
Mike Stump af6ab88979 Prep for new warning.
llvm-svn: 76772
2009-07-22 20:02:03 +00:00
Douglas Gregor 8a27391190 "This patch implements the restrictions on union members detailed in
[class.union]p1", from John McCall!

llvm-svn: 76766
2009-07-22 18:25:24 +00:00
Douglas Gregor b09f3d82cc Implement parsing and semantic analysis for out-of-line definitions of static
data members of class templates. We don't instantiate the definitions yet,
however.

llvm-svn: 76756
2009-07-22 17:18:37 +00:00
Douglas Gregor a3a4dd5d03 Test template instantiation for member functions of class templates defined
out of line.

llvm-svn: 76740
2009-07-22 15:45:39 +00:00
Douglas Gregor 168190d822 Complain if we're entering the context of a dependent nested-name-specifier but
cannot match that nested-name-specifier to a class template or class template
partial specialization.

llvm-svn: 76704
2009-07-22 00:28:09 +00:00
Douglas Gregor d8d297c0ac Basic parsing and semantic analysis for out-of-line definitions of the
member functions of class templates, e.g.,

  template<typename T> 
  struct X {
    void f(T);
  };

  template<typename T> X<T>::f(T) { /* ... */ }

llvm-svn: 76692
2009-07-21 23:53:31 +00:00
Mike Stump 0ab3c3deac Revert this, we have a better way to do this.
llvm-svn: 76687
2009-07-21 23:47:12 +00:00
Mike Stump d8679446a3 Revert this, we have a better way to handle this.
llvm-svn: 76685
2009-07-21 23:45:39 +00:00
Mike Stump df3f1447e4 Prep for new warning.
llvm-svn: 76640
2009-07-21 21:03:09 +00:00
Mike Stump f4464156cf Prep for new warning.
llvm-svn: 76628
2009-07-21 19:03:43 +00:00
Mike Stump 447351f1ff Prep for new warning.
llvm-svn: 76627
2009-07-21 19:02:55 +00:00
Daniel Dunbar 631a57e30f Fix test case to match intent.
llvm-svn: 75381
2009-07-11 20:17:35 +00:00
Anders Carlsson 43171d6aeb Add another test.
llvm-svn: 75324
2009-07-11 00:55:33 +00:00
Anders Carlsson ae01993a12 Implement more of C++0x 'auto'. A variable with an auto type specifier must have an initializer. Also, move some tests around to match the C++0x draft better.
llvm-svn: 75322
2009-07-11 00:34:39 +00:00
Douglas Gregor b05ce0f395 Another little test for C++ [over.over]
llvm-svn: 75151
2009-07-09 17:44:05 +00:00
Douglas Gregor 6b6ba8bad8 Add test for C++ [over.over.]p1, the contexts in which one can take the address of an overloaded function.
llvm-svn: 75146
2009-07-09 17:16:51 +00:00
Anders Carlsson 03f89b1828 Store the isAddressOfOperand in the UnresolvedDeclRefExpr, so that we can pass it when instantiating the expr. Fixes another member pointer bug.
llvm-svn: 75075
2009-07-09 00:05:08 +00:00
Douglas Gregor b257e4fff8 Implement the simple form of overload resolution used when taking the
address of an overloaded function (which may involve both functions
and function templates). 

llvm-svn: 75069
2009-07-08 23:33:52 +00:00
Anders Carlsson 0b675f5ad5 It's not allowed to form member pointers to members that have reference type. Add a test for this and the rest of [dcl.mptr]p3.
llvm-svn: 75054
2009-07-08 21:45:58 +00:00
Douglas Gregor 9b14658713 Implement template argument deduction when taking the address of a
function template. Most of the change here is in factoring out the
common bits used for template argument deduction from a function call
and when taking the address of a function template.

llvm-svn: 75044
2009-07-08 20:55:45 +00:00
Douglas Gregor be759256b9 Fix a corner case with argument-dependent lookup and overloaded function sets.
llvm-svn: 74999
2009-07-08 10:57:20 +00:00
Douglas Gregor 197e5f7bb7 Improve argument-dependent lookup to find associated classes and
namespaces based on the template arguments of a class template
specialization type.

llvm-svn: 74993
2009-07-08 07:51:57 +00:00
Douglas Gregor d3cb356d14 Overload resolution prefers non-templates to templates
llvm-svn: 74971
2009-07-07 23:38:56 +00:00
Douglas Gregor e81f3e71f8 Improve template argument deduction from a call. In particular,
implement C++ [temp.deduct.call]p3b3, which allows a template-id
parameter to match a derived class of the argument, while deducing
template arguments.

llvm-svn: 74965
2009-07-07 23:09:34 +00:00
Ted Kremenek 71bf4264bf Fix RUN line so this test doesn't hang.
llvm-svn: 74719
2009-07-02 18:44:31 +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
Douglas Gregor e3f1f350ff Cope with explicitly-specified function template arguments when there
are fewer template arguments than there are template parameters for
that function.

llvm-svn: 74578
2009-07-01 00:28:38 +00:00
Douglas Gregor 89026b5018 When explicit template arguments are provided for a function call,
substitute those template arguments into the function parameter types
prior to template argument deduction. There's still a bit of work to
do to make this work properly when only some of the template arguments
are specified.

llvm-svn: 74576
2009-06-30 23:57:56 +00:00
Douglas Gregor a727cb98a4 Preliminary parsing and ASTs for template-ids that refer to function
templates, such as make<int&>. These template-ids are only barely
functional for function calls; much more to come.

llvm-svn: 74563
2009-06-30 22:34:41 +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 cf0b47d179 During template argument deduction from a function call, allow
deduction from pointer and pointer-to-member types to work even in the
presence of a qualification conversion (C++ [temp.deduct.type]p3
bullet 2). 

llvm-svn: 74354
2009-06-26 23:10:12 +00:00
Anders Carlsson 94ff77a356 More auto work.
llvm-svn: 74339
2009-06-26 22:18:59 +00:00
Anders Carlsson f82bb6b4ed Fix test.
llvm-svn: 74335
2009-06-26 21:54:43 +00:00
Douglas Gregor febe45a727 A little template argument deduction test uncovered an "oops". As part
of template instantiation, we were dropping cv-qualifiers on the
instantiated type in a few places. This change reshuffles the
type-instantiation code a little bit so that there's a single place
where we add qualifiers to the instantiated type, so that we won't end
up with this same bug in the future.

llvm-svn: 74331
2009-06-26 21:40:05 +00:00
Douglas Gregor 705c900d23 Template argument deduction is no longer responsible for checking
non-dependent parameter types. Instead, class template partial
specializations perform a final check of all of the instantiated
arguments. This model is cleaner, and works better for function
templates where the "final check" occurs during overload resolution.

Also, cope with cv-qualifiers when the parameter type was originally a
reference type, so that the deduced argument can be more qualified
than the transformed argument.

llvm-svn: 74323
2009-06-26 20:57:09 +00:00
Anders Carlsson 6bd992d1c3 Can't have arrays of auto.
llvm-svn: 74314
2009-06-26 19:33:28 +00:00
Anders Carlsson 364035d1a8 An auto variable can't appear in its own initializer.
llvm-svn: 74312
2009-06-26 19:16:07 +00:00
Douglas Gregor cceb97559e Improve template argument deduction for reference parameters when
deducing template arguments from a function call. Plus, add a bunch of
tests.

llvm-svn: 74301
2009-06-26 18:27:22 +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
Anders Carlsson ad6bd35b46 C++ decltype support (N2343)
llvm-svn: 74118
2009-06-24 21:24:56 +00:00
Douglas Gregor 23061ded56 Implement matching of function templates, so that one can declare overloaded function templates. C++ [temp.over.link] paragraphs 4-8.
llvm-svn: 74079
2009-06-24 16:50:40 +00:00
Anders Carlsson 9e47af8b59 Add test for [class.local]p2.
llvm-svn: 74051
2009-06-24 02:00:28 +00:00
Anders Carlsson 829574edab Add test for [class.nested.type]p1
llvm-svn: 74033
2009-06-24 00:30:37 +00:00