Commit Graph

503 Commits

Author SHA1 Message Date
Douglas Gregor db8c6fd18f Check that an overloaded function name, when used by the ! operator,
actually resolves to a particular function. Fixes PR8181, from Faisal
Vali!

llvm-svn: 114331
2010-09-20 17:13:33 +00:00
Douglas Gregor 009f69979a When dealing with an anonymous enumeration declared in function
prototype scope, temporarily set the context of the enumeration
declaration to the translation unit. We do the same thing for
parameters, until we have an actual function declaration on which to
hang them. Fixes <rdar://problem/8435682>.

There is more work to do in this area, since we have existing bugs
with tags being declared/defined in function parameter lists. This fix
is correct, and we'll end up extending it when we deal with those
existing bugs.

llvm-svn: 114135
2010-09-16 23:58:57 +00:00
Abramo Bagnara 6a0c4097f1 Parentheses around address non-type template argument is demoted to an extension warning.
llvm-svn: 113739
2010-09-13 06:06:58 +00:00
Douglas Gregor 6162334ce0 Diagnose the instantiation of variables (including static data
members) with function type. Fixes PR8047.

llvm-svn: 113723
2010-09-12 07:37:24 +00:00
Douglas Gregor 8ce63154d0 When diagnosing C++ [temp.expl.spec]p3 in C++98/03 mode, downgrade the
error to a warning if we're in a case that would be allowed in
C++0x. This "fixes" PR8084 by making Clang accept more code than GCC
and (non-strict) EDG do. 

Also, add the missing test case for the C++0x semantics, which should
have been in r113717.

llvm-svn: 113718
2010-09-12 05:24:55 +00:00
Douglas Gregor 2bbc0266e0 Implement the "note" in C++ [over.built]p1, which is actually meant to
be a semantic requirement that a built-in overloaded operator is not
added to the overload set of there is already a user-defined
overloaded operator with the same parameter types. Fixes PR8087.

llvm-svn: 113713
2010-09-12 04:28:07 +00:00
Sebastian Redl a8bac37bb1 Test destructors in delete expressions and of temporaries for throwing.
llvm-svn: 113664
2010-09-10 23:27:10 +00:00
Sebastian Redl b8a76c42b5 Address Doug's comments.
llvm-svn: 113650
2010-09-10 22:34:40 +00:00
Sebastian Redl e56be2f72c Eli helped me understand how evaluation contexts work.
llvm-svn: 113642
2010-09-10 21:57:27 +00:00
Sebastian Redl 8c40ba392c Test CXXNoexceptExpr codegen and serialization.
llvm-svn: 113630
2010-09-10 21:04:03 +00:00
Sebastian Redl 4fa4a6b85e Add another small test case.
llvm-svn: 113628
2010-09-10 21:03:58 +00:00
Sebastian Redl dbd14bdefc Tests for noexcept in templates.
llvm-svn: 113625
2010-09-10 20:55:50 +00:00
Sebastian Redl 5f0180d815 First version of a testcase, plus fixes.
llvm-svn: 113624
2010-09-10 20:55:47 +00:00
Chris Lattner d7ff9f91bf remove curly quotes, patch by Dimitry Andric!
llvm-svn: 113156
2010-09-06 17:52:29 +00:00
Chris Lattner 7f2c7f4ef3 "const std::vector<int>*" not "std::vector<int> const*"
llvm-svn: 113094
2010-09-05 00:27:00 +00:00
Chris Lattner 24b89469ac 'const std::type_info*' instead of 'std::type_info const*'
llvm-svn: 113092
2010-09-05 00:17:29 +00:00
Chris Lattner 53fa04909c make clang print types as "const int *" instead of "int const*",
which is should have done from the beginning.  As usual, the most
fun with this sort of change is updating all the testcases.

llvm-svn: 113090
2010-09-05 00:04:01 +00:00
Chandler Carruth 9bb67f4d1a Allow anonymous and local types. The support was already in place for these,
but this makes them work even as an extension in C++98. This resolves PR8077.

llvm-svn: 113011
2010-09-03 21:12:34 +00:00
John McCall 417e74491c Add a quick-and-dirty hack to give a better diagnostic for [class.protected]
restrictions.  The note's not really on the right place given its wording,
but putting a second note on the call site (or muddying the wording) doesn't
appeal.

