Commit Graph

449 Commits

Author SHA1 Message Date
Douglas Gregor bddb73fa1d If a destructor is referenced or a pseudo-destructor expression is
formed without a trailing '(', diagnose the error (these expressions
must be immediately called), emit a fix-it hint, and fix the code.

llvm-svn: 81015
2009-09-04 18:29:40 +00:00
Douglas Gregor ad8a336b40 Implement AST, semantics, and CodeGen for C++ pseudo-destructor
expressions, e.g.,

  p->~T()

when p is a pointer to a scalar type. 

We don't currently diagnose errors when pseudo-destructor expressions
are used in any way other than by forming a call.

llvm-svn: 81009
2009-09-04 17:36:40 +00:00
Douglas Gregor 119b0c7185 Introduce an egregious hack to fix PR4828.
The problem this change addresses is that we treat __is_pod and
__is_empty as keywords in C++, because they are built-in type traits
in GCC >= 4.3. However, GNU libstdc++ 4.2 (and possibly earlier
versions) define implementation-detail struct templates named __is_pod
and __is_empty. 

This commit solves the problem by recognizing

  struct __is_pod

and

  struct __is_empty

as special token sequences. When one of these token sequences is
encountered, the keyword (__is_pod or __is_empty) is implicitly
downgraded to an identifier so that parsing can continue. This is an
egregious hack, but it has the virtue of "just working" whether
someone is using libstdc++ 4.2 or not, without the need for special
flags.

llvm-svn: 80988
2009-09-04 05:53:02 +00:00
Douglas Gregor 2b6ca46c6b Improve template instantiation for member access expressions that
involve qualified names, e.g., x->Base::f. We now maintain enough
information in the AST to compare the results of the name lookup of
"Base" in the scope of the postfix-expression (determined at template
definition time) and in the type of the object expression.

llvm-svn: 80953
2009-09-03 21:38:09 +00:00
Fariborz Jahanian 3501bcec7d Issue diagnostics in variety of situations involving
reference/const data members when user has declared
the constructor. This necessitated some non-minor
refactoring.

llvm-svn: 80934
2009-09-03 19:36:46 +00:00
Douglas Gregor c26e0f626b Improved handling for dependent, qualified member access expressions, e.g.,
t->Base::f

where t has a dependent type. We save the nested-name-specifier in the
CXXUnresolvedMemberExpr then, during instantiation, substitute into
the nested-name-specifier with the (transformed) object type of t, so
that we get name lookup into the type of the object expression.

Note that we do not yet retain information about name lookup into the
lexical scope of the member access expression, so several regression
tests are still disabled.

llvm-svn: 80925
2009-09-03 16:14:30 +00:00
Douglas Gregor b7bfe79412 Rewrite of our handling of name lookup in C++ member access expressions, e.g.,
x->Base::f

We no longer try to "enter" the context of the type that "x" points
to. Instead, we drag that object type through the parser and pass it
into the Sema routines that need to know how to perform lookup within
member access expressions.

We now implement most of the crazy name lookup rules in C++
[basic.lookup.classref] for non-templated code, including performing
lookup both in the context of the type referred to by the member
access and in the scope of the member access itself and then detecting
ambiguities when the two lookups collide (p1 and p4; p3 and p7 are
still TODO). This change also corrects our handling of name lookup
within template arguments of template-ids inside the
nested-name-specifier (p6; we used to look into the scope of the
object expression for them) and fixes PR4703.

I have disabled some tests that involve member access expressions
where the object expression has dependent type, because we don't yet
have the ability to describe dependent nested-name-specifiers starting
with an identifier.

llvm-svn: 80843
2009-09-02 22:59:36 +00:00
John McCall 2dc078f24e Ensure that the tag decls of friend decls aren't added to the friending class's
decl list, and remove some workarounds that were due to this.  Thanks to Eli for
pointing this out and providing the test case.

