Commit Graph

170 Commits

Author SHA1 Message Date
Eli Friedman 9cf6b59400 Add additional note to mark the cause of synthesized constructors. Mark
declaration invalid if the constructor can't be properly built.  Addresses
remaining review comments from Fariborz for r86500.

llvm-svn: 86579
2009-11-09 19:20:36 +00:00
Eli Friedman d7686ef31c Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors.  This has a number of benefits:

1. Less code.

2. Explicit and implicit constructors get the same diagnostics.

3. The AST explicitly contains constructor calls from implicit default
constructors.  This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.

llvm-svn: 86500
2009-11-09 01:05:47 +00:00
Daniel Dunbar 34546ce43d Remove RUN: true lines.
llvm-svn: 86432
2009-11-08 01:47:25 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Sebastian Redl 1060067dd1 Don't allow definitions of array variables without some size information in C++. Fixed PR5401
llvm-svn: 86165
2009-11-05 19:47:47 +00:00
Sebastian Redl 2dfdb820ca Allow the element type of arrays to be incomplete in C++.
This fixes PR5048. Also fix a bug where zero-sized arrays weren't warned about when the size was unsigned.

llvm-svn: 86136
2009-11-05 15:52:31 +00:00
Douglas Gregor 220f4277bd Switch parsing of using declarations over to ParseUnqualifiedId.
llvm-svn: 86027
2009-11-04 16:30:06 +00:00
Daniel Dunbar a530841b4f Switch XFAIL format to match LLVM.
llvm-svn: 85880
2009-11-03 07:25:45 +00:00
Douglas Gregor 7861a80346 Introduce a new class, UnqualifiedId, that provides a parsed
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.

Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.

llvm-svn: 85851
2009-11-03 01:35:08 +00:00
Douglas Gregor 1d0015f8e1 Improved fix for PR3844, which recovers better for class template
partial specializations and explicit instantiations of non-templates.

llvm-svn: 85620
2009-10-30 22:09:44 +00:00
Douglas Gregor 916462b2f7 Improve diagnostics when parsing something like
template<> struct foo<int> { ... };

where "foo" does not refer to a template. Fixes PR3844.

llvm-svn: 85616
2009-10-30 21:46:58 +00:00
Douglas Gregor 412e8bc56d Instantiate class template friends better; fixes PR5332.
llvm-svn: 85612
2009-10-30 21:07:27 +00:00
John McCall 70dd5f6574 Report accurate source-location information when rebuilding types during
template instantiation.

llvm-svn: 85545
2009-10-30 00:06:24 +00:00
Douglas Gregor 21610380de Implement support for semantic checking and template instantiation of
class template partial specializations of member templates. Also,
fixes a silly little bug in the marking of "used" template parameters
in member templates. Fixes PR5236.

llvm-svn: 85447
2009-10-29 00:04:11 +00:00
Douglas Gregor 19f3d70149 Test
explicit-instantiation-declaration-after-explicit-instantiation-definition
errors. This wraps up explicit template instantiation for now.

llvm-svn: 85347
2009-10-27 23:55:05 +00:00
Douglas Gregor b7e5c847c4 Implement proper linkage for explicit instantiation declarations of
inlined functions. For example, given

  template<typename T>
  class string {
    unsigned Len;

  public:
    unsigned size() const { return Len; }
  };

  extern template class string<char>;

we now give the instantiation of string<char>::size
available_externally linkage (if it is ever instantiated!), as
permitted by the C++0x standard.
      

llvm-svn: 85340
2009-10-27 23:26:40 +00:00
Douglas Gregor afca3b4a5c Explicit instantiation suppresses the instantiation of non-inline
function template specializations and member functions of class
template specializations.

llvm-svn: 85300
2009-10-27 20:53:28 +00:00
Douglas Gregor 1d957a336f An explicit instantiation definition only instantiations those class
members that have a definition. Also, use
CheckSpecializationInstantiationRedecl as part of this instantiation
to make sure that we diagnose the various kinds of problems that can
occur with explicit instantiations.