There are corner cases where this can be wrong, but I'm not concerned.

llvm-svn: 112950
2010-09-03 04:56:05 +00:00
Sebastian Redl bd59576541 Make inline namespace not be transparent after all. The concept simply doesn't fit. Instead, special-case the few places where transparent contexts have the desired behavior for inline namespaces. Fixes a redeclaration issue in inline namespaces.
llvm-svn: 112637
2010-08-31 20:53:31 +00:00
Chandler Carruth fc0e2a03fa Fix a regression that allowed clearly ill formed code. The diagnostic is still
terrible, FIXME left to do a proper job of diagnosing this.

llvm-svn: 112581
2010-08-31 05:42:40 +00:00
Sebastian Redl 5a5f2c76b6 Enable inline namespaces in C++03 as an extension.
llvm-svn: 112566
2010-08-31 00:36:45 +00:00
Sebastian Redl 35034569c7 Add a forgotten place where the enclosing namespace set matters, plus a big testcase for inline namespace fun.
llvm-svn: 112565
2010-08-31 00:36:40 +00:00
Sebastian Redl b5c2baa2d7 Enable inline namespaces in the AST.
llvm-svn: 112564
2010-08-31 00:36:36 +00:00
Douglas Gregor 4afc236cee When instantiating a function type, instantiate the return type before
instantiating the parameters. In a perfect world, this wouldn't
matter, and compilers are free to instantiate in any order they
want. However, every other compiler seems to instantiate the return
type first, and some code (in this case, Boost.Polygon) depends on
this and SFINAE to avoid instantiating something that shouldn't be
instantiated.

We could fight this battle, and insist that Clang is allowed to do
what it does, but it's not beneficial: it's more predictable to
instantiate this way, in source order. When we implement
late-specified return types, we'll need to instantiate the return type
last when it was late-specified, hence the FIXME.

We now compile Boost.Polygon properly.

llvm-svn: 112561
2010-08-31 00:26:14 +00:00
Douglas Gregor 66d2c8e886 Perform the function-to-pointer adjustment during template argument
deduction where the parameter is a function reference, function
pointer, or member function pointer and the argument is an overloaded
function. Fixes <rdar://problem/8360106>, a template argument
deduction issue found by Boost.Filesystem.

llvm-svn: 112523
2010-08-30 21:04:23 +00:00
Douglas Gregor cfcb942267 Add test case from PR6952, which now works (thanks to Gabor).
llvm-svn: 112477
2010-08-30 14:37:53 +00:00
Douglas Gregor 2c7d9290ee Add redeclaration checking for static data members and fix a corner
case with redeclaration checking for fields, from Faisal Vali!
Fixes PR7970.

llvm-svn: 112476
2010-08-30 14:32:14 +00:00
John McCall 1177ff1740 That's not the right direction to compute notional accessibility in at all.
llvm-svn: 112360
2010-08-28 08:47:21 +00:00
John McCall 96329678e4 When checking access control for an instance member access on
an object of type I, if the current access target is protected
when named in a class N, consider the friends of the classes P
where I <= P <= N and where a notional member of N would be
non-forbidden in P.

llvm-svn: 112358
2010-08-28 07:56:00 +00:00
Sebastian Redl 6766794c0b Parser support for inline namespaces
llvm-svn: 112320
2010-08-27 23:12:46 +00:00
Chandler Carruth cfe41db403 Support explicit instantiation of function templates and members of class
templates when only the declaration is in scope. This requires deferring the
instantiation to be lazy, and ensuring the definition is required for that
translation unit. We re-use the existing pending instantiation queue,
previously only used to track implicit instantiations which were required to be
lazy. Fixes PR7979.

A subsequent change will rename *PendingImplicitInstantiations to
*PendingInstatiations for clarity given its broader role.

llvm-svn: 112037
2010-08-25 08:27:02 +00:00
John McCall 7d46051eea Catch the case of trying to turn '&(X::a)' into a member pointer as well.
llvm-svn: 111997
2010-08-24 23:26:21 +00:00
John McCall 24d189484b When trying to resolve the address of an overloaded expression,
only form pointers-to-member if the expression has the appropriate
form.  This avoids assertions later on on invalid code, but also
allows us to properly resolve mixed-staticity overloads.