llvm-svn: 80745
2009-09-02 00:55:30 +00:00
Douglas Gregor 810f7a9d95 Move C++ test over to CodeGenCXX, since it requires CodeGen to reproduce
llvm-svn: 80672
2009-09-01 15:39:05 +00:00
Douglas Gregor 522fbc4969 Support explicit C++ member operator syntax, from James Porter!
llvm-svn: 80608
2009-08-31 19:52:13 +00:00
Anders Carlsson b533df02b5 More missing member goodness.
llvm-svn: 80491
2009-08-30 07:09:50 +00:00
Anders Carlsson 0d2a51b61f Improve missing error messages as suggested by Doug.
llvm-svn: 80489
2009-08-30 06:49:43 +00:00
Anders Carlsson 5167a4644d Use DiagnoseMissingMember for UsingDecls.
llvm-svn: 80470
2009-08-30 00:58:45 +00:00
Anders Carlsson 896c230a19 Improve diagnostics for missing members. This renames the err_typecheck_no_member to err_typecheck_no_member_deprecated. The idea is that err_typecheck_no_member_deprecated should be phased out and any call sites that reference it should call DiagnoseMissingMember instead.
llvm-svn: 80469
2009-08-30 00:54:35 +00:00
Eli Friedman 2624be4fd4 Fix a couple issues with parsing invalid nested-name-specifiers.
llvm-svn: 80421
2009-08-29 04:08:08 +00:00
Anders Carlsson 938b10079a CreateDeclRefExprs that point to UnresolvedUsingDecls.
llvm-svn: 80413
2009-08-29 01:06:32 +00:00
Anders Carlsson a884e67485 Add another check for UnresolvedUsingDecl.
llvm-svn: 80412
2009-08-29 00:56:38 +00:00
Douglas Gregor 90820ee62a Make sure we actually found a redeclaration before complaining about attributes added to a redeclaration in C++
llvm-svn: 80403
2009-08-28 22:54:55 +00:00
Anders Carlsson 01ff6d7094 Check for UnresolvedUsingDecl when determining if a declaration is a redeclaration or not.
llvm-svn: 80383
2009-08-28 17:57:07 +00:00
Anders Carlsson d20e795a5b Fix this for real.
llvm-svn: 80377
2009-08-28 16:57:08 +00:00
Anders Carlsson f2bc7c386e Allow explicit ctors for casts.
llvm-svn: 80374
2009-08-28 16:22:20 +00:00
Anders Carlsson 759b78951e When doing overload resolution, expressions that are value dependent but not type dependent and of integral type should not be treated as null pointer constants.
llvm-svn: 80369
2009-08-28 15:55:56 +00:00
Anders Carlsson 4bd7875b9c Instantiate unresolved using declarations.
llvm-svn: 80366
2009-08-28 15:18:15 +00:00
Douglas Gregor 6a1f965853 When looking for overloaded member operators, make sure to instantiate
class template specializations (when possible) and look into base
classes. Thanks to Eli for the test case!

FIXME -=1.

llvm-svn: 80302
2009-08-27 23:35:55 +00:00
Sebastian Redl 880a348b52 Extend the exception spec test even further. Now I need to implement this.
llvm-svn: 80276
2009-08-27 19:07:16 +00:00
Eli Friedman 972931e25d Don't create a junk file in the source directory.
llvm-svn: 80274
2009-08-27 19:01:37 +00:00
Anders Carlsson 574315a0fa Add a BuildCXXTemporaryObjectExpr and use it so default arguments will be instantiated correctly for temporary object expressions.
llvm-svn: 80206
2009-08-27 05:08:22 +00:00
Anders Carlsson c24fc2949e More support for pseudo dtors.
llvm-svn: 80129
2009-08-26 19:22:42 +00:00
Douglas Gregor e9899d9769 Fix for overloaded binary operators whose operands need implicit
conversions, from Sylvere Teissier!

llvm-svn: 80112
2009-08-26 17:08:25 +00:00
Anders Carlsson be96bc94e8 Handle the implicit 'this' parameter for format attributes.
llvm-svn: 79987
2009-08-25 14:12:34 +00:00
Douglas Gregor f2270430a1 Skip transparent contexts when performing C++ name lookup
llvm-svn: 79931
2009-08-24 18:55:03 +00:00
Douglas Gregor b00b10eb2e Implement support for equality comparisons (!=, ==) of member
pointers, by extending the "composite pointer type" logic to include
member pointer types.

