Commit Graph

899 Commits

Author SHA1 Message Date
Douglas Gregor 7db3e95b0d When synthesizing an implicitly-defined copy or move constructor, or
when computing the exception specification of a copy or move constructor,
ignore non-static data member initializers. Fixes PR11418 /
<rdar://problem/10478642>.

llvm-svn: 145269
2011-11-28 20:03:15 +00:00
David Blaikie 0f65d59e52 Include named unions in union member init checking
llvm-svn: 144883
2011-11-17 06:01:57 +00:00
Eli Friedman 4134073c4b Compute whether a class is trivial correctly for template classes with an explicitly deleted or defaulted special member. PR11387.
llvm-svn: 144715
2011-11-15 22:39:08 +00:00
John McCall d5c98ae695 Resolve placeholder expressions before trying to deduce
'auto'.  Introduce a convenience method to make this a bit
easier, and use it elsewhere.

llvm-svn: 144605
2011-11-15 01:35:18 +00:00
Richard Smith ce40ad677e Represent an APValue based on a Decl as that Decl, rather than a DeclRefExpr
or MemberExpr which refers to it. As a side-effect, MemberExprs which refer to
static member functions and static data members are now emitted as constant
expressions.

llvm-svn: 144468
2011-11-12 22:28:03 +00:00
Richard Smith d62306a481 Constant expression evaluation: support for evaluation of structs and unions of
literal types, as well as derived-to-base casts for lvalues and
derived-to-virtual-base casts.

llvm-svn: 144265
2011-11-10 06:34:14 +00:00
Richard Smith ad45a8681d Some tests missed from r144056.
llvm-svn: 144060
2011-11-08 02:18:13 +00:00
Richard Smith eda3c84698 constexpr: static data members declared constexpr are required to have an
initializer; all other constexpr variables are merely required to be
initialized. In particular, a user-provided constexpr default constructor can be
used for such initialization.

llvm-svn: 144028
2011-11-07 22:16:17 +00:00
Douglas Gregor 5d1b4e3d1f When we notice that a member function is defined with "= delete" or "=
default", make a note of which is used when creating the
initial declaration. Previously, we would wait until later to handle
default/delete as a definition, but this is too late: when adding the
declaration, we already treated the declaration as "user-provided"
when in fact it was merely "user-declared".

Fixes PR10861 and PR10442, along with a bunch of FIXMEs.

llvm-svn: 144011
2011-11-07 20:56:01 +00:00
David Blaikie b06c68d320 Move tests to the appropriate directory to match the spec hierarchy.
llvm-svn: 143906
2011-11-07 03:27:58 +00:00
Eli Friedman 3ba20c1571 Make test work with ARM C++ ABI.
llvm-svn: 143425
2011-11-01 03:30:32 +00:00
Richard Smith 53cafabac0 Add test missed from r143234.
llvm-svn: 143257
2011-10-29 00:03:08 +00:00
Eli Friedman 64d9504b8f Compute the promoted integer type of fixed-width enums correctly. Found by inspection.
llvm-svn: 143021
2011-10-26 07:38:19 +00:00
Eli Friedman 3f37c1ce4c Correctly perform integral promotions on wchar_t/char16_t/char32_t in C++. <rdar://problem/10309088>.
llvm-svn: 143019
2011-10-26 07:22:48 +00:00
David Blaikie dd58d4ca8f Handle redundant 'typename' on base class specifications.
llvm-svn: 142937
2011-10-25 18:46:41 +00:00
David Blaikie afa155fb88 Fix erroneous name-specifiers prior to decltypes better/correctly as per Doug's feedback.
llvm-svn: 142935
2011-10-25 18:17:58 +00:00
David Blaikie 1cd50022b2 Fix cases where the optional nested-name-specifier erroneously preceeded a decltype-specification when specifying a base type.
llvm-svn: 142928
2011-10-25 17:10:12 +00:00
David Blaikie 00ee7a081d Support the use of decltype for specifying base types. Fixes PR11216.
llvm-svn: 142926
2011-10-25 15:01:20 +00:00
Douglas Gregor baabbb779d Undo unnecessary change
llvm-svn: 142907
2011-10-25 03:47:25 +00:00
Douglas Gregor ab6bc1d13e Make the -Wc++11-compat warnings ignored by default, so we don't break
valid C++98/03 code. However, add these warnings to -Wall, for those
who obviously already like clean code.

