Commit Graph

23 Commits

Author SHA1 Message Date
Richard Smith af41696bc4 Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, the
type-name is looked up in the context of the complete postfix-expression. Don't
forget to pass the scope into this lookup when the type-name is a template-id;
it might name an alias template which can't be found within the class itself.

Bug spotted by Johannes Schaub on #llvm.

llvm-svn: 168011
2012-11-15 00:31:27 +00:00
Matt Beaumont-Gay d9f244afbb Fix a QoI bug reported by a user.
Set the source location for the "member reference base type ... is not a
structure or union" diag to point at the operator rather than the member name.
If we're giving this diagnostic because of a typo'd '.' in place of a ';' at
the end of a line, the caret previously pointed at the identifier on the
following line, which isn't as helpful as it could be. Pointing the caret at
the '.' makes it more obvious what the problem is.

llvm-svn: 155267
2012-04-21 01:12:48 +00:00
Kaelyn Uhrain 3658e6a636 Convert SemaExprMember.cpp to pass a callback object to CorrectTypo,
improving the typo correction results in certain situations.

This is also the first typo correction callback conversion to affect
an existing unit test. :)

llvm-svn: 148140
2012-01-13 21:28:55 +00:00
Eli Friedman 9a766c4043 A few minor improvements to error recovery trying to access member of a function. In particular, this restores the cool error recovery for the example from http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html , which regressed a few months back.
llvm-svn: 148089
2012-01-13 02:20:01 +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
Matt Beaumont-Gay 3c27391a90 Implement Sema::isExprCallable.
We can use this to produce nice diagnostics (and try to fixit-and-recover) in
various cases where we might see "MyFunction" instead of "MyFunction()". The
changes in SemaExpr are an example of how to use isExprCallable.

llvm-svn: 130878
2011-05-04 22:10:40 +00:00
Matt Beaumont-Gay f8bb45f14d Much to my surprise, OverloadExprs can also point to function template decls.
llvm-svn: 127061
2011-03-05 02:42:30 +00:00
Matt Beaumont-Gay 06de2553f3 Clean up the error recovery at the bottom of Sema::LookupMemberExpr. This
mostly just shuffles various possibilities for recovery into a more
straightforward order, but also unifies a couple of diagnostics.

llvm-svn: 126266
2011-02-22 23:52:53 +00:00
Matt Beaumont-Gay 956fc1cb81 Fix PR9025 and add a diagnostic (and sometimes a fixit) for an overloaded
function name used as the base of a member expression. Early feedback from
Chandler Carruth, and code review from Nick Lewycky.

llvm-svn: 125714
2011-02-17 02:54:17 +00:00
Douglas Gregor a9c3e82755 Don't die when a member access refers to a non-class member via a
qualified name. Fixes <rdar://problem/8231724>.

llvm-svn: 109682
2010-07-28 22:27:52 +00:00
Douglas Gregor c048c52734 When typo correction produces a result that is not of the kind we're
looking for, reset the name within the LookupResult structure in
addition to clearing out the results. Fixes PR7508.

llvm-svn: 107197
2010-06-29 19:27:42 +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
Douglas Gregor 516d672310 When name lookup finds a single declaration that was imported via a
using declaration, look at its underlying declaration to determine the
lookup result kind (e.g., overloaded, unresolved). Fixes at least one
issue in Boost.Bimap.

llvm-svn: 102317
2010-04-25 21:15:30 +00:00
Douglas Gregor 861eb80a3b Improve the diagnostic when we find something we did not expect in a
member expression (p-> or x.), by showing the type we looked into and
what we did actually find.

llvm-svn: 102315
2010-04-25 20:55:08 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
John McCall a6d407c296 Fix IsProvablyNotDerivedFrom to always use record definitions when available.
Gets clang-on-clang passing again.

llvm-svn: 90270
2009-12-01 22:28:41 +00:00
Douglas Gregor d82ae38d53 Rework the fix-it hint for code like
get_origin->x

where get_origin is actually a function and the user has forgotten the
parentheses. Instead of giving a lame note for the fix-it, give a
full-fledge error, early, then build the call expression to try to
recover. 

llvm-svn: 86238
2009-11-06 06:30:47 +00:00
Douglas Gregor 0b3d95ae64 Fix a crash with qualified member access into a non-type, from Sean Hunt!
llvm-svn: 84370
2009-10-17 22:37:54 +00:00
Argyrios Kyrtzidis b1d51aa18a Use "()" instead of "(void)" when pretty-printing a parameter-less function type for C++.
llvm-svn: 72747
2009-06-03 02:06:50 +00:00
Douglas Gregor 0b08ba44a1 If the user is trying to apply the -> or . member reference operator
to a function or function pointer, it's probably because the user
forgot to put in parentheses () to call the function.

llvm-svn: 67826
2009-03-27 06:00:30 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Douglas Gregor 6bd18af3a3 Add test for contextual conversion to bool, and enable some FIXME'd tests
llvm-svn: 62302
2009-01-16 03:02:29 +00:00
Douglas Gregor 2eedc3aa1c Add support for member references (E1.E2, E1->E2) with C++ semantics,
which can refer to static data members, enumerators, and member
functions as well as to non-static data members.

Implement correct lvalue computation for member references in C++. 
Compute the result type of non-static data members of reference type properly.

llvm-svn: 61294
2008-12-20 23:49:58 +00:00