Commit Graph

468 Commits

Author SHA1 Message Date
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
Douglas Gregor 553f3a9b30 Speculatively revert r108156; it appears to be breaking self-host.
llvm-svn: 108194
2010-07-12 21:08:32 +00:00
Douglas Gregor dbb2806a7b Do not generate LLVM IR for available_externally function bodies at
-O0, since we won't be using the definitions for anything anyway. For
lib/System/Path.o when built in Debug+Asserts mode, this leads to a 4%
improvement in compile time (and suppresses 440 function bodies).

<rdar://problem/7987644>

llvm-svn: 108156
2010-07-12 17:24:55 +00:00
John McCall b5081aff68 Apparently the {{$}} hack doesn't work on Windows; I am saddened but not
surprised.

llvm-svn: 107874
2010-07-08 13:17:29 +00:00
John McCall be349def4b Mark calls to 'throw()' functions as nounwind, and mark the functions nounwind
as well.

llvm-svn: 107858
2010-07-08 06:48:12 +00:00
Douglas Gregor 747eb7840a Reinstate the fix for PR7556. A silly use of isTrivial() was
suppressing copies of objects with trivial copy constructors.

llvm-svn: 107857
2010-07-08 06:14:04 +00:00
Douglas Gregor e182370eda Revert r107828 and r107827, the fix for PR7556, which seems to be
breaking bootstrap on Linux.

llvm-svn: 107837
2010-07-07 23:37:33 +00:00
Sebastian Redl a771d2239d Rip out the C++0x-specific handling of destructor names. The specification is still in flux and unclear, and our interim workaround was broken. Fixes PR7467.
llvm-svn: 107835
2010-07-07 23:17:38 +00:00
Douglas Gregor 1d9ef840fa A using declaration can redeclare a typedef to the same type. These
typedefs won't have the same canonical declaration (since they are
distinct), so we need to check for this case specifically. Fixes
<rdar://problem/8018262>.

llvm-svn: 107833
2010-07-07 23:08:52 +00:00
Douglas Gregor 442612c285 Do not use CXXZeroValueInitExpr for class types. Instead, use
CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as
appropriate. Fixes PR7556, and provides a slide codegen improvement
when copy-initializing a POD class type from a value-initialized
temporary. Previously, we weren't eliding the copy.

llvm-svn: 107827
2010-07-07 22:35:13 +00:00
John McCall bd30929e4d Validated by nightly-test runs on x86 and x86-64 darwin, including after
self-host.  Hopefully these results hold up on different platforms.  

I tried to keep the GNU ObjC runtime happy, but it's hard for me to test.
Reimplement how clang generates IR for exceptions.  Instead of creating new
invoke destinations which sequentially chain to the previous destination,
push a more semantic representation of *why* we need the cleanup/catch/filter
behavior, then collect that information into a single landing pad upon request.

Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional
control flow) are generated, since it's actually fairly closely tied in with
the former.  Remove the need to track which cleanup scope a block is associated
with.

Document a lot of previously poorly-understood (by me, at least) behavior.

The new framework implements the Horrible Hack (tm), which requires every
landing pad to have a catch-all so that inlining will work.  Clang no longer
requires the Horrible Hack just to make exceptions flow correctly within
a function, however.  The HH is an unfortunate requirement of LLVM's EH IR.

llvm-svn: 107631
2010-07-06 01:34:17 +00:00
Douglas Gregor 6d880b1a83 Provide exception specifications for implicitly-declared default constructors.
llvm-svn: 107437
2010-07-01 22:31:05 +00:00
Douglas Gregor 8453ddb5fe Provide exception specifications for implicitly-declared copy constructors.
llvm-svn: 107429
2010-07-01 20:59:04 +00:00
Douglas Gregor 19ecba740f Test implicit declaration of copy assignment operator with non-const argument
llvm-svn: 107421
2010-07-01 20:08:52 +00:00
Douglas Gregor cfe682274c Teach DeclareImplicitCopyConstructor how to cope with virtual bases
and multi-dimensional array fields. Fixes several bugs found by
inspection.

llvm-svn: 107411
2010-07-01 18:27:03 +00:00
Douglas Gregor 68e1136585 Provide an exception-specification for an implicitly-declared
copy-assignment operator.

llvm-svn: 107406
2010-07-01 17:48:08 +00:00
Douglas Gregor 2f3d9e8264 Add Sema test case for exception-specifiers implicitly added to destructors.
llvm-svn: 107395
2010-07-01 14:21:35 +00:00
Douglas Gregor a343430e00 Add test case that I forgot to commit with r107354 (the implementation
of C++ DR481). 