Introduce test cases for member pointer comparisons, including those
that involve the builtin operator candidates implemented earlier. 

llvm-svn: 79925
2009-08-24 17:42:35 +00:00
Douglas Gregor 8b9575f27e Top-level semicolons are allowed in C++0x. Fixes PR4755.
llvm-svn: 79912
2009-08-24 12:17:54 +00:00
Eli Friedman c96d4963eb Implement __is_empty. Patch by Sean Hunt.
llvm-svn: 79143
2009-08-15 21:55:26 +00:00
Anders Carlsson 5fd7dad784 getFunctionLevelDeclContext needs to get the previous DeclContext if EnterDeclaratorContext has been called. Fixes PR4694. (Doug, please review)
llvm-svn: 78480
2009-08-08 17:48:49 +00:00
Anders Carlsson 21776b75ce Make sure to diagnose use of declarations in the case where we create an implicit CXXThisExpr.
llvm-svn: 78474
2009-08-08 16:55:18 +00:00
Fariborz Jahanian 11a8e95a1a After reporting ill-formed copy constructor(12.8.p3)
don't recurs and crash.

llvm-svn: 78323
2009-08-06 17:22:51 +00:00
Douglas Gregor d806156d54 Support nested-name-specifiers for C++ member access expressions, e.g.,
this->Base::foo

from James Porter!

llvm-svn: 78278
2009-08-06 03:17:00 +00:00
Daniel Dunbar 769f940655 Ok, ok, I give in. Fix tests for unused result warning.
llvm-svn: 77780
2009-08-01 06:07:15 +00:00
Fariborz Jahanian e82da999e9 Fixed test.
llvm-svn: 77506
2009-07-29 21:26:28 +00:00
Fariborz Jahanian 4b12ed115a Some refactoring of member access for
performace sake. Also added a test case.

llvm-svn: 77502
2009-07-29 20:41:46 +00:00
Sebastian Redl 63c4da01c8 Check for identical types in C++ catch expression. Patch by Erik Verbruggen.
llvm-svn: 77475
2009-07-29 17:15:45 +00:00
Sebastian Redl 955a067bdd Make functional-style casts emit correct messages, and fix a crash-on-invalid.
llvm-svn: 77451
2009-07-29 13:50:23 +00:00
Anders Carlsson 32d105d8d4 Add two more tests.
llvm-svn: 77330
2009-07-28 17:14:18 +00:00
Benjamin Kramer 8675976806 fix test (broken in r77224)
llvm-svn: 77241
2009-07-27 19:53:49 +00:00
Sebastian Redl 9f831dbbcd Implement C++ semantics for C-style and functional-style casts. This regresses Clang extension conversions, like vectors, but allows conversions via constructors and conversion operators.
Add custom conversions to static_cast.

llvm-svn: 77076
2009-07-25 15:41:38 +00:00
Daniel Dunbar 595c98729b Make having no RUN line a failure.
Doug, please look at decltype-crash and instantiate-function-1.mm, I'm not sure
if they are actually testing the right thing / anything.

llvm-svn: 77070
2009-07-25 12:47:38 +00:00
Fariborz Jahanian 4dcc53f312 Fixes broken test by accident.
llvm-svn: 77001
2009-07-24 20:33:35 +00:00
Fariborz Jahanian a5c335527d More Sema check for constructor's member initializer along
with type conversion to fix ir-gen crash.

llvm-svn: 77000
2009-07-24 20:28:49 +00:00
Douglas Gregor 79f83eda84 This patch fixes the implementations of the __has_trivial_destructor
and __has_trivial_constructor builtin pseudo-functions and
additionally implements __has_trivial_copy and __has_trivial_assign,
from John McCall!

llvm-svn: 76916
2009-07-23 23:49:00 +00:00