Commit Graph

3181 Commits

Author SHA1 Message Date
Douglas Gregor dd6c0356ba Improve recovery in a wonky case where one tries to specialize a
template template parameter.

When building a template-id type, check whether the template-name
itself is dependent (even if the template arguments are not!) and
handle it as a template-id type.

llvm-svn: 86913
2009-11-12 00:46:20 +00:00
John McCall b0e419e34d Add <foo> = [<bar> nextObject] to the -Widiomatic-parentheses category,
and give that category an explicit test.  Generalize the internal diagnostic
name.

llvm-svn: 86905
2009-11-12 00:06:05 +00:00
Douglas Gregor adee3e3b22 Template argument deduction for template template parameters. This
permits, among other things, ripping apart and reconstructing
templates via partial specialization:

  template<typename T> 
  struct DeepRemoveConst { typedef T type; };

  template<typename T>
  struct DeepRemoveConst<const T> {
    typedef typename DeepRemoveConst<T>::type type;
  };

  template<template<typename> class TT, typename T>
  struct DeepRemoveConst<TT<T> > {
    typedef TT<typename DeepRemoveConst<T>::type> type;
  };

Also, fix a longstanding thinko in the code handling partial ordering
of class template partial specializations. We were performing the
second deduction without clearing out the results of the first
deduction. It's amazing we got through so much code with such a
horrendous error :(

llvm-svn: 86893
2009-11-11 23:06:43 +00:00
John McCall 5055e4cdfd Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part of
the -Wconversion check.

llvm-svn: 86891
2009-11-11 22:52:37 +00:00
Fariborz Jahanian 13e0c90fc1 writable atomic property's setter/getter must be in 'lock' step of
either both synthesized or bith user defined. 
Implements radar 6557233.

llvm-svn: 86887
2009-11-11 22:40:11 +00:00
Douglas Gregor 84d49a2085 Improve diagnostics when a default template argument does not match
with its corresponding template parameter. This can happen when we
performed some substitution into the default template argument and
what we had doesn't match any more, e.g.,

  template<int> struct A;
  template<typename T, template<T> class X = A> class B;

  B<long> b;

Previously, we'd emit a pretty but disembodied diagnostic showing how
the default argument didn't match the template parameter. The
diagnostic was good, but nothing tied it to the *use* of the default
argument in "B<long>". This commit fixes that.

Also, tweak the counting of active template instantiations to avoid
counting non-instantiation records, such as those we create for
(surprise!) checking default arguments, instantiating default
arguments, and performing substitutions as part of template argument
deduction.

llvm-svn: 86884
2009-11-11 21:54:23 +00:00
Douglas Gregor eebed72fbb Move handling of template parameter packs out of the
template-type-parameter specific template argument checking code and
up to the template argument checking loop. In theory, this should make
variadic templates work better; in practice, they don't well enough
for us to care anyway (YET!), so this is mostly a re-organization to
simplify CheckTemplateArgument.

llvm-svn: 86868
2009-11-11 19:41:09 +00:00
Douglas Gregor da0fb53c16 Refactoring of template-argument checking code to reduce nesting,
increase sanity. No intended functionality change.

llvm-svn: 86866
2009-11-11 19:31:23 +00:00
Douglas Gregor e62e6a0191 Before checking a template template argument against its corresponding
template template parameter, substitute any prior template arguments
into the template template parameter. This, for example, allows us to
properly check the template template argument for a class such as:

  template<typename T, template<T Value> class X> struct Foo;

The actual implementation of this feature was trivial; most of the
change is dedicated to giving decent diagnostics when this
substitution goes horribly wrong. We now get a note like:

  note: while substituting prior template arguments into template
      template parameter 'X' [with T = float]

As part of this change, enabled some very pedantic checking when
comparing template template parameter lists, which shook out a bug in
our overly-eager checking of default arguments of template template
parameters. We now perform only minimal checking of such default
arguments when they are initially parsed.

llvm-svn: 86864
2009-11-11 19:13:48 +00:00
Douglas Gregor 38fee967ae Instantiation of template template parameters for nested templates, e.g.,
template<typename T>
  struct X {
    template<template<T Value> class Y> struct Inner;
  };

llvm-svn: 86844
2009-11-11 16:58:32 +00:00
John McCall 7e1d6d78d5 Preserve source locations when building offsetof expressions featuring
anonymous members.  Partial fix for PR 5390.

llvm-svn: 86796
2009-11-11 03:23:23 +00:00
John McCall 0506e4af2c Apparently the following idiom is specifically encouraged:
if (self = [super init])
Recognize it and only warn if -Wparentheses is explicitly enabled.

llvm-svn: 86790
2009-11-11 02:41:58 +00:00
Douglas Gregor 9167f8bbd5 Introduce a new representation for template template
parameters. Rather than storing them as either declarations (for the
non-dependent case) or expressions (for the dependent case), we now
(always) store them as TemplateNames. 

The primary change here is to add a new kind of TemplateArgument,
which stores a TemplateName. However, making that change ripples to
every switch on a TemplateArgument's kind, also affecting
TemplateArgumentLocInfo/TemplateArgumentLoc, default template
arguments for template template parameters, type-checking of template
template arguments, etc.

This change is light on testing. It should fix several pre-existing
problems with template template parameters, such as:
  - the inability to use dependent template names as template template
  arguments
  - template template parameter default arguments cannot be
  instantiation

However, there are enough pieces missing that more implementation is
required before we can adequately test template template parameters. 

llvm-svn: 86777
2009-11-11 01:00:40 +00:00
John McCall caef2448da Create a new Scope when parsing a declaration with a C++ scope specifier.
llvm-svn: 86764
2009-11-11 00:21:18 +00:00
Fariborz Jahanian 4e088941ad Diagnose illegally typed operator new/new[].
llvm-svn: 86755
2009-11-10 23:47:18 +00:00
Douglas Gregor b53edfb8dc Improve parsing of template arguments to lay the foundation for
handling template template parameters properly. This refactoring:

  - Parses template template arguments as id-expressions, representing
    the result of the parse as a template name (Action::TemplateTy)
    rather than as an expression (lame!).

  - Represents all parsed template arguments via a new parser-specific
    type, ParsedTemplateArgument, which stores the kind of template
    argument (type, non-type, template) along with all of the source
    information about the template argument. This replaces an ad hoc
    set of 3 vectors (one for a void*, which was either a type or an
    expression; one for a bit telling whether the first was a type or
    an expression; and one for a single source location pointing at
    the template argument).

  - Moves TemplateIdAnnotation into the new Parse/Template.h. It never
    belonged in the Basic library anyway.

llvm-svn: 86708
2009-11-10 19:49:08 +00:00
Fariborz Jahanian dc21610419 Changed a variable name to match what it represents
(Ted's feedback).

llvm-svn: 86702
2009-11-10 19:31:09 +00:00
John McCall b8be78b753 Fix a similar problem with qualified lookup through using directives,
although in this case we probably just run a risk of duplicating work;
I can't think of how this could cause a bug.

llvm-svn: 86680
2009-11-10 09:25:37 +00:00
John McCall 9757d0363d Make a somewhat more convincing test case for unqualified lookup through
using directives, and fix a bug thereby exposed:  since we're playing
tricks with pointers, we need to make certain we're always using the same 
pointers for things.
Also tweak an existing error message.

llvm-svn: 86679
2009-11-10 09:20:04 +00:00
John McCall f6c8a4ef1f Fix unqualified lookup through using directives.
This is a pretty minimal test case;  I'll make a better one later.

llvm-svn: 86669
2009-11-10 07:01:13 +00:00
Anders Carlsson ace5d07e50 When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:
@class NSString;

@interface Test
+ (void)test:(NSString *)string;
@end

void g(NSString *a);

void f() {
  NSString *a = "Foo";
  g("Foo");
  [Test test:"Foo"];
}

will produce

t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *'
  NSString *a = "Foo";
                ^~~~~
                @
t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *'
  g("Foo");
    ^~~~~
    @
t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *'
  [Test test:"Foo"];
             ^~~~~
             @
3 diagnostics generated.

llvm-svn: 86665
2009-11-10 04:46:30 +00:00
Anders Carlsson 1566eb5a26 Use PP.getLocForEndOfToken as suggested by John.
llvm-svn: 86661
2009-11-10 03:32:44 +00:00
Anders Carlsson 0b8ea554e5 If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
llvm-svn: 86659
2009-11-10 03:24:44 +00:00
Fariborz Jahanian a44e8d85a7 Further change in a comment.
llvm-svn: 86599
2009-11-09 22:28:08 +00:00
Fariborz Jahanian 3fe453c48c Removed a FIXME on nested type specifier warning.
llvm-svn: 86598
2009-11-09 22:25:11 +00:00
Fariborz Jahanian b98dade25b Changed error for nested type qualifier mismatch to
warning, to match gcc. It used to be warning, so
better keep it a warning (it broke a certain project).

llvm-svn: 86597
2009-11-09 22:16:37 +00:00
Douglas Gregor 4ef1d400d9 Make sure that Type::getAs<ArrayType>() (or Type::getAs<subclass of
ArrayType>()) does not instantiate. Update all callers that used this
unsafe feature to use the appropriate ASTContext::getAs*ArrayType method.

llvm-svn: 86596
2009-11-09 22:08:55 +00:00
Douglas Gregor 8caea94c74 Make sure that we look into nested, transparent declaration contexts
when looking for a name within a given DeclContext. Now enumerators
will show up in code-completion results.

llvm-svn: 86591
2009-11-09 21:35:27 +00:00
Fariborz Jahanian facfdd4d93 For array pointee type, get its cvr qualifier from
its element type. Fixes pr5432.

llvm-svn: 86587
2009-11-09 21:02:05 +00:00
Benjamin Kramer 382414d519 Fix build after r86579.
llvm-svn: 86584
2009-11-09 20:14:44 +00:00
Douglas Gregor 1bc688dc60 Make sure that we instantiate default function arguments for an
overloaded operator(). 

llvm-svn: 86581
2009-11-09 19:27:57 +00:00
Eli Friedman 9cf6b59400 Add additional note to mark the cause of synthesized constructors. Mark
declaration invalid if the constructor can't be properly built.  Addresses
remaining review comments from Fariborz for r86500.

llvm-svn: 86579
2009-11-09 19:20:36 +00:00
Douglas Gregor 36d7c5f29b Improve instantiation of default template arguments for nested
templates. The instantiation of these default arguments must be (and
now, is) delayed until the template argument is actually used, at
which point we substitute all levels of template arguments
concurrently.

llvm-svn: 86578
2009-11-09 19:17:50 +00:00
Eli Friedman e4310c8273 Add support for cdecl attribute. (As far as I know, it doesn't affect CodeGen
unless we start implementing command-line switches which override the default
calling convention, so the effect is mostly to silence unknown attribute
warnings.)

llvm-svn: 86571
2009-11-09 18:38:53 +00:00
Douglas Gregor d3d9306275 When transforming an InitListExpr, if we already computed a non-dependent type for the InitListExpr, keep it
llvm-svn: 86559
2009-11-09 17:16:50 +00:00
Eli Friedman cb29876839 Add hack to make the given testcase work. As far as I can tell, this change is
reasonably safe, but it doesn't seem like the right solution.

llvm-svn: 86508
2009-11-09 03:59:26 +00:00
Eli Friedman 96c0a3e6c2 Remove a useless variable that got left behind.
llvm-svn: 86501
2009-11-09 01:11:03 +00:00
Eli Friedman d7686ef31c Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors.  This has a number of benefits:

1. Less code.

2. Explicit and implicit constructors get the same diagnostics.

3. The AST explicitly contains constructor calls from implicit default
constructors.  This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.

llvm-svn: 86500
2009-11-09 01:05:47 +00:00
Eli Friedman fd8d4e1383 Fix use-after-free bug.
llvm-svn: 86485
2009-11-08 22:15:39 +00:00
Sebastian Redl 14236c8e82 Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.
llvm-svn: 86465
2009-11-08 13:56:19 +00:00
Sebastian Redl afb8be743d When checking the namespace of a redeclaration or definition, look through linkage specs. Fixes PR5430.
llvm-svn: 86461
2009-11-08 11:36:54 +00:00
Sebastian Redl 3752e1dbb4 Don't reprocess non-dependent initializers of non-dependent VarDecls. Fixes PR5426.
llvm-svn: 86460
2009-11-08 10:16:43 +00:00
Alexis Hunt 6f3de50ca7 Test commit - minor terminology change to my recent patch suggested by John McCall
llvm-svn: 86442
2009-11-08 07:46:34 +00:00
Douglas Gregor 4100db6174 Always make sure we're using an unqualified type when building a
constructor name.  Fixes PR5418.

llvm-svn: 86441
2009-11-08 07:12:55 +00:00
Fariborz Jahanian d7aa9d8a63 Patch to gives an error that at least points users in the direction of the error, rather
than an error about incompatible types. Patch by Sean Hunt.

llvm-svn: 86402
2009-11-07 20:20:40 +00:00
Douglas Gregor 358e7745ed Cope with calls to operator() templates. Fixes PR5419.
llvm-svn: 86387
2009-11-07 17:23:56 +00:00
John McCall b61e9d03c1 Support -Wshorten-64-to-32 for integer types only, which seems to satisfy the
core requirements.  Fixes rdar://problem/6389954

llvm-svn: 86364
2009-11-07 09:03:53 +00:00
John McCall b397956338 Improve -Wconversion by permitting binary operations on values of the target
type (or smaller) to stay "closed" within the type.

llvm-svn: 86356
2009-11-07 08:15:46 +00:00
Anders Carlsson f5dc6fa252 Don't treat variables with non-trivial ctors or dtors as unused. Fixes PR5407.
llvm-svn: 86352
2009-11-07 07:26:56 +00:00
Anders Carlsson 2889e0e72c Cleanup, no functionality change.
llvm-svn: 86351
2009-11-07 07:18:14 +00:00
Anders Carlsson 3d70975917 When instantiating a field decl, make sure to clone its attributes. With this change FileCheck no longer crashes when it's run without any arguments.
llvm-svn: 86344
2009-11-07 06:07:58 +00:00
John McCall fceb64bd04 Implement -Wconversion. Off by default, in the non-gcc group. There's
significant work left to be done to reduce the false-positive rate here.

llvm-svn: 86326
2009-11-07 03:30:10 +00:00
Steve Naroff eae650366d Add basic code completion support for ObjC messages.
Still a work in progress...

llvm-svn: 86323
2009-11-07 02:08:14 +00:00
Eli Friedman 01cad4c6b0 Make sure isCopyAssignment is only true for actual copy assignment operators,
instead of all assignment operators.  The mistake messes up IRGen because
it ends up assuming that the assignment operator is actually the implicit
copy assignment operator, and therefore tries to emit the RHS as an lvalue.

llvm-svn: 86307
2009-11-07 00:02:45 +00:00
Douglas Gregor 9eb7701dff Various improvements to Clang's code-completion infrastructure:
- Introduce more code-completion string "chunk" kinds that describe
  symbols, the actual text that the user is expected to type, etc.
  - Make the generation of macro results optional, since it can be
  slow
  - Make code-completion accessible through the C API, marshalling the
  code-completion results through a temporary file (ick) to maintain
  process separation.

The last doesn't have tests yet.

llvm-svn: 86306
2009-11-07 00:00:49 +00:00
Fariborz Jahanian 3600f41a3a Since default writable attribute is 'assign', allow
specification of 'assign' (no warning to be issued),
when a continuation class makes a 'readonly' attribute
'readwrite' but also specifies the 'assign' attribute.
(this matches gcc's behavior and prevents exessive 
 warnings)/

llvm-svn: 86297
2009-11-06 22:59:12 +00:00
John McCall e2c91e6b26 Don't warn -Wsign-compare if we're in an unevaluated context, and fixed
a typo pointed out by Fariborz.

llvm-svn: 86265
2009-11-06 18:16:06 +00:00
John McCall e46fd8531c compare.c also needs a target triple now, and improve some comments while we're
at it.

llvm-svn: 86243
2009-11-06 08:53:51 +00:00
John McCall 99ce6bfe28 Improve the -Wsign-compare heuristics:
* If the unsigned type is smaller than the signed type, never warn, because
    its value will not change when zero-extended to the larger type.
  * If we're testing for (in)equality, and the unsigned value is an integer
    constant whose sign bit is not set, never warn, because even though the
    signed value might change, it can't affect the result of the equality.

Also make the comparison test cases much more rigorous, and have them expose
the subtle differences between C and C++ here.

llvm-svn: 86242
2009-11-06 08:49:08 +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 ad8b22269e If we have a C-style cast, functional cast, or a static_cast to a
class type, don't perform the array-to-pointer or function-to-pointer
conversions, because we may end up binding a reference to a function
or array.

With this change, FileCheck now passes -fsyntax-only!

llvm-svn: 86211
2009-11-06 01:14:41 +00:00
Douglas Gregor 02ba0ea461 When we encounter a derived-to-base conversion when performing an
implicit conversion sequence, check the validity of this conversion
and then perform it.

llvm-svn: 86210
2009-11-06 01:02:41 +00:00
Fariborz Jahanian eec642f8ab Minor cleanup of my last patch.
llvm-svn: 86209
2009-11-06 00:55:14 +00:00
Fariborz Jahanian 5582451e91 This patch implements Sema for clause 13.3.3.1p4.
It has to do with vararg constructors used as conversion
functions. Code gen needs work. This is WIP.

llvm-svn: 86207
2009-11-06 00:23:08 +00:00
Douglas Gregor b2186fe23c Make sure that EnumConstantDecls always get a type, even when they have type-dependent initializers.
llvm-svn: 86197
2009-11-06 00:03:12 +00:00
Sebastian Redl 0b7c85fc5a The signed/unsigned checker should not warn for value-dependent expressions, and should especially not try to evaluate them.
llvm-svn: 86173
2009-11-05 21:09:23 +00:00
Douglas Gregor 4ebb7f3e4c Be a little more careful when trying to extract a TypeDecl from a enum/class/struct/union specifier; in invalid code, we may also see ClassTemplateDecls.
llvm-svn: 86171
2009-11-05 20:54:04 +00:00
Sebastian Redl 1060067dd1 Don't allow definitions of array variables without some size information in C++. Fixed PR5401
llvm-svn: 86165
2009-11-05 19:47:47 +00:00
Douglas Gregor 13a2c03801 Eliminate some false positives due to a thinko in the "'blah' is
always zero in this context" warning logic. Also, make the diagnostic
itself more precise when referring to pointer values ("NULL" vs. "zero").

llvm-svn: 86143
2009-11-05 17:49:26 +00:00
Sebastian Redl 65ae200a13 When collecting types for built-in candidates, make arrays decay to pointers. Otherwise, subscripting an array leads to no candidates at all. Fixes PR5360.
llvm-svn: 86140
2009-11-05 16:36:20 +00:00
Sebastian Redl 2dfdb820ca Allow the element type of arrays to be incomplete in C++.
This fixes PR5048. Also fix a bug where zero-sized arrays weren't warned about when the size was unsigned.

llvm-svn: 86136
2009-11-05 15:52:31 +00:00
Douglas Gregor 3ec1bf240d Fixed two places where we needed to force completion of a type
(without complaining if it fails) to get proper semantics: reference
binding with a derived-to-base conversion and the enumeration of
constructors for user-defined conversions. There are probably more
cases to fix, but my prior attempt at statically ensuring that
complete-type checking always happens failed. Perhaps I'll try again.

With this change, Clang can parse include/llvm/*.h!

llvm-svn: 86129
2009-11-05 13:06:35 +00:00
John McCall 1fa36b7cab Implement the conditional-operator part of -Wsign-compare. Turn
DiagnoseSignCompare into Sema::CheckSignCompare and call it from more places.

Add some enumerator tests.  These seem to expose some oddities in the
types we're converting C++ enumerators to;  in particular, they're converting
to unsigned before int, which seems to contradict 4.5 [conv.prom] p2.

Note to self: stop baiting Doug in my commit messages.

llvm-svn: 86128
2009-11-05 09:23:39 +00:00
Douglas Gregor 5287f091b2 When instantiating a UnaryOperator, allow the resulting expression to
still be dependent or invoke an overloaded operator. Previously, we
only supported builtin operators.

BinaryOperator/CompoundAssignOperator didn't have this issue because
we always built a CXXOperatorCallExpr node, even when name lookup
didn't find any functions to save until instantiation time. Now, that
code builds a BinaryOperator or CompoundAssignOperator rather than a
CXXOperatorCallExpr, to save some space.

llvm-svn: 86087
2009-11-05 00:51:44 +00:00
John McCall 644a4181c9 Implement -Wsign-compare, or at least the actual comparison part of it.
Conditional operands are next.

Fixes part of rdar://problem/7289584.

llvm-svn: 86083
2009-11-05 00:40:04 +00:00
Douglas Gregor 01df946664 Make sure to grab CVR qualifiers from the canonical type. ARGH!
llvm-svn: 86079
2009-11-05 00:07:36 +00:00
Douglas Gregor b184f0d32e When instantiating a MemberExpr, be sure to instantiate the
explicitly-specified template arguments, too!

llvm-svn: 86066
2009-11-04 23:20:05 +00:00
John McCall c90f6d76bd Comments, formatting. Based on patch by Brandon Pearcy!
llvm-svn: 86065
2009-11-04 23:13:52 +00:00
John McCall e22a04aba9 Diagnose using a field to initialize itself. Patch by Brandon Pearcy!
llvm-svn: 86061
2009-11-04 23:02:40 +00:00
Douglas Gregor 41127188ac When starting a C++ member access expression, make sure to compute the
type of the object even when it is dependent. Specifically, this makes
sure that we get the right type for "this->", which is important when
performing name lookup into this scope to determine whether an
identifier or operator-function-id is a template name.

llvm-svn: 86060
2009-11-04 22:49:18 +00:00
Douglas Gregor 4d0c38ad95 Fix a little canonical-types issue with non-type template arguments.
Fixes PR5349. 

llvm-svn: 86052
2009-11-04 21:50:46 +00:00
Douglas Gregor 2de8f4149e Don't try to check the initialization of fields with dependent
types. Fixes PR5352.

Fariborz, please review.

llvm-svn: 86031
2009-11-04 17:16:11 +00:00
Douglas Gregor 615ac67fb8 Store the unresolved class type in MemberPointerType's Class field,
from Peter Collingbourne!

llvm-svn: 86030
2009-11-04 16:49:01 +00:00
Douglas Gregor 220f4277bd Switch parsing of using declarations over to ParseUnqualifiedId.
llvm-svn: 86027
2009-11-04 16:30:06 +00:00
John McCall 4c98fd8953 Preserve type source information in sizeof/alignof expressions, and pass it
through to indexing.

llvm-svn: 86018
2009-11-04 07:28:41 +00:00
Douglas Gregor c95a1fa7f6 When performing template instantiation (transformation) of
expressions, keep track of whether we are immediately taking the
address of the expression. Pass this flag when building a declaration
name expression so that we handle pointer-to-member constants
properly.

llvm-svn: 86017
2009-11-04 07:01:15 +00:00
John McCall 4976fd4ea9 Diagnose the use of 'fastcall' on functions without prototypes or with
varargs prototypes.

llvm-svn: 86001
2009-11-04 03:36:09 +00:00
John McCall 9eff4e60ae Diagnose __builtin_offsetof on incomplete types. Fixes
rdar://problem/7222956

llvm-svn: 85999
2009-11-04 03:03:43 +00:00
John McCall 28a6aeab7e Change our basic strategy for avoiding deprecation warnings when the decl use
appears in a deprecated context.  In the new strategy, we emit the warnings
as usual unless we're currently parsing a declaration, where "declaration" is
restricted to mean a decl group or a few special cases in Objective C.  If
we *are* parsing a declaration, we queue up the deprecation warnings until
the declaration has been completely parsed, and then emit them only if the
decl is not deprecated.
We also standardize the bookkeeping for deprecation so as to avoid special cases.

llvm-svn: 85998
2009-11-04 02:18:39 +00:00
Douglas Gregor 71395fa1d5 Implement support for parsing dependent template-ids that refer to
overloaded operators, e.g.,

  p->template operator+<T>()

llvm-svn: 85989
2009-11-04 00:56:37 +00:00
Mike Stump 53f9ded62b Refine volatile handling, specifically, we must have the canonical
type to look at the volatile specifier.  I found these all from just
hand auditing the code.

llvm-svn: 85967
2009-11-03 23:25:48 +00:00
Douglas Gregor 3cf81317e4 Parsing and semantic analysis for template-ids that name overloaded
operators, e.g., 

  operator+<int>

which now works in declarators, id-expressions, and member access
expressions. This commit only implements the non-dependent case, where
we can resolve the template-id to an actual declaration.

llvm-svn: 85966
2009-11-03 23:16:33 +00:00
Mike Stump 96638affa6 We have to ensure we have the canonical type to do this. This is but
one instance of a large problem.  assert for non-canoical types would
help track down these things.

llvm-svn: 85956
2009-11-03 22:20:01 +00:00
Fariborz Jahanian 7ad3616659 Remove previous patch for pr5296 due to further clarification
of value-initialization and trivial constructors.

llvm-svn: 85935
2009-11-03 20:38:53 +00:00
Douglas Gregor 30d60cb36e Replace the code that parses member access expressions after "." or
"->" with a use of ParseUnqualifiedId. Collapse
ActOnMemberReferenceExpr, ActOnDestructorReferenceExpr (both of them),
ActOnOverloadedOperatorReferenceExpr,
ActOnConversionOperatorReferenceExpr, and
ActOnMemberTemplateIdReferenceExpr into a single, new action
ActOnMemberAccessExpr that does the same thing more cleanly (and can
keep more source-location information).

llvm-svn: 85930
2009-11-03 19:44:04 +00:00
Douglas Gregor a121b75d9d Use ParseUnqualifiedId when parsing id-expressions. This eliminates
yet another copy of the unqualified-id parsing code.

Also, use UnqualifiedId to simplify the Action interface for building
id-expressions. ActOnIdentifierExpr, ActOnCXXOperatorFunctionIdExpr,
ActOnCXXConversionFunctionExpr, and ActOnTemplateIdExpr have all been
removed in favor of the new ActOnIdExpression action.

llvm-svn: 85904
2009-11-03 16:56:39 +00:00
Douglas Gregor 7861a80346 Introduce a new class, UnqualifiedId, that provides a parsed
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.

Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.

llvm-svn: 85851
2009-11-03 01:35:08 +00:00
Fariborz Jahanian a386d9533b Assortment of property attributes declared in continuation
class must match those of same property declared
in its primary class. (Fixes radar 7352425)

llvm-svn: 85843
2009-11-03 00:01:38 +00:00
Fariborz Jahanian de8db16a7d Property declared in continuation class can only be used to
change a readonly property declared in the class (and its inherited protocols)
to writable property. (Fixes radar 7350645).

llvm-svn: 85836
2009-11-02 22:45:15 +00:00
Fariborz Jahanian ec344ed2f5 Diagnose implementation of a property declared in a category
in its class implementation instead of crashing. Fixes radar 7350345.

llvm-svn: 85813
2009-11-02 18:45:36 +00:00
Douglas Gregor 0840cc02ce When determining whether a reference to a static data member is an
integral constant expression, make sure to find where the initializer
was provided---inside or outside the class definition---since that can
affect whether we have an integral constant expression (and, we need
to see the initializer itself).

llvm-svn: 85741
2009-11-01 20:32:48 +00:00
Douglas Gregor 5897e097a6 Within a template, qualified name lookup can refer to a non-dependent type
that is not known to be a base class at template definition time due
to some dependent base class. Treat qualified name lookup that refers
to a non-static data member or function as implicit class member
access when the "this" type would be dependent.

llvm-svn: 85718
2009-11-01 17:08:18 +00:00
Douglas Gregor 954de17977 Implement "incremental" template instantiation for non-type template
parameters and template type parameters, which occurs when
substituting into the declarations of member templates inside class
templates. This eliminates errors about our inability to "reduce
non-type template parameter depth", fixing PR5311.

Also fixes a bug when instantiating a template type parameter
declaration in a member template, where we weren't properly reducing
the template parameter's depth.

LLVM's StringSwitch header now parses.

llvm-svn: 85669
2009-10-31 17:21:17 +00:00
Douglas Gregor bb3b46eb74 When a friend is declared in a dependent context, don't even try to
match it up with a declaration in the outer scope.

llvm-svn: 85628
2009-10-30 22:42:42 +00:00
Douglas Gregor 412e8bc56d Instantiate class template friends better; fixes PR5332.
llvm-svn: 85612
2009-10-30 21:07:27 +00:00
Douglas Gregor f329c7c3c0 Include macros in code-completion results
llvm-svn: 85594
2009-10-30 16:50:04 +00:00
Chris Lattner 252d36e74c warn about returning the address of a label.
llvm-svn: 85576
2009-10-30 04:01:58 +00:00
Anders Carlsson 3f0db2beb1 Add a CK_DerivedToBaseMemberPointer cast kind and use it in Sema (Still no codegen).
llvm-svn: 85552
2009-10-30 00:46:35 +00:00
John McCall 41b215eef6 Include pointee type information in the diagnostic for creating bad pointers or
arrays.

llvm-svn: 85550
2009-10-30 00:37:20 +00:00
John McCall 70dd5f6574 Report accurate source-location information when rebuilding types during
template instantiation.

llvm-svn: 85545
2009-10-30 00:06:24 +00:00
Douglas Gregor e6fb91f2cb We may need to instantiate a class template specialization as part of a derived-to-base pointer case
llvm-svn: 85532
2009-10-29 23:08:22 +00:00
Douglas Gregor 07cc4ac606 Slightly improve source-location information during template instantiation
llvm-svn: 85529
2009-10-29 22:21:39 +00:00
Sebastian Redl adba46edc2 Properly instantiate usage of overloaded operator []. Fixes PR5345.
llvm-svn: 85524
2009-10-29 20:17:01 +00:00
John McCall 0d07eb32de A few TemplateArgumentLoc clean-ups. Try to remember the Expr for a declaration.
Provide an API for getting the SourceRange of a TAL and use it judiciously.

llvm-svn: 85520
2009-10-29 18:45:58 +00:00
Douglas Gregor ba91b89711 Yet more instantiation-location information. Fixes PR5336.
llvm-svn: 85516
2009-10-29 17:56:10 +00:00
Anders Carlsson 561f793890 Make sure to call CompleteConstructorCall for bases and members that are initialized implicitly in constructors so that default arguments etc are set correctly. Fixes PR5283.
llvm-svn: 85510
2009-10-29 15:46:07 +00:00
John McCall 0ad166672f Track source information for template arguments and template specialization
types.  Preserve it through template instantiation.  Preserve it through PCH,
although TSTs themselves aren't serializable, so that's pretty much meaningless.

llvm-svn: 85500
2009-10-29 08:12:44 +00:00
Douglas Gregor 21610380de Implement support for semantic checking and template instantiation of
class template partial specializations of member templates. Also,
fixes a silly little bug in the marking of "used" template parameters
in member templates. Fixes PR5236.

llvm-svn: 85447
2009-10-29 00:04:11 +00:00
Fariborz Jahanian d264ee0cba Use array's base element type in getting to its
constructor. WIP.

llvm-svn: 85420
2009-10-28 19:04:36 +00:00
Fariborz Jahanian 57277c5cae Removed an unnecessary arguement passed to InitializeVarWithConstructor
which should come from the variable and wasn't correct for arrays in any case.
No change in functionality.

llvm-svn: 85415
2009-10-28 18:41:06 +00:00
Fariborz Jahanian 42f666342c Diagnose use of data pointer member in a function call
expression instead of crashing.

llvm-svn: 85401
2009-10-28 16:49:46 +00:00
Douglas Gregor 3da3c06578 Slightly improve source location information during template instantiation
llvm-svn: 85353
2009-10-28 00:29:27 +00:00
Fariborz Jahanian ef8b8ce207 Type of a conditional expression with two distinct objective-c
class pointer is the most derived common class of the two.
This is <rdar://problem/7334235>.

llvm-svn: 85337
2009-10-27 23:02:38 +00:00
Douglas Gregor 583dcafce4 Introduce FunctionDecl::isInlined() to tell whether a function should
be inlined.

llvm-svn: 85307
2009-10-27 21:11:48 +00:00
Douglas Gregor 35b5753e17 Rename FunctionDecl::isInline/setInline to
FunctionDecl::isInlineSpecified/setInlineSpecified.

llvm-svn: 85305
2009-10-27 21:01:01 +00:00
Douglas Gregor afca3b4a5c Explicit instantiation suppresses the instantiation of non-inline
function template specializations and member functions of class
template specializations.

llvm-svn: 85300
2009-10-27 20:53:28 +00:00
Douglas Gregor 1d957a336f An explicit instantiation definition only instantiations those class
members that have a definition. Also, use
CheckSpecializationInstantiationRedecl as part of this instantiation
to make sure that we diagnose the various kinds of problems that can
occur with explicit instantiations.

llvm-svn: 85270
2009-10-27 18:42:08 +00:00
Fariborz Jahanian 115654873d Generate constructor for value-initialization cases, even if the
implementation technique doesn't call the constructor at that point.
DR302. Fixes pr5296.

llvm-svn: 85249
2009-10-27 16:51:19 +00:00
Sebastian Redl 4461507151 Implement Chris's suggestions for the precendence warnings. Reformat the code a bit. Test the fixits.
llvm-svn: 85231
2009-10-27 12:10:02 +00:00
Douglas Gregor ef6ab417c1 Only set the point of instantiation for an implicit or explicit
instantiation once we have committed to performing the
instantiation. As part of this, make our makeshift
template-instantiation location information suck slightly less.

Fixes PR5264.

llvm-svn: 85209
2009-10-27 06:26:26 +00:00
Mike Stump 989dc73c48 Almost missed this one... Doc update for last change.
llvm-svn: 85196
2009-10-27 02:07:23 +00:00
Mike Stump ab8b2e08c3 Refine noreturn handling. Fixes -Wmissing-noreturn so that it doesn't
complain that functions that have a return statement should be
declared noreturn.  Fixed PR5286.

llvm-svn: 85195
2009-10-27 01:59:05 +00:00
Ted Kremenek f3afe1e900 Use a pred_iterator instead of a succ_iterator (wrong typedef).
llvm-svn: 85193
2009-10-27 01:07:53 +00:00
Fariborz Jahanian 59f64202d6 Add 'fixit' hint on mis-use of pointer-to-member
binary operators.

llvm-svn: 85153
2009-10-26 20:45:27 +00:00
Sebastian Redl 4afb7c58a4 Add fixit hint to bitwise precedence warning.
llvm-svn: 85129
2009-10-26 17:01:32 +00:00
Sebastian Redl 4302824fe2 Implement a warning for mixing bitwise logical with comparison ops. Fixes PR5297.
llvm-svn: 85117
2009-10-26 15:24:15 +00:00
Chris Lattner c77f989687 Fix PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
declared noreturn.

llvm-svn: 85075
2009-10-25 22:43:07 +00:00
Chris Lattner b7df3c66c8 Implement rdar://6756623 - use of deprecated type in deprecated typedef should not warn
llvm-svn: 85073
2009-10-25 22:31:57 +00:00
Sebastian Redl e24b16205f Make sure we actually have a definition before asking if it is implicit. Fixes PR4674.
llvm-svn: 85072
2009-10-25 22:31:45 +00:00
Chris Lattner ecf328e6dd When parsing a top level struct declaration, make sure to
process decl attributes instead of dropping them on the floor.
This allows us to diagnose cases like the testcase.  Also don't
diagnose deprecated stuff in ActOnTag: not all uses of tags
may be 'uses', and SemaType does this now.

llvm-svn: 85071
2009-10-25 22:21:57 +00:00
Chris Lattner e40853aabd move calls to DiagnoseUseOfDecl (which warns about deprecated/unavailable
types) out of Sema::getTypeName into ConvertDeclSpecToType.  getTypeName
is sometimes used as a predicate in the parser, so it could cause redundant
diags to be emitted.  This is also needed by two upcoming enhancements.

llvm-svn: 85070
2009-10-25 22:09:09 +00:00
Sebastian Redl d7b3d7dd79 Remove the Skip parameter from GetTypeForDeclarator and dependents. Take the opportunity to improve an error message and fix PR4498.
llvm-svn: 85068
2009-10-25 21:45:37 +00:00
Chris Lattner 588f19acc1 remove a nonsensical todo
llvm-svn: 85067
2009-10-25 21:19:07 +00:00
Chris Lattner 1138f04aa5 move the extwarn about using long long out of the entry of
GetTypeForDeclarator and into the code that handles long long 
already.

llvm-svn: 85063
2009-10-25 18:25:04 +00:00
Chris Lattner dae17dbbed simplify interface to ConvertDeclSpecToType, check for inferred
block return types only when a TST isn't specified, not every time
through GetTypeForDeclarator.

llvm-svn: 85062
2009-10-25 18:21:37 +00:00
Chris Lattner ebfde05f29 change ConvertDeclSpecToType to be a static function in SemaType.cpp
llvm-svn: 85061
2009-10-25 18:07:27 +00:00
Chris Lattner 1fb66f4323 change Sema::ActOnFriendTypeDecl to use GetTypeForDeclarator instead
of ConvertDeclSpecToType, which I'd like to keep private to SemaType.cpp.
We do this by cons'ing up a trivial Declarator for the type.

John, please review.

llvm-svn: 85060
2009-10-25 17:47:27 +00:00
Chris Lattner 22e8563175 various cleanups for SemaType.cpp
llvm-svn: 85059
2009-10-25 17:36:50 +00:00
Chris Lattner a27dd59277 minor reorg: check both attributes before decl.
llvm-svn: 85058
2009-10-25 17:21:40 +00:00
Chris Lattner 17e15f18c5 simplify Sema::getTypeName a bit: if control gets out of the switch,
IIDecl cannot be null.  There is no need to check for both C++ mode and
presence of CXXRecordDecl.  ObjC interfaces can't have ScopeSpecs.

llvm-svn: 85057
2009-10-25 17:16:46 +00:00
Chris Lattner 5566290b34 In objc mode, every identifier in a cast expression was using doing a
type looking using getTypeName() and every property access was using
NextToken() to do lookahead to see if the identifier is followed by
a '.'.  Rearrange this code to not need lookahead and only do the
type lookup if we have "identifier." in the token stream.  Also
improve a diagnostic a bit.

llvm-svn: 85056
2009-10-25 17:04:48 +00:00
Sebastian Redl 1054faed32 Audit the code for places where it is assumed that every base specifier refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector.
llvm-svn: 85055
2009-10-25 17:03:50 +00:00
Sebastian Redl c45c03c9dd Ignore dependent bases in ADL. Fixes PR5271.
llvm-svn: 85054
2009-10-25 09:35:33 +00:00
Nate Begeman e46ee9aaea Add support for vector shifts, pretty straight forward.
llvm-svn: 85033
2009-10-25 02:26:48 +00:00
John McCall 703a3f8a7b Preserve type source information in TypedefDecls. Preserve it across
template instantiation.  Preserve it through PCH.  Show it off to the indexer.

I'm healthily ignoring the vector type cases because we don't have a sensible
TypeLoc implementation for them anyway.

llvm-svn: 84994
2009-10-24 08:00:42 +00:00
Douglas Gregor d33198420d Fix overload resolution when calling a member template or taking the
address of a member template when explicit template arguments are
provided.

llvm-svn: 84991
2009-10-24 04:59:53 +00:00
Douglas Gregor 6b815c8799 Implement template instantiation for non-type template
parameters. Fixes PR5103.

llvm-svn: 84979
2009-10-23 23:25:44 +00:00
John McCall 48f2d5860d Store the builtin types as CanQualTypes. Expand a bit on the CanQual API,
but also remove some methods that cause ambiguities, and generally
make CanQual<blah> more analogous to QualType.

llvm-svn: 84976
2009-10-23 23:03:21 +00:00
Douglas Gregor 091f04256a Migrate Sema::ActOnCallExpr to Sema::FixOverloadedFunctionReference,
so that we maintain better source information after template argument
deduction and overloading resolves down to a specific
declaration. Found and dealt with a few more cases that 
FixOverloadedFunctionReference didn't cope with.

(Finally) added a test case that puts together this change with the
DeclRefExpr change to (optionally) include nested-name-specifiers and
explicit template argument lists.

llvm-svn: 84974
2009-10-23 22:18:25 +00:00
John McCall 856bbea332 Remove OriginalTypeParmDecl; the original type is the one specified
in the DeclaratorInfo, if one is present.

Preserve source information through template instantiation.  This is made
more complicated by the possibility that ParmVarDecls don't have DIs, which
is possibly worth fixing in the future.

Also preserve source information for function parameters in ObjC method
declarations.

llvm-svn: 84971
2009-10-23 21:48:59 +00:00
Fariborz Jahanian 9a14b84ac5 Diagnose misuse of '.*' and '->*' operators during parse
instead of crashing in code gen.

llvm-svn: 84968
2009-10-23 21:01:39 +00:00
Sebastian Redl c057f423a0 Apply the special enum restrictions from [over.match.oper]p3b2 in argument-dependent lookup too. This fixes PR5244.
llvm-svn: 84963
2009-10-23 19:23:15 +00:00
Douglas Gregor 4bd90e53c2 Eliminate QualifiedDeclRefExpr, which captured the notion of a
qualified reference to a declaration that is not a non-static data
member or non-static member function, e.g., 

  namespace N { int i; }
  int j = N::i;

Instead, extend DeclRefExpr to optionally store the qualifier. Most
clients won't see or care about the difference (since
QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the
number of top-level expression types that clients need to cope with,
brings the implementation of DeclRefExpr into line with MemberExpr,
and simplifies and unifies our handling of declaration references.

Extended DeclRefExpr to (optionally) store explicitly-specified
template arguments. This occurs when naming a declaration via a
template-id (which will be stored in a TemplateIdRefExpr) that,
following template argument deduction and (possibly) overload
resolution, is replaced with a DeclRefExpr that refers to a template
specialization but maintains the template arguments as written.

llvm-svn: 84962
2009-10-23 18:54:35 +00:00
Fariborz Jahanian c9af8fd76b Fixed a code gen bug (by fixing the AST) involving user-defined
pointer-to-member type conversion follwed by a pointer-to-member
standard conversion.

llvm-svn: 84955
2009-10-23 18:08:22 +00:00
John McCall 24e7cb6f26 Rebuild dependently-sized ext vectors if either the element type or the size
changed under the transform.

llvm-svn: 84953
2009-10-23 17:55:45 +00:00
Benjamin Kramer 0c78c7aa20 Silence GCC 4.3 warning.
TreeTransform.h:2333: warning: suggest parentheses around && within ||

llvm-svn: 84949
2009-10-23 10:48:09 +00:00
John McCall 90459c50d7 Preserve type source information when substituting into FieldDecls.
Just r84734 now that some fundamental work has been completed.

llvm-svn: 84914
2009-10-22 23:33:21 +00:00
John McCall fa2d692b7d Preserve source information for anonymous struct/union declarations.
llvm-svn: 84913
2009-10-22 23:31:08 +00:00
John McCall fc93cf9777 When building types from declarators, instead of building two types (one for
the DeclaratorInfo, one for semantic analysis), just build a single type whose
canonical type will reflect the semantic analysis (assuming the type is
well-formed, of course).

To make that work, make a few changes to the type system:
* allow the nominal pointee type of a reference type to be a (possibly sugared)
  reference type.  Also, preserve the original spelling of the reference type.
  Both of these can be ignored on canonical reference types.
* Remove ObjCProtocolListType and preserve the associated source information on
  the various ObjC TypeLocs.  Preserve the spelling of protocol lists except in
  the canonical form.
* Preserve some level of source type structure on parameter types, but
  canonicalize on the canonical function type.  This is still a WIP.

Drops code size, makes strides towards accurate source location representation,
slight (~1.7%) progression on Cocoa.h because of complexity drop.

llvm-svn: 84907
2009-10-22 22:37:11 +00:00
John McCall b692a098c6 Canonicality is a property of qualified types, not unqualified types.
llvm-svn: 84891
2009-10-22 20:10:53 +00:00
Douglas Gregor 6a573fe543 When replacing a template-id expression with a declaration reference expression after overloading completes, make sure to keep the qualifier. Still not ready with that test-case...
llvm-svn: 84880
2009-10-22 18:02:20 +00:00
Douglas Gregor d019ff686c When building and instantiating a template-id reference expression, such as
N::f<int>

keep track of the full nested-name-specifier. This is mainly QoI and
relatively hard to test; will try to come up with a printing-based
test once we also retain the explicit template arguments past overload
resolution.

llvm-svn: 84869
2009-10-22 17:20:55 +00:00
Sebastian Redl 802f14ccde Try to instantiate templates before doing hierarchy checks in static_cast. Fixes PR5261.
llvm-svn: 84860
2009-10-22 15:07:22 +00:00
Douglas Gregor 3c8a0cfa5b When a template-id expression refers to a member function template, turn it into an (implicit) member access expression. Fixes PR5220
llvm-svn: 84848
2009-10-22 07:19:14 +00:00
Douglas Gregor 6493d9c27e Refactor our handling of implicit member reference expressions to get most of the logic out of BuildDeclarationNameExpr
llvm-svn: 84847
2009-10-22 07:08:30 +00:00
Douglas Gregor c02cfe2a55 Don't (directly) call RequireCompleteType with an invalid source location.
llvm-svn: 84793
2009-10-21 23:19:44 +00:00
Douglas Gregor b8440a76c4 Don't generate pointer types for void or base classes when finding
conversion types for builtin overloaded operator candidates; I misread
this section in the standard the first time around.

llvm-svn: 84788
2009-10-21 22:01:30 +00:00
Anders Carlsson fcb4ab4420 Change FixOverloadedFunctionReference to return a (possibly new) expression. Substitute TemplateIdRefExprs with DeclRefExprs. Doug, plz review :)
llvm-svn: 84763
2009-10-21 17:16:23 +00:00
Douglas Gregor 74ba25ca5a Improve diagnostics and template instantiation behavior when calling
an overloaded function call operator.

llvm-svn: 84745
2009-10-21 06:18:39 +00:00
John McCall b879435493 Revert those last two commits. Beware the treacherous semicolon.
llvm-svn: 84736
2009-10-21 03:40:01 +00:00
John McCall fb81159c30 Preserve type source information when substituting into ParmVarDecls.
Apparently I'm grinding my commit count.

llvm-svn: 84735
2009-10-21 02:50:40 +00:00
John McCall c30047ae8d Preserve type source information when substituting into FieldDecls.
llvm-svn: 84734
2009-10-21 02:42:37 +00:00
John McCall f1abcdcddd Preserve source information when substituting into VarDecls.
llvm-svn: 84733
2009-10-21 02:39:02 +00:00
John McCall 609459e070 Clone Sema::SubstType for DeclaratorInfos.
llvm-svn: 84724
2009-10-21 00:58:09 +00:00
John McCall de88989e5d Initialize using the base location provided by the derived implementation,
not the default one (which is always empty).

llvm-svn: 84721
2009-10-21 00:44:26 +00:00
John McCall 550e0c2f0f Rewrite TreeTransform to transform types as DeclaratorInfos rather than as bare
QualTypes.  Don't actually exploit this yet.

llvm-svn: 84716
2009-10-21 00:40:46 +00:00
Ted Kremenek 89e53fddb8 Add FIXME.
llvm-svn: 84696
2009-10-20 23:48:29 +00:00
Anders Carlsson b68b028a02 Change ResolveAddressOfOverloadedFunction to support TemplateIdRefExpr. No testcase yet because FixOverloadedFunctionReference needs to be updated too. Doug, plz review.
llvm-svn: 84693
2009-10-20 22:53:47 +00:00
Fariborz Jahanian ac741ffd44 Moved comment to its proper place in my last patch.
llvm-svn: 84662
2009-10-20 20:07:35 +00:00
Fariborz Jahanian 9a587b0111 Patch implements ranking conversions between member pointers [over.ics.rank]
llvm-svn: 84660
2009-10-20 20:04:46 +00:00
Eli Friedman 06ed2a5c94 Remove default argument for ImpCastExprToType. Add appropriate argument
to all callers.  Switch a few other users of CK_Unknown to proper cast 
kinds.

Note that there are still some situations where we end up with 
CK_Unknown; they're pretty easy to find with grep. There 
are still a few missing conversion kinds, specifically 
pointer/int/float->bool and the various combinations of real/complex 
float/int->real/complex float/int.

llvm-svn: 84623
2009-10-20 08:27:19 +00:00
Douglas Gregor a5cb6da0cd Handle substitutions into the "first qualifier in scope" of a
qualified member access expression (e.g., t->U::member) when that
first qualifier refers to a template parameters.

llvm-svn: 84612
2009-10-20 05:58:46 +00:00
Chris Lattner bd19b18100 Implement PR5242: don't desugar a type more than once in a diagnostic. This
implements a framework that allows us to use information about previously
substituted values to simplify subsequent ones.  Maybe this would be useful
for C++'y stuff, who knows.  We now get:

t.c:4:21: error: invalid operands to binary expression ('size_t' (aka 'unsigned long *') and 'size_t')
  return (size_t) 0 + (size_t) 0;
         ~~~~~~~~~~ ^ ~~~~~~~~~~

on the testcase.  Note that size_t is only aka'd once.

llvm-svn: 84604
2009-10-20 05:36:05 +00:00
Chris Lattner c243f299ce teach FormatDiagnostic to aggregate previously formatted arguments and
pass them down into the ArgToStringFn implementation.  This allows 
redundancy across operands to a diagnostic to be eliminated.

This isn't used yet, so no functionality change.

llvm-svn: 84602
2009-10-20 05:25:22 +00:00
Chris Lattner dac91470d7 code cleanup, convert if tree to switch etc.
llvm-svn: 84599
2009-10-20 05:12:36 +00:00
Fariborz Jahanian a4a9334a50 Builtin candidate minimization for
<<=, >>= and the rest.

llvm-svn: 84568
2009-10-20 00:04:40 +00:00
Douglas Gregor c59e56190e Parse a simple-template-id following a '~' when calling a destructor, e.g.,
t->~T<A0, A1>()

Fixes PR5213.

llvm-svn: 84545
2009-10-19 22:04:39 +00:00
Fariborz Jahanian b9e8c42ee6 Add the built-in candidate set reduction hueristic
to '+=', '-=', '*=' and '/=' builtin operators and
fixes a logic bug exposed by doing this.

llvm-svn: 84538
2009-10-19 21:30:45 +00:00
Fariborz Jahanian 996a6aa3f1 Copy conversion of an expression to its base class
is a standard convesion and not a user-defined
conversion.

llvm-svn: 84525
2009-10-19 19:18:20 +00:00
Anders Carlsson 027732b5b9 Set the cast kind to CK_NoOp for C-style casts that are really const casts. Fixes PR5248.
llvm-svn: 84514
2009-10-19 18:14:28 +00:00