Commit Graph

455 Commits

Author SHA1 Message Date
Douglas Gregor 5823da3ab0 Re-improve recovery when the condition of a switch statement does not
have integral or enumeration type, so that we still check the contents
of the switch body. My previous patch made this worse; now we're back
to where we were previously.

llvm-svn: 107223
2010-06-29 23:25:20 +00:00
Douglas Gregor f4ea725d38 Factor the conversion from a switch condition to an integral or
enumeration type out into a separate, reusable routine. The only
functionality change here is that we recover a little more
aggressively from ill-formed switch conditions.

llvm-svn: 107222
2010-06-29 23:17:37 +00:00
Douglas Gregor a3208f9e7c Vector types are not arithmetic types, either. Note that we now ban
__real myvec and __imag myvec, since they aren't all that useful (it's
just an identity function) but we might want to use them in more
restricted cases in the future (e.g., "__real mycomplexvec" could
extract the real parts of a vector of complex numbers).

llvm-svn: 106601
2010-06-22 23:41:02 +00:00
Douglas Gregor 49b4d73451 Type Type::isRealFloatingType() that vectors are not floating-point
types, updating callers of both isFloatingType() and
isRealFloatingType() accordingly. Caught at least one issue where we
allowed one to declare a vector of vectors (!), along with cleaning up
the standard-conversion logic for C++.

llvm-svn: 106595
2010-06-22 23:07:26 +00:00
Douglas Gregor 4ffbad1904 Change Type::isFloatingType() to reflect the actual definition of a
"floating type" in C, which does not include vector types. Introduce
Type::hasFloatingRepresentation() for the places where we want to know
whether the underlying representation is one or more floating-point
values. Remove some hacks we had where the former behavior of
Type::isFloatingType() was at odds with the language definition of the
term.

llvm-svn: 106584
2010-06-22 22:12:46 +00:00
Douglas Gregor db48cf3c31 Don't allow vector conversions to sneak in under the guise of
floating-point conversions or floating-integral conversions. We
really, really, really need to make isFloatingType() and friends not
apply to vector types.

llvm-svn: 106551
2010-06-22 16:52:27 +00:00
Douglas Gregor 630dec57a2 Use UnaryOperator as the representation of dependent expressions when
no overloaded operators were found in scope, mirroring what we already
do for BinaryOperator.

llvm-svn: 106222
2010-06-17 15:46:20 +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 6972a62c8f Give Type::isIntegralType() an ASTContext parameter, so that it
provides C "integer type" semantics in C and C++ "integral type"
semantics in C++. 

Note that I still need to update isIntegerType (and possibly other
predicates) using the same approach I've taken for
isIntegralType(). The two should have the same meaning, but currently
don't (!).

llvm-svn: 106074
2010-06-16 00:35:25 +00:00
Douglas Gregor b90df60b3b Introduce Type::isIntegralOrEnumerationType(), to cover those places
in C++ that involve both integral and enumeration types. Convert all
of the callers to Type::isIntegralType() that are meant to work with
both integral and enumeration types over to
Type::isIntegralOrEnumerationType(), to prepare to eliminate
enumeration types as integral types.

llvm-svn: 106071
2010-06-16 00:17:44 +00:00
John McCall 6d1116ac49 Conversions from Objective C object pointers to bool are "pointer conversions
to bool" in the sense of C++ [over.ics.rank]p4 bullet 1.  I have decreed it.

llvm-svn: 105817
2010-06-11 10:04:22 +00:00
Jeffrey Yasskin 5d474d0a96 Fix the 64-bit build. operator<<(DiagnosticBuilder, long) doesn't exist, so
ptrdiff_t (long on 64-bit, apparently) is ambiguous between the int and
unsigned int overloads.

llvm-svn: 105816
2010-06-11 06:58:43 +00:00
Jeffrey Yasskin 2b99c6fc4f Add an option -fshow-overloads=best|all to limit the number of overload
candidates printed.  We default to 'all'.  At the moment, 'best' prints only
the first 4 overloads, but we'll improve that over time.

llvm-svn: 105815
2010-06-11 05:57:47 +00:00
Douglas Gregor 1fc3d66da4 Tweak our handling of the notion of a standard conversion sequence
being a subsequence of another standard conversion sequence. Instead
of requiring exact type equality for the second conversion step,
require type *similarity*, which is type equality with cv-qualifiers
removed at all levels. This appears to match the behavior of EDG and
VC++ (albeit not GCC), and feels more intuitive. Big thanks to John
for the line of reasoning that supports this change: since
cv-qualifiers are orthogonal to the second conversion step, we should
ignore them in the type comparison.