llvm-svn: 85270
2009-10-27 18:42:08 +00:00
Douglas Gregor 04a0a6c461 Test for interaction between explicit instantiations and specializations
llvm-svn: 85244
2009-10-27 15:36:37 +00:00
Douglas Gregor 969c2a238c Test various aspects of explicit instantiation that were already implemented.
llvm-svn: 85243
2009-10-27 15:00:12 +00:00
Douglas Gregor ef6ab417c1 Only set the point of instantiation for an implicit or explicit
instantiation once we have committed to performing the
instantiation. As part of this, make our makeshift
template-instantiation location information suck slightly less.

Fixes PR5264.

llvm-svn: 85209
2009-10-27 06:26:26 +00:00
Sebastian Redl e24b16205f Make sure we actually have a definition before asking if it is implicit. Fixes PR4674.
llvm-svn: 85072
2009-10-25 22:31:45 +00:00
Sebastian Redl 548e629e02 In some dependent contexts, incomplete array types persist into FinalizeDeclaratorGroup. Don't require them to have a complete type. This allows us to compile Hello World with the Apache stdcxx library. If you don't use endl, it even links and runs.
llvm-svn: 84347
2009-10-17 19:37:06 +00:00
Douglas Gregor 8f003d0fa3 Make sure that we're diagnosing duplicate explicit instantiation definitions.
llvm-svn: 84189
2009-10-15 18:07:02 +00:00
Douglas Gregor d6ba93dc6e Check the interactions between explicit instantiations and template
specializations. Work in progress; there's more cleanup required to
actually use the new CheckSpecializationInstantiationRedecl checker
uniformly.

llvm-svn: 84185
2009-10-15 15:54:05 +00:00
Douglas Gregor a8b89d2622 Diagnose explicit instantiations of function templates and member
functions/static data members of class template specializations that
do not have definitions. This is the latter part of [temp.explicit]p4;
the former part still needs more testing.

llvm-svn: 84182
2009-10-15 14:05:49 +00:00
Douglas Gregor 68edf13213 More explicit template instantiation. Now we're checking for more
cases where an explicit instantiation requires a definition; the
remainder of these checks will come with the implementation of
paragraph 4 of [temp.explicit].

llvm-svn: 84181
2009-10-15 12:53:22 +00:00
Douglas Gregor e47f5a76cc Additional semantic checking for explicit template instantiations,
focusing on the scope- and qualifier-related semantic requirements in
C++ [temp.explicit]p2.

llvm-svn: 84154
2009-10-14 23:41:34 +00:00
Douglas Gregor b81005dffc Check the implicit instantiation of a static data member of a class
template that has no out-of-line definition.

llvm-svn: 84141
2009-10-14 21:33:19 +00:00
Douglas Gregor 3cc3cdeea9 Give explicit and implicit instantiations of static data members of
class templates the proper linkage. 

Daniel, please look over the CodeGenModule bits.

llvm-svn: 84140
2009-10-14 21:29:40 +00:00
Douglas Gregor 3c74d41d27 Testing and some minor fixes for explicit template instantiation.
llvm-svn: 84129
2009-10-14 20:14:33 +00:00
Douglas Gregor 15e5602e59 Improve diagnostics when the parser encounters a declarator with an
unknown type name, e.g.,

  foo::bar x;

when "bar" does not refer to a type in "foo". 

With this change, the parser now calls into the action to perform
diagnostics and can try to recover by substituting in an appropriate
type. For example, this allows us to easily diagnose some missing
"typename" specifiers, which we now do:

  test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename'
        prior to dependent type name 'A<T>::type'
  A<T>::type A<T>::f() { return type(); }
  ^~~~~~~~~~
  typename 

Fixes PR3990.

llvm-svn: 84053
2009-10-13 23:27:22 +00:00
Douglas Gregor e40876a50c Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.

llvm-svn: 84028
2009-10-13 21:16:44 +00:00
Douglas Gregor 62e10f0bdc Diagnose attempts to add default function arguments to a
specialization. This completes C++ [temp.expl.spec]!

llvm-svn: 83980
2009-10-13 17:02:54 +00:00
Douglas Gregor cf91555cb8 When explicitly specializing a member that is a template, mark the
template as a specialization. For example, this occurs with:

  template<typename T>
  struct X {
    template<typename U> struct Inner { /* ... */ };
  };

  template<> template<typename T>
  struct X<int>::Inner {
    T member;
  };