llvm-svn: 111987
2010-08-24 22:52:39 +00:00
Douglas Gregor f0f8369912 Diagnose the presence of multiple initializations of static data
members, from Faisal Vali! Fixes PR6904.

llvm-svn: 111900
2010-08-24 05:27:49 +00:00
Douglas Gregor 5be1eb8daf Revert r111609, which is failing its new test.
llvm-svn: 111611
2010-08-20 03:26:10 +00:00
John McCall a189f2eb0a Detect efforts to declare a template member friend and explicitly ignore them.
Avoids a crash.

llvm-svn: 111609
2010-08-20 01:40:01 +00:00
John McCall bd8062dff1 Work around a crash when checking access to injected class names
qua templates.  The current fix suppresses the access check entirely
in this case;  to do better, we'd need to be able to say that a
particular lookup result came from a particular injected class name,
which is not easy to do with the current representation of LookupResult.
This is on my known-problems list.

llvm-svn: 111009
2010-08-13 07:02:08 +00:00
John McCall dcc7140f86 Perform access control when template lookup finds a class template.
This is *really* hacky.

llvm-svn: 110997
2010-08-13 02:23:42 +00:00
Douglas Gregor 13e6587313 If name lookup finds different type declarations in different scopes
that actually refer to the same underlying type, it is not an
ambiguity; add uniquing support based on the canonical type of type
declarations. Fixes <rdar://problem/8296180>.

llvm-svn: 110806
2010-08-11 14:45:53 +00:00
Douglas Gregor 836a7e8468 Improve our handling of user-defined conversions when computing
implicit conversion sequences. In particular, model the "standard
conversion" from a class to its own type (or a base type) directly as
a standard conversion in the normal path *without* trying to determine
if there is a valid copy constructor. This appears to match the intent
of C++ [over.best.ics]p6 and more closely matches GCC and EDG.

As part of this, model non-lvalue reference initialization via
user-defined conversion in overloading the same way we handle it in
InitializationSequence, separating the "general user-defined
conversion" and "conversion to compatible class type" cases.

The churn in the overload-call-copycon.cpp test case is because the
test case was originally wrong; it assumed that we should do more
checking for copy constructors that we actually should, which affected
overload resolution.

Fixes PR7055. Bootstrapped okay.

llvm-svn: 110773
2010-08-11 02:15:33 +00:00
Douglas Gregor 2588691a69 Diagnose the use of "inline" on block-scope function declarations in
C++, from Andrea Nall!

llvm-svn: 110439
2010-08-06 11:44:10 +00:00
Eli Friedman a170cd6257 Get rid of isObjectType; when C++ says "object type", it generally
just means "not a function type", not "not a function type or void". This
changes behavior slightly, but generally in a way which accepts more code.

llvm-svn: 110303
2010-08-05 02:49:48 +00:00
Sebastian Redl 29ce472c17 Drop an unjustified limitation from Type::isObjectType(). Fixes PR7801 and doesn't seem to break anything.
llvm-svn: 110295
2010-08-05 01:21:19 +00:00
John McCall 3faf1cf3ea Add a test case for P%7346, which was fixed by not doing the operator
delete lookup until the end of the class definition.

llvm-svn: 110176
2010-08-04 01:07:02 +00:00
John McCall deb646ebb5 Only look up an 'operator delete' on the definition of a destructor, not on
a declaration.

llvm-svn: 110175
2010-08-04 01:04:25 +00:00
John McCall 66a8759400 Look through using declarations when deciding whether to use an operator
delete for a virtual destructor.  Diagnose ambiguities.

Fixes PR7803.

llvm-svn: 110173
2010-08-04 00:31:26 +00:00
John McCall 796c2a52a9 Treat template parameters as part of the declaration-specifiers for the
purpose of access control.  Fixes PR7644.

I can't actually find anything directly justifying this, but it seems obvious.

llvm-svn: 108521
2010-07-16 08:13:16 +00:00
Douglas Gregor eebe72199e When determining whether an overload set with explicit template
arguments only resolves to a single specialization, make sure to look
through using declarations. Fixes PR7641.

llvm-svn: 108376
2010-07-14 23:20:53 +00:00
Douglas Gregor a700f68828 Reinstate the optimization suppressing available_externally functions
at -O0. The only change from the previous patch is that we don't try
to generate virtual method thunks for an available_externally
function.

llvm-svn: 108230
2010-07-13 06:02:28 +00:00