Commit Graph

6492 Commits

Author SHA1 Message Date
Alexis Hunt 1647354ec9 After consultation with doug, revert r131515.
llvm-svn: 131574
2011-05-18 20:57:13 +00:00
Alexis Hunt d0cdd1fab1 Revert r121528 as it breaks a simple testcase, which leads to, among
other things, libcxx not building.

llvm-svn: 131573
2011-05-18 20:57:11 +00:00
Sebastian Redl b900f04ccc Implement implicit exception specifications of destructors.
llvm-svn: 131528
2011-05-18 05:20:56 +00:00
Alexis Hunt e77a28f7e1 Implement an additional fix for infinite recursion of deleted special
member functions by making sure that they're on the record before
checking for deletion.

Also make sure source locations are valid to avoid crashes.

Unfortunately, the declare-all-implicit-members approach is still
required in order to ensure that dependency loops do not result in
incorrectly deleting functions (since they are to be deleted at the
declaration point per the standard).

Fixes PR9917

llvm-svn: 131520
2011-05-18 03:41:58 +00:00
Alexis Hunt 2430a6fb91 Force declaration of implicit members in C++0x mode.
I hear at least one person crying out in anguish, but it's unfortunately
necessary to avoid infinite loops with mutually dependent constructors
trying to call each other and determine if they are deleted.

It might be possible to go back to the old behavior if we can implement
part-of-file lookups efficiently, or if a solution is discovered by
which we can safely detect and avoid infinite recusion.

llvm-svn: 131515
2011-05-18 01:06:45 +00:00
Alexis Hunt 604aeb3849 Fix some minor bugs and add a lot more test cases for defaulted
constructors, including two more FIXMEs (one of which I don't actually
understand).

llvm-svn: 131487
2011-05-17 20:44:43 +00:00
Alexis Hunt 8b4551844c Implement some tests for defaulted constructors. To do this I had to
suppress an error we were previously emitting on valid union code.

llvm-svn: 131440
2011-05-17 00:19:05 +00:00
Alexis Hunt 97ab554c1c Implement the new C++0x rules for non-trivial things in unions so that
my defaulted constructor tests stop yelling at me about them.

llvm-svn: 131432
2011-05-16 22:41:40 +00:00
Douglas Gregor 9d07dfa439 When checking a set of template parameter lists against a
nested-name-specifier, re-evaluate the nested-name-specifier as if we
were entering that context (which we did!), so that we'll resolve a
template-id to a particular class template partial
specialization. Fixes PR9913.

llvm-svn: 131383
2011-05-15 17:27:27 +00:00
John McCall 036f2f6b35 The array-size operand to a new-expression is not necessarily a size_t.
It can be larger, it can be smaller, it can be signed, whatever.  Handle
all the crazy cases with grace and spirit.

llvm-svn: 131378
2011-05-15 07:14:44 +00:00
Argyrios Kyrtzidis 7da04c6367 Emit an error when trying to @encode an incomplete type.
There are APIs, e.g. [NSValue valueWithBytes:objCType:], which use the encoding to find out
the size of an object pointed to by a pointer. Make things safer by making it illegal to @encode
incomplete types.

llvm-svn: 131364
2011-05-14 20:32:39 +00:00
Francois Pichet c2fac71c75 Revert 131347. It asserts if the specialization in within a class template:
template<class U> 
struct X1 {
  template<class T> void f(T*);
  template<> void f(int*) { } 
};

Won't be so simple. I need to think more about it.

llvm-svn: 131362
2011-05-14 19:17:07 +00:00
Alexis Hunt 22b5b13ce3 Make sure we actually generate defaulted copy constructors; caught by
Howard Hinnant. Thanks!

llvm-svn: 131349
2011-05-14 18:20:50 +00:00
Francois Pichet 6744e14d9c In Microsoft mode, allow template function explicit specialization at class scope.
Necessary to parse MFC and MSVC standard lib code.

Example:
struct X {
  template<class T> void f(T) { }
  template<> void f(int) { } 
}

llvm-svn: 131347
2011-05-14 17:46:46 +00:00
Richard Smith 0c4a34b1a0 PR9908: Fix the broken fix for PR9902 to get the template argument lists in the right order.
Also, don't reject alias templates in all ElaboratedTypes: some ElaboratedTypes do not correspond to elaborated-type-specifiers.

llvm-svn: 131342
2011-05-14 15:04:18 +00:00
Alexis Hunt c9a5573ef1 What I hope to be an implementation of defaulted copy assignment
operators.

llvm-svn: 131338
2011-05-14 05:23:28 +00:00
Alexis Hunt b2f2780a16 More progress towards defaulted copy assignment
llvm-svn: 131337
2011-05-14 05:23:24 +00:00
Alexis Hunt 119f365d31 Start implementing defaulted copy assignment
llvm-svn: 131336
2011-05-14 05:23:20 +00:00
Alexis Hunt b5b14c8b8f Fix copy constructor deletion detection with array types.
This fixes PR9910

llvm-svn: 131309
2011-05-13 21:10:11 +00:00
Fariborz Jahanian 7d62273c87 refactor CheckForwardProtocolDeclarationForCircularDependency returns
'true' on detecting protocol cycles. No functionality change.

llvm-svn: 131297
2011-05-13 18:02:08 +00:00
Alexis Hunt 913820daf0 Defaulting copy constructors now works reasonably well.
One more special member to go

llvm-svn: 131287
2011-05-13 06:10:58 +00:00
Douglas Gregor a6a7e3c1f2 Teach the template parameter dependency checker used when matching
template parameter lists to scope specifiers for friend declarations
about injected class name types. Fixes the
g++.dg/template/memfriend5.C regression in the GCC testsuite.

llvm-svn: 131272
2011-05-13 00:34:01 +00:00
Alexis Hunt d9a5cc13cf Implement the __is_trivially_copyable type trait
llvm-svn: 131270
2011-05-13 00:31:07 +00:00
Alexis Hunt 1f69a02fb9 Implement defaulting of destructors.
llvm-svn: 131260
2011-05-12 22:46:29 +00:00
Alexis Hunt f9172946be Hrm
llvm-svn: 131259
2011-05-12 22:46:25 +00:00
Fariborz Jahanian cadf7c57ad After issuing diagnostics on circular protocol list,
don't build circular AST in protocol's protocol list 
when user code has introduced it. Indexer and other   
clients may crash. // rdar://9221614

llvm-svn: 131254
2011-05-12 22:04:39 +00:00
Alexis Hunt 5a7fa250ab Properly parse the 'default' and 'delete' keywords.
They are actually grammatically considered definitions and parsed
accordingly.

This fixes the outstanding bugs regarding defaulting functions after
their declarations.

We now really nicely diagnose the following construct (try it!)

int foo() = delete, bar;

Still todo: Defaulted functions other than default constructors
            Test cases (including for the above construct)

llvm-svn: 131228
2011-05-12 06:15:49 +00:00
Alexis Hunt f92197cf96 Make it so that we actually generate definitions for explicitly
defaulted default constructors.

As it happens, making sure that we handle out-of-line defaulted
functions properly will involved making sure that we actually parse them
correctly, so that's coming after.

llvm-svn: 131224
2011-05-12 03:51:51 +00:00
Alexis Hunt b315302bf9 Implement deletion of explicitly defaulted default constructors.
We still don't parse out-of-line defaults correctly, which is needed to
get the full effect out of this patch.

llvm-svn: 131223
2011-05-12 03:51:48 +00:00
Nick Lewycky 610128eba6 Fix crasher spotted in IWYU.
llvm-svn: 131222
2011-05-12 03:51:24 +00:00
Nick Lewycky 2da484f225 Fix typo in comment.
llvm-svn: 131212
2011-05-12 00:12:46 +00:00
Richard Smith 5e96d8328d Fix PR9902: correctly substitute alias templates within the template in which they are defined: provide an empty list of arguments for each containing template context during substitution.
llvm-svn: 131211
2011-05-12 00:06:17 +00:00
Douglas Gregor 347d626cf7 Implement CWG1170, which makes access-control errors into template
argument deduction failures. Only implemented in C++0x, since this is
a significant change in behavior from C++98/03.

llvm-svn: 131209
2011-05-11 23:45:11 +00:00
Douglas Gregor 373af9bc5d When checking for the necessary 'template<>' headers based on the
nested of an out-of-line declaration, only require a 'template<>'
header for each enclosing class template that hasn't been previously
specialized; previously, we were requiring 'template<>' for enclosing
class templates and members of class templates that hadn't been
previously specialized. Fixes <rdar://problem/9422013>.

llvm-svn: 131207
2011-05-11 23:26:17 +00:00
Alexis Hunt 466627ca2e Commit some missing changes to the previous patch.
This means we get C++0x jump-across-intializer semantics correct.

llvm-svn: 131204
2011-05-11 22:50:12 +00:00
Alexis Hunt ea6f0320f0 Implement implicit deletion of default constructors.
Yes, I'm aware that the diagnostics are awful.

Tests to follow.

llvm-svn: 131203
2011-05-11 22:34:38 +00:00
Francois Pichet b796b632a8 In Microsoft mode, allow conversion from pointer to integral type no matter what size the integral type is. Necessary to parse MFC code.
Example:
void f(char *ptr) {
  char var = (char)ptr;
}

llvm-svn: 131201
2011-05-11 22:13:54 +00:00
John McCall c67067f43e Teach CFG building how to deal with CXXMemberCallExprs and BoundMemberTy,
then teach -Wreturn-type to handle the same.  Net effect:  we now correctly
handle noreturn attributes on member calls in the CFG.

llvm-svn: 131178
2011-05-11 07:19:11 +00:00
Francois Pichet 3abc9b8b79 In Microsoft mode, allow pure specifier (=0) on inline functions declared at class scope.
This removes 2 errors when parsing MFC code with clang

Example:
class A {
    virtual void f() = 0 { }
}

llvm-svn: 131175
2011-05-11 02:14:46 +00:00
John McCall dfbf9341ad Use a heralded conversion to bool in inline-asm constraints.
llvm-svn: 131170
2011-05-10 23:39:47 +00:00
Alexis Hunt 80f00ff95d Re-do R131114 without breaking code.
I've edited one diagnostic which would print "copy constructor" for copy
constructors and "constructor" for any other constructor. If anyone is
extremely enamored with this, it can be reinstated with a simple boolean
flag rather than calling getSpecialMember, which is inappropriate.

llvm-svn: 131143
2011-05-10 19:08:14 +00:00
Douglas Gregor 972fe534ed Reimplement Sema::MatchTemplateParametersToScopeSpecifier() based on
the semantic context referenced by the nested-name-specifier rather
than the syntactic form of the nested-name-specifier. The previous
incarnation was based on my complete misunderstanding of C++
[temp.expl.spec]. The latest C++0x working draft clarifies the
requirements here, and this rewrite is intended to follow that.

Along the way, improve source location information in the
diagnostics. For example, if we report that a specific type needs or
doesn't need a 'template<>' header, we dig out that type in the
nested-name-specifier and highlight its range.

Fixes: PR5907, PR9421, PR8277, PR8708, PR9482, PR9668, PR9877, and
<rdar://problem/9135379>.

llvm-svn: 131138
2011-05-10 18:27:06 +00:00
Rafael Espindola 5fe6d35770 Revert 131114. This fixes PR9884.
llvm-svn: 131126
2011-05-10 14:12:22 +00:00
Alexis Hunt 6d5b96c6b3 Further implement defaulting constructors.
Focus is on default constructors for the time being. Currently the
exception specification and prototype are processed correctly. Codegen
might work but in all likelihood doesn't.

Note that due to an error, out-of-line defaulting of member functions is
currently impossible. It will continue to that until I muster up the
courage to admit that I secretly pray to epimetheus and that I need to
rework the way default gets from Parse -> Sema.

llvm-svn: 131115
2011-05-10 00:49:42 +00:00
Alexis Hunt be3f9ecd18 The last of the trivial constructor changes, make CXXSpecialMember
reflect our new, more accurate AST.

llvm-svn: 131114
2011-05-10 00:41:46 +00:00
Douglas Gregor 0f8bc97abd Ignore const/volatile/restrict qualifiers on anonymous structs and
unions. Fixes PR8326.

llvm-svn: 131109
2011-05-09 23:05:33 +00:00
Douglas Gregor 5d1d9e381e Extend the tag-ambiguity hack I committed in r130810 for tag
definitions to also include tag declarations. Fixes PR8151.

llvm-svn: 131102
2011-05-09 21:46:33 +00:00
Alexis Hunt 88c75c311f Clean up trivial default constructors now.
hasTrivialDefaultConstructor() really really means it now.

Also implement a fun standards bug regarding aggregates. Doug, if you'd
like, I can un-implement that bug if you think it is truly a defect.

The bug is that non-special-member constructors are never considered
user-provided, so the following is an aggregate:

struct foo {
  foo(int);
};

It's kind of bad, but the solution isn't obvious - should

struct foo {
  foo (int) = delete;
};

be an aggregate or not?

Lastly, add a missing initialization to FunctionDecl.

llvm-svn: 131101
2011-05-09 21:45:35 +00:00
Douglas Gregor a7203e537d When determining whether we need to instantiate a function type,
also consider whether any of the parameter types (as written, prior to
decay) are dependent. Fixes PR9880 and <rdar://problem/9408413>.

llvm-svn: 131099
2011-05-09 20:45:16 +00:00
Alexis Hunt f479f1b7e4 Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" and
modify the semantics slightly to accomodate default constructors (I
hope).

llvm-svn: 131087
2011-05-09 18:22:59 +00:00