llvm-svn: 107359
2010-07-01 00:21:50 +00:00
Daniel Dunbar 8452ef0798 tests: Use %clangxx when using driver for C++, in case C++ support is disabled.
llvm-svn: 107153
2010-06-29 16:52:24 +00:00
Chandler Carruth 2d69ec7a72 Partial fix for PR7267 based on comments by John McCall on an earlier patch.
This is more targeted, as it simply provides toggle actions for the parser to
turn access checking on and off. We then use these to suppress access checking
only while we parse the template-id (included scope specifier) of an explicit
instantiation and explicit specialization of a class template. The
specialization behavior is an extension, as it seems likely a defect that the
standard did not exempt them as it does explicit instantiations.

This allows the very common practice of specializing trait classes to work for
private, internal types. This doesn't address instantiating or specializing
function templates, although those apparently already partially work.

The naming and style for the Action layer isn't my favorite, comments and
suggestions would be appreciated there.

llvm-svn: 106993
2010-06-28 08:39:25 +00:00
Benjamin Kramer 9aa0d39443 A bug I've introduced in STDIN handling surfaced a few broken tests, fix them.
Lexer/hexfloat.cpp is now XFAIL'd, I'd appreciate if someone could look into it.

llvm-svn: 106840
2010-06-25 12:48:07 +00:00
Douglas Gregor 010815a20b Downgrade the error when using a typedef in the nested-name-specifier
of an explicit instantiation to an ExtWarn, since nobody else seems to
diagnose this problem.

llvm-svn: 106109
2010-06-16 16:26:47 +00:00
John McCall e9cccd86da Fix a point of semantics with using declaration hiding: method templates
introduced by using decls are hidden even if their template parameter lists
or return types differ from the "overriding" declaration.

Propagate using shadow declarations around more effectively when looking up
template-ids.  Reperform lookup for template-ids in member expressions so that
access control is properly set up.

Fix some number of latent bugs involving template-ids with totally invalid
base types.  You can only actually get these with a scope specifier, since
otherwise the template-id won't parse as a template-id.

Fixes PR7384.

llvm-svn: 106093
2010-06-16 08:42:20 +00:00
Sebastian Redl c3eba8f547 Commit my WIP on constexpr support. This commit: an XFAILed test and treating constexpr as a top-level const.
llvm-svn: 105752
2010-06-09 21:19:43 +00:00
Jeffrey Yasskin caa710dfd2 PR7245: Make binding a reference to a temporary without a usable copy
constructor into an extension warning into the error that C++98 requires.

llvm-svn: 105529
2010-06-07 15:58:05 +00:00
Jeffrey Yasskin 2f96e9f5c9 Add an extension to avoid an error when a global template has the same name as
a member template, and you try to call the member template with an explicit
template argument.  See PR7247 

For example, this downgrades the error to a warning in:

template<typename T> struct set{};
struct Value {
    template<typename T>
    void set(T value) {
    }
};
void foo() {
    Value v;
    v.set<double>(3.2);  // Warning here.
}

llvm-svn: 105518
2010-06-05 01:39:57 +00:00
Douglas Gregor 2e87ca218f When checking for equality of template parameter lists, a template
type parameter pack is distinct from a template type parameter.

llvm-svn: 105464
2010-06-04 08:34:32 +00:00
Douglas Gregor 71b209dea6 Properly disambiguate between an elaborated-type-specifier and a
type-parameter within a template parameter list. Found by inspection. 

llvm-svn: 105462
2010-06-04 07:30:15 +00:00
Eli Friedman 91a3d27ec0 Make sure to check the accessibility of and mark the destructor for the
operand of a throw expression.  Fixes PR7281.

llvm-svn: 105408
2010-06-03 20:39:03 +00:00
Jeffrey Yasskin c9b9bdcc20 There is no dcl.init.ref p16. This test deals with p5.
llvm-svn: 105351
2010-06-02 22:01:22 +00:00
John McCall f24d7bbbcd A more minimal fix for PR6762.
llvm-svn: 104991
2010-05-28 18:45:08 +00:00
John McCall 61d8258fa3 Roll back r104941.
llvm-svn: 104990
2010-05-28 18:25:28 +00:00
John McCall 2177a9b65a Add a new attribute on records, __attribute__((adl_invisible)), and define
the x86-64 __va_list_tag with this attribute.  The attribute causes the
affected type to behave like a fundamental type when considered by ADL.

(x86-64 is the only target we currently provide with a struct-based
__builtin_va_list)

Fixes PR6762.

llvm-svn: 104941
2010-05-28 08:20:36 +00:00
John McCall cd4b3ba316 Test case for r104938.
llvm-svn: 104939
2010-05-28 06:14:52 +00:00
Douglas Gregor ed2540d205 When we complain about a member being inaccessible due to a constraint
along an access path, add another note pointing at the member we
actually found.

llvm-svn: 104937
2010-05-28 04:34:55 +00:00
John McCall 4583186b8b When filtering out previous declarations of friend functions, consider the
lookup context, not the direct semantic context.  Fixes PR7230.

llvm-svn: 104917
2010-05-28 01:41:47 +00:00