llvm-svn: 105678
2010-06-09 03:53:18 +00:00
Douglas Gregor ce21919bd6 A built-in overload candidate is consider a non-template function when
determining whether one overload candidate is better than
another. Fixes PR7319.

llvm-svn: 105642
2010-06-08 21:03:17 +00:00
Douglas Gregor 4038cf4b57 Implement a warning when converting the literal 'false' to a
pointer. Original patch by Troy D. Straszheim; fixes PR7283.

llvm-svn: 105621
2010-06-08 17:35:15 +00:00
Douglas Gregor b9f907bafc Make sure to strip off top-level cv-qualifiers as part of a
derived-to-base conversion on a pointer. Fixes PR7224.

llvm-svn: 104607
2010-05-25 15:31:05 +00:00
Douglas Gregor e87561aa2e An identity conversion is better than any non-identity
conversion. Fixes PR7095.

llvm-svn: 104476
2010-05-23 22:10:15 +00:00
Douglas Gregor 30a4f4c757 Provide the overloaded functions for UnresolvedLookupExpr and
UnresolvedMemberExpr in their constructors, rather than adding them
after the fact. No functionality change.

llvm-svn: 104468
2010-05-23 18:57:34 +00:00
Douglas Gregor cbfbca14d0 Implement C++ builtin operator candidates for vector types.
llvm-svn: 104105
2010-05-19 03:21:00 +00:00
Fariborz Jahanian 9f963c2488 Misc. fixes to bring Objetive-C++'s handling of
gc attributes to be inline with Objective-C
(for radar 7925141).

llvm-svn: 104084
2010-05-18 23:04:17 +00:00
Douglas Gregor 4618868a7d Implement C++ support for vector and extended vector types. This
involves extending implicit conversion sequences to model vector
conversions and vector splats, along with teaching the C++ conditional
operator-checking code about vector types.

Fixes <rdar://problem/7983501>.

llvm-svn: 104081
2010-05-18 22:42:18 +00:00
Douglas Gregor 5fd04d4832 Tweak typo-correction logic a bit regarding "super", so that we
consider "super" as a candidate whenever we're parsing an expression
within an Objective-C method in an interface that has a superclass. At
some point, we'd like to give "super" a little edge over non-local
names; that will come later.

llvm-svn: 104022
2010-05-18 16:14:23 +00:00
Chris Lattner bb53efb016 fix rdar://7985267 - Don't emit an error about a non-pod argument
passed to va_start, it doesn't actually pass it.

llvm-svn: 103899
2010-05-16 04:01:30 +00:00
John McCall 8b07ec253d Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
  one of {primitive-id, primitive-Class, user-defined @class}
with
  a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared).  ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.

Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType.  Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet.  Remove some number of methods that are no
longer used, at least after this patch.

By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.

llvm-svn: 103870
2010-05-15 11:32:37 +00:00
Fariborz Jahanian cac49a8f8a Objective-C++ Sema. Support for conversion of a C++
class object used as a receiver to an objective-c
pointer via a converwsion function. wip.

llvm-svn: 103672
2010-05-12 23:29:11 +00:00
Douglas Gregor 0bbe94d6df Don't complain about an __builtin_va_arg expression's result being
unused, since the operation has side effects.

llvm-svn: 103360
2010-05-08 22:41:50 +00:00
Douglas Gregor b02d6b3b94 Don't destroy the data associated with an overload resolution candidate; it's ASTContext-allocated now
llvm-svn: 103350
2010-05-08 20:20:05 +00:00
Douglas Gregor 90cf2c98bb Record template argument deduction failures for member function
templates and conversion function templates. 

llvm-svn: 103349
2010-05-08 20:18:54 +00:00
Douglas Gregor d09efd43d3 When printing an overload candidate that failed due to SFINAE, print a
specific message that includes the template arguments, e.g.,

test/SemaTemplate/overload-candidates.cpp:27:20: note: candidate template
      ignored: substitution failure [with T = int *]
  typename T::type get_type(const T&); // expected-note{{candidate ...
                   ^

llvm-svn: 103348
2010-05-08 20:07:26 +00:00
Douglas Gregor 1d72edd7c5 Improve overload-candidate diagnostic for a function template that
failed because the explicitly-specified template arguments did not
match its template parameters, e.g.,

test/SemaTemplate/overload-candidates.cpp:18:8: note: candidate
template
      ignored: invalid explicitly-specified argument for template
      parameter 'I'
  void get(const T&);
       ^
test/SemaTemplate/overload-candidates.cpp:20:8: note: candidate
template
      ignored: invalid explicitly-specified argument for 1st template
      parameter
  void get(const T&);
       ^

llvm-svn: 103344
2010-05-08 19:15:54 +00:00
Douglas Gregor 564767cf39 A leak is better than a double-free while I figure out how to address
this issue.

llvm-svn: 103343
2010-05-08 18:32:25 +00:00
Douglas Gregor 461761d68f Minor cleanup, and ban copying of OverloadCandidateSets. No
functionality change. 

llvm-svn: 103342
2010-05-08 18:20:53 +00:00
Douglas Gregor 02eb4835ce When template argument deduction fails because the call had too
many/too few arguments, use the same diagnostic we use for arity
mismatches in non-templates (but note that it's a function template).

llvm-svn: 103341
2010-05-08 18:13:28 +00:00
Douglas Gregor 3626a5cac2 When printing a non-viable overload candidate that failed due to
conflicting deduced template argument values, give a more specific
reason along with those values, e.g.,

test/SemaTemplate/overload-candidates.cpp:4:10: note: candidate template
      ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')
const T& min(const T&, const T&); 
         ^

llvm-svn: 103339
2010-05-08 17:41:32 +00:00
Douglas Gregor 496e8b345c Reapply the reference-binding patch applied below, along with a fix to
ensure that we complete the type when we need to look at constructors
during reference binding.

When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion. 

Re-fixes PR7080.

llvm-svn: 103283
2010-05-07 19:42:26 +00:00
Douglas Gregor 56f14e575d Revert r103220. It seems to be breaking self-host
llvm-svn: 103259
2010-05-07 15:55:52 +00:00
Douglas Gregor d80c0238bb When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion. 

Fixes PR7080.

llvm-svn: 103220
2010-05-07 00:28:31 +00:00
John McCall 4fa0d5f2bd Diagnose deprecated/unavailable functions selected by overload resolution.
Fixes rdar://problem/4232969, or at least the clang parts of it.

llvm-svn: 103191
2010-05-06 18:15:07 +00:00
Chandler Carruth 27c9fe9f8b Silence a pedantic GCC warning by making the grouping of && and || explicit.
llvm-svn: 103141
2010-05-06 00:15:06 +00:00
Douglas Gregor c8be95274d When instantiating a function that was declared via a typedef, e.g.,
typedef int functype(int, int);
    functype func;

also instantiate the synthesized function parameters for the resulting
function declaration. 

With this change, Boost.Wave builds and passes all of its regression
tests.

llvm-svn: 103025
2010-05-04 18:18:31 +00:00
Fariborz Jahanian 5e5998f014 For the sake of Objective-c++ overload resolution,
treat argument types of objective-c pointer types
which only differ in their protocol qualifiers as
the same type (radar 7925668).

llvm-svn: 102955
2010-05-03 21:06:18 +00:00
Douglas Gregor 980fb16f9a When determining a standard conversion sequence involves resolving the
address of an overloaded function (or function template), perform that
resolution prior to determining the implicit conversion
sequence. This resolution is not part of the implicit conversion
sequence itself.

Previously, we would always consider this resolution to be a
function pointer decay, which was a lie: there might be an explicit &
in the expression, in which case decay should not occur. This caused
the CodeGen assertion in PR6973 (where we created a 
pointer to a pointer to a function when we should have had a pointer
to a function), but it's likely that there are corner cases of
overload resolution where this would have failed.

Cleaned up the code involved in determining the type that will
produced afer resolving the overloaded function reference, and added
an assertion to make sure the result is correct. Fixes PR6973.

llvm-svn: 102650
2010-04-29 18:24:40 +00:00
Douglas Gregor d0ace02496 When copying a temporary object to initialize an entity for which the
temporary needs to be bound, bind the copy object. Otherwise, we won't
end up calling the destructor for the copy. Fixes Boost.Optional.

llvm-svn: 102290
2010-04-25 00:55:24 +00:00
Anders Carlsson 7d3360f123 Add base paths for CK_BaseToDerived and CK_BaseToDerivedMemberPointer.
llvm-svn: 102261
2010-04-24 19:36:51 +00:00
Anders Carlsson a70cff624e Actually produce base paths for CastExprs of kind CK_DerivedToBase.
llvm-svn: 102259
2010-04-24 19:06:50 +00:00
Anders Carlsson 7afe4245e2 Pass the base specifiers through to CheckDerivedToBaseConversion. No functionality change yet.
llvm-svn: 102250
2010-04-24 17:11:09 +00:00
Anders Carlsson 0c509eeac7 CastExpr should not hold a pointer to the base path. More cleanup.
llvm-svn: 102249
2010-04-24 16:57:13 +00:00
Anders Carlsson 9759793855 Add an InheritancePath parameter to the ImplicitCastExpr constructor.
llvm-svn: 102218
2010-04-23 22:18:37 +00:00
Benjamin Kramer 92b761cf4b Remove dead code.
llvm-svn: 101920
2010-04-20 18:01:57 +00:00