Commit Graph

578 Commits

Author SHA1 Message Date
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Anders Carlsson d3569efb5a Add bug number.
llvm-svn: 86357
2009-11-07 08:24:59 +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
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 f4f2ff773b Improve recovery when we fail to parse the operand of a C++ named cast. Fixes PR5210
llvm-svn: 86234
2009-11-06 05:48:00 +00:00
Douglas Gregor 6af6c3ee56 Turn off -Wsign-compare warnings by default
llvm-svn: 86233
2009-11-06 05:24:12 +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
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
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
Mike Stump 5ff76e2fa2 Fix 80-col violation.
llvm-svn: 86115
2009-11-05 03:47:55 +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
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 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
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 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 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
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
John Thompson 995c845e5c Disabling some MS extensions which cause this test to fail
llvm-svn: 85242
2009-10-27 14:58:27 +00:00
John Thompson ec87bb5c46 Disabling some MS extensions which cause these tests to fail
llvm-svn: 85236
2009-10-27 14:31:53 +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
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
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
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 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
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
Fariborz Jahanian 9a587b0111 Patch implements ranking conversions between member pointers [over.ics.rank]
llvm-svn: 84660
2009-10-20 20:04:46 +00:00
Anders Carlsson 7001794302 It's OK for a pure virtual function to override another pure virtual function. Fixes PR5222.
llvm-svn: 84428
2009-10-18 19:34:08 +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
Edward O'Callaghan 93135aad29 Fix for PR5190, Credit to Zhanyong Wan.
llvm-svn: 84346
2009-10-17 19:32:54 +00:00
Sebastian Redl 5371aed18c Add a DR437 testcase, but disable it for now, since it fails.
llvm-svn: 84345
2009-10-17 18:31:05 +00:00
Fariborz Jahanian 956127de22 Patch to clean up and improve visual display of
builtin function ambiguity.

llvm-svn: 84289
2009-10-16 23:25:02 +00:00
Anders Carlsson 35a99d95b3 The result type of logical || and && is bool in C++. Fixes PR5206.
llvm-svn: 84231
2009-10-16 01:44:21 +00:00
Fariborz Jahanian 3b937fa298 Apply heuristics to cut back on number of candidate
sets of builtin operators. Currently, it is applied 
to '++' and '->*' operators. I need to apply it to others
as well. Also, heuristics need be applied to 
BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants.
This is WIP.

llvm-svn: 84187
2009-10-15 17:14:05 +00:00
Anders Carlsson 63dce02544 Check the return type when calling pointer to member functions.
llvm-svn: 84161
2009-10-15 00:41:48 +00:00
Sebastian Redl 7eb5d377d7 Use partial diagnostics properly in call to RequireCompleteType. Among other things, this means we get a note on the declaration of the incomplete type when it is used in an exception specification.
llvm-svn: 84099
2009-10-14 14:59:48 +00:00
Sebastian Redl 075b21d4dc Do exception spec compatibility tests for member pointers, too.
llvm-svn: 84098
2009-10-14 14:38:54 +00:00
Fariborz Jahanian 31481d8b22 Handle ambiguity of reference initialization.
Removes a FIXME.

llvm-svn: 84068
2009-10-14 00:52:43 +00:00
Douglas Gregor 15e5602e59 Improve diagnostics when the parser encounters a declarator with an
unknown type name, e.g.,

  foo::bar x;

when "bar" does not refer to a type in "foo". 

With this change, the parser now calls into the action to perform
diagnostics and can try to recover by substituting in an appropriate
type. For example, this allows us to easily diagnose some missing
"typename" specifiers, which we now do:

  test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename'
        prior to dependent type name 'A<T>::type'
  A<T>::type A<T>::f() { return type(); }
  ^~~~~~~~~~
  typename 

Fixes PR3990.

llvm-svn: 84053
2009-10-13 23:27:22 +00:00
Anders Carlsson e4f4b5e919 Check the return type of binary operators and the arrow operator.
llvm-svn: 84043
2009-10-13 22:43:21 +00:00
Anders Carlsson 834facc2b0 Check the return type of operator[]() and fix a thinko that lead to a crash in SemaCXX/overloaded-operator.cpp.
llvm-svn: 84041
2009-10-13 22:22:09 +00:00
Anders Carlsson 3d5829cd4f More return type checking.
llvm-svn: 84034
2009-10-13 21:49:31 +00:00
Anders Carlsson f64a3dae04 Diagnose invalid return types for unary operators.
llvm-svn: 84030
2009-10-13 21:19:37 +00:00
Douglas Gregor e40876a50c Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.

llvm-svn: 84028
2009-10-13 21:16:44 +00:00
Anders Carlsson 8523d20af3 Pass the right SourceLocation to Actions.ActOnOverloadedOperatorReferenceExpr and Actions.ActOnConversionOperatorReferenceExpr. Update incomplete-call.cpp test.
llvm-svn: 84026
2009-10-13 21:02:07 +00:00
John McCall d5707abdfd Implement -Wparentheses: warn about using assignments in contexts that require
conditions.  Add a fixit to insert the parentheses.  Also fix a very minor
possible memory leak in 'for' conditions.

Fixes PR 4876 and rdar://problem/7289172

llvm-svn: 83907
2009-10-12 21:59:07 +00:00