We need to treat templates that are member specializations as special
in two contexts:

  - When looking for a definition of a member template, we look
    through the instantiation chain until we hit the primary template
    *or a member specialization*. This allows us to distinguish
    between the primary "Inner" definition and the X<int>::Inner
    definition, above.
  - When computing all of the levels of template arguments needed to
    instantiate a member template, don't add template arguments
    from contexts outside of the instantiation of a member
    specialization, since the user has already manually substituted
    those arguments.

Fix up the existing test for p18, which was actually wrong (but we
didn't diagnose it because of our poor handling of member
specializations of templates), and add a new test for member
specializations of templates.

llvm-svn: 83974
2009-10-13 16:30:37 +00:00
Douglas Gregor 3a88c1d784 Improve the internal representation and semantic analysis of friend
function templates.

This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation. 

Oh, and make sure that explicit specialization declarations are not
friends.

llvm-svn: 83970
2009-10-13 14:39:41 +00:00
Douglas Gregor ef06ccf8d0 When declaring a class template whose name is qualified, make sure
that the scope in which it is being declared is complete. Also, when
instantiating a member class template's ClassTemplateDecl, be sure to
delay type creation so that the resulting type is dependent. Ick.

llvm-svn: 83923
2009-10-12 23:11:44 +00:00
Douglas Gregor 775b837976 Test explicit specialization involving multiple template<> headers
llvm-svn: 83914
2009-10-12 22:33:31 +00:00
Douglas Gregor ca027af608 Permit explicit specialization of member functions of class templates
that are declarations (rather than definitions). Also, be sure to set
the access specifiers properly when instantiating the declarations of
member function templates.

llvm-svn: 83911
2009-10-12 22:27:17 +00:00
Douglas Gregor 2210c9cd6e Test explicit specializations of static data members that are declarations, not definitions
llvm-svn: 83904
2009-10-12 21:37:59 +00:00
Douglas Gregor a2fe1fe208 Yet another test for explicit specialization, this one involving linkage
llvm-svn: 83901
2009-10-12 21:21:22 +00:00
Douglas Gregor 1fc79dda69 More tests for explicit template specialization
llvm-svn: 83896
2009-10-12 20:45:50 +00:00
Douglas Gregor 00bb0cbfa5 Add test for last commit
llvm-svn: 83893
2009-10-12 20:23:10 +00:00
John McCall 6538c93050 Qualified lookup through using declarations. Diagnose a new type of ambiguity.
Split the various ambiguous result enumerators into their own enum.  Tests
for most of C++ [namespace.qual].

llvm-svn: 83700
2009-10-10 05:48:19 +00:00
Anders Carlsson 7f84ed9287 Add CheckCallReturnType and start using it for regular call expressions. This will improve error messages. For
struct B;

B f();

void g() {
f();
}

We now get

t.cpp:6:3: error: calling 'f' with incomplete return type 'struct B'
  f();
  ^~~
t.cpp:3:3: note: 'f' declared here
B f();
  ^
t.cpp:1:8: note: forward declaration of 'struct B'
struct B;
       ^

llvm-svn: 83692
2009-10-09 23:51:55 +00:00
Douglas Gregor 1245e6ff69 Tests for C++ [expr], from James Porter!
llvm-svn: 83588
2009-10-08 22:38:14 +00:00
Fariborz Jahanian 8ae5b0a18b Fix up error reporting when object cannot be constructed
because of missing default constructor of a member.
Fixes pr5154.

llvm-svn: 83583
2009-10-08 22:15:49 +00:00
Douglas Gregor eeffde3a1d Add more testing for the properties of explicit specialization.
Also, eliminate a redundant diagnostic by marking a variable declared
with incomplete type as an invalid declaration.

llvm-svn: 83553
2009-10-08 16:41:22 +00:00
Douglas Gregor 19c52729ed Don't complain about out-of-line explicit specializations of member
function and member function templates that are not definitions. Add
more tests to ensure that explicit specializations of member function
templates prevent instantiation.

llvm-svn: 83550
2009-10-08 15:54:21 +00:00
Douglas Gregor 1e9b25caf4 More testing for explicit specializations of member class templates
llvm-svn: 83548
2009-10-08 15:27:05 +00:00