llvm-svn: 142903
2011-10-25 03:07:45 +00:00
Peter Collingbourne 7d33cd3a2f Fix grammar for C++11 alignment specifiers, and add a few FIXMEs.
llvm-svn: 142760
2011-10-23 20:07:52 +00:00
Peter Collingbourne 9f58d7b789 Diagnose unexpanded parameter packs in member initialisers (including
in-class member initialisers).

llvm-svn: 142758
2011-10-23 18:59:44 +00:00
Peter Collingbourne e109a2ca59 Attach class template attributes to the templated CXXRecordDecl,
instead of silently discarding them.

As a side effect, this improves diagnostics for constexpr class
templates slightly.

llvm-svn: 142755
2011-10-23 17:07:16 +00:00
Peter Collingbourne 99eddc3d92 Permit auto SCS on parameter declarations, C++03 [dcl.stc]p2
llvm-svn: 142649
2011-10-21 11:55:09 +00:00
Richard Smith fe2750db42 Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-POD
but trivially constructible and destructible variables in C++11 mode. Also
incidentally improve the precision of the wording for jump diagnostics in C++98
mode.

llvm-svn: 142619
2011-10-20 21:42:12 +00:00
Richard Smith f411196d15 'extern template' is a C++11 feature. Add an Extension for C++98 (this matches
gcc's behaviour), and a -Wc++98-compat-pedantic warning for C++11.

llvm-svn: 142597
2011-10-20 18:35:58 +00:00
David Blaikie 651c73ce78 Fix pr9789, assert-on-invalid while instantiating an (invalid) class template with a non-final parameter pack. Also improve the warning for non-final parameter packs in this scenario so it only fires once, rather than once for every template parameter after the non-final parameter pack.
llvm-svn: 142473
2011-10-19 05:19:50 +00:00
Richard Smith aed32b4d8c Simplify RecordDeclCXX::setBases slightly. No functional change.
Add test that a variadic base list which expands to 0 bases doesn't make the
class a non-aggregate. This test passed before the change, too.

llvm-svn: 142411
2011-10-18 20:08:55 +00:00
Richard Smith c30493db3c In C++11, a class's members are allowed to be nominated as friends.
llvm-svn: 142393
2011-10-18 18:33:57 +00:00
David Blaikie cc5f8f0d9e Switch to the C++11 warning flags in tests.
Patch by Ahmed Charles!

llvm-svn: 142340
2011-10-18 05:54:07 +00:00
John McCall 4124c4924d Teach the ARC compiler to not require __bridge casts when
passing/receiving CF objects at +0 to/from Objective-C methods
or audited C functions.

llvm-svn: 142219
2011-10-17 18:40:02 +00:00
Douglas Gregor 7e1aa5b7ac Don't try to diagnose anything when we're passing incomplete types
through varargs. This only happens when we're in an unevaluated
context, where we don't want to trigger an error anyway. Fixes PR11131
/ <rdar://problem/10288375>.

llvm-svn: 141986
2011-10-14 20:34:19 +00:00
Richard Smith 465841e48c [temp.explicit]p1: constexpr cannot be specified in explicit instantiations.
llvm-svn: 141982
2011-10-14 19:58:02 +00:00
Richard Smith 9ca5c42582 Update all tests other than Driver/std.cpp to use -std=c++11 rather than
-std=c++0x. Patch by Ahmed Charles!

llvm-svn: 141900
2011-10-13 22:29:44 +00:00
Douglas Gregor cda2270217 Allow calling an overloaded function set by taking the address of the
functions, e.g., (&f)(0). Fixes <rdar://problem/9803316>.

llvm-svn: 141877
2011-10-13 18:10:35 +00:00
Douglas Gregor ebcfbb5d22 When we determine that a function template specialization produced as
part of template argument deduction is ill-formed, we mark it as
invalid and treat it as a deduction failure. If we happen to find that
specialization again, treat it as a deduction failure rather than
silently building a call to the declaration.

Fixes PR11117, a marvelous bug where deduction failed after creating
an invalid specialization, causing overload resolution to pick a
different candidate. Then we performed a similar overload resolution
later, and happily picked the invalid specialization to
call... resulting in a silent link failure.

llvm-svn: 141809
2011-10-12 20:35:48 +00:00
Douglas Gregor 205d044552 Switch diagnostic text from "C++0x" over to "C++11".
We'd also like for "C++11" or "c++11" to be used for the warning
groups, but without removing the old warning flags. Patches welcome;
I've run out of time to work on this today.

llvm-svn: 141801
2011-10-12 19:26:40 +00:00
Richard Smith fd53aaf7e7 constexpr: don't consider class types with mutable members to be literal types.
The standard doesn't allow this, but mutable constexpr variables break the
semantics so badly that we can't reasonably accept them.

llvm-svn: 141768
2011-10-12 05:08:15 +00:00
John McCall 50a2c2c19d Catch placeholder types in DefaultLvalueConversion
and DefaultFunctionArrayLvalueConversion.  To prevent
significant regression for should-this-be-a-call fixits,
and to repair some such regression from the introduction of
bound member placeholders, make those placeholder checks
try to build calls appropriately.  Harden the build-a-call
logic while we're at it.

llvm-svn: 141738
2011-10-11 23:14:30 +00:00
Alexis Hunt 77c1f9f888 Get rid of ShouldDeleteMoveConstructor.
llvm-svn: 141650
2011-10-11 06:43:29 +00:00
Alexis Hunt 1bc6f71ebc Consolidate copy constructor deletion into ShouldDeleteSpecialMember.
llvm-svn: 141645
2011-10-11 04:55:36 +00:00
Douglas Gregor ab96bcf6ea When substituting into a sizeof parameter pack expression in a context
where we can't expand (i.e., multi-level substitution), be sure to
substitute the pack with its level-reduced pack. Fixes PR10230.

llvm-svn: 141568
2011-10-10 18:59:29 +00:00
Douglas Gregor 556e5860f9 Per C++ [class.bit]p2, unnamed bit-fields are not members. Fixes PR10289.
llvm-svn: 141549
2011-10-10 17:22:13 +00:00
Richard Smith f368fb40df constexpr: Disable checking of constructor member initializer lists for
constexpr constructor templates. Such checking is optional, and currently hard
to get right since clang doesn't generate implicit member initializers until
instantiation (even for non-dependent members).

This is needed for clang to accept libstdc++ from g++4.6 in c++0x mode.

llvm-svn: 141547
2011-10-10 16:38:04 +00:00
Douglas Gregor b06fa540e8 When adding a direct initializer to a declaration, allow the
initializer to update the type of the declaration. For example, this
allows us to determine the size of an incomplete array from its
initializer. Fixes PR10288.

llvm-svn: 141543
2011-10-10 16:05:18 +00:00
Douglas Gregor 877d4ebba4 Always add the built-in overload candidates for operators &&, ||, and
!. Fixes PR9865.

llvm-svn: 141537
2011-10-10 14:05:31 +00:00
Alexis Hunt d6da876bac Begin work consolidating ShouldDelete* functions.
Begin with just default constructors. One note is that as a side effect
of this, a conformance test was removed on the basis that this is almost
certainly a defect as with most of union initialization. As it is, clang
does not implement union initialization close to the standard as it's
quite broken as written. I hope to write a paper addressing the issues
eventually.

llvm-svn: 141528
2011-10-10 06:18:57 +00:00
Douglas Gregor 16e65616d6 Implement the restrictions in C++ [class.friend]p6, which disallow
defining a friend function with a qualified name or in a local
class. Fixes PR9853. 

llvm-svn: 141524
2011-10-10 01:11:59 +00:00
Douglas Gregor 56636589ff The effective context of a friend function is its lexical
context. Fixes PR9103.

llvm-svn: 141520
2011-10-09 22:38:36 +00:00
Douglas Gregor 0c83c8128b Per the note in C++0x [temp.deduct.call]p4, don't attempt template
argument deduction against a function parameter that has no deducible
template parameters in it. Fixes PR8598.

llvm-svn: 141517
2011-10-09 22:06:46 +00:00