summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/overload-call.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DR1152 / PR12931 / PR6177: A candidate function which requires binding a constRichard Smith2012-05-241-8/+14
| | | | | | | | volatile reference to a temporary is not viable. My interpretation is that DR1152 was a bugfix, not a rule change for C++11, so this is not conditional on the language mode. This matches g++'s behavior. llvm-svn: 157370
* Improve some of the conversion warnings to fire on conversion to bool.David Blaikie2012-05-151-1/+1
| | | | | | | | | | | Moves the bool bail-out down a little in SemaChecking - so now -Wnull-conversion and -Wliteral-conversion can fire when the target type is bool. Also improve the wording/details in the -Wliteral-conversion warning to match the -Wconstant-conversion. llvm-svn: 156826
* Further improvement to wording of overload resolution diagnostics, and includingRichard Smith2012-05-151-3/+3
| | | | | | the sole parameter name in the diagnostic in more cases. Patch by Terry Long! llvm-svn: 156807
* PR11857: When the wrong number of arguments are provided for a functionRichard Smith2012-05-111-2/+8
| | | | | | | which expects exactly one argument, include the name of the argument in the diagnostic text. Patch by Terry Long! llvm-svn: 156607
* Enable warn_impcast_literal_float_to_integer by default.David Blaikie2012-04-051-1/+1
| | | | | | | | | | | | | | | | | This diagnostic seems to be production ready, it's just an oversight that it wasn't turned on by default. The test changes are a bit of a mixed bag. Some tests that seemed like they clearly didn't need to use this behavior have been modified not to use it. Others that I couldn't be sure about, I added the necessary expected-warnings to. It's possible the diagnostic message could be improved to make it clearer that this warning can be suppressed by using a value that won't lose precision when converted to the target type (but can still be a floating point literal, such as "bool b = 1.0;"). llvm-svn: 154068
* Qualifiers on a canonical array type go on the outermost type, not theDouglas Gregor2012-03-101-0/+5
| | | | | | innermost type. Fixes PR12142. llvm-svn: 152456
* Fix a regression from r151117: ADL requires that we attempt to complete anyRichard Smith2012-02-251-1/+21
| | | | | | | | associated classes, since it can find friend functions declared within them, but overload resolution does not otherwise require argument types to be complete. llvm-svn: 151434
* Implement C++11 [expr.call]p11: If the operand to a decltype-specifier is aRichard Smith2012-02-221-0/+9
| | | | | | | | | | | | | | | | | | function call (or a comma expression with a function call on its right-hand side), possibly parenthesized, then the return type is not required to be complete and a temporary is not bound. Other subexpressions inside a decltype expression do not get this treatment. This is implemented by deferring the relevant checks for all calls immediately within a decltype expression, then, when the expression is fully-parsed, checking the relevant constraints and stripping off any top-level temporary binding. Deferring the completion of the return type exposed a bug in overload resolution where completion of the argument types was not attempted, which is also fixed by this change. llvm-svn: 151117
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Allow calling an overloaded function set by taking the address of theDouglas Gregor2011-10-131-0/+9
| | | | | | functions, e.g., (&f)(0). Fixes <rdar://problem/9803316>. llvm-svn: 141877
* Identity and non-identity standard conversion sequences can beDouglas Gregor2011-06-051-0/+22
| | | | | | | | | compared even when one is a reference binding and the other is not (<rdar://problem/9173984>), but the definition of an identity sequence does not involve lvalue-to-rvalue adjustments (PR9507). Fix both inter-related issues. llvm-svn: 132660
* Revert the fix for PR8013.Douglas Gregor2010-11-091-8/+0
| | | | | | | | | | | | | That bug concerned the well-formedness of code such as (&ovl)(a, b, c). GCC rejects the code, while EDG accepts it. On further study of the standard, I see no support for EDG's position: in particular, C++ [over.over] does not list this as a context where we can take the address of an overloaded function, C++ [over.call.func] does not reference the address-of operator at any point, and C++ [expr.call] claims that the function argument in a call is either a function lvalue or a pointer-to-function; (&ovl) is neither. llvm-svn: 118620
* Handle overload resolution when calling an overloaded function setDouglas Gregor2010-11-091-0/+8
| | | | | | with, e.g., (&f)(a, b, c). Fixes PR8013. llvm-svn: 118508
* Add test case for r115588.Argyrios Kyrtzidis2010-10-051-0/+13
| | | | llvm-svn: 115590
* make clang print types as "const int *" instead of "int const*",Chris Lattner2010-09-051-3/+3
| | | | | | | which is should have done from the beginning. As usual, the most fun with this sort of change is updating all the testcases. llvm-svn: 113090
* Extend the "cannot convert from base class pointer to derived classDouglas Gregor2010-07-011-0/+6
| | | | | | pointer" diagnostic to handle references, too. llvm-svn: 107372
* Improve diagnostic when we fail to pick an overload because it wouldDouglas Gregor2010-06-301-0/+6
| | | | | | require a base-to-derived pointer conversion. llvm-svn: 107349
* String literals enclosed in parentheses are still stringDouglas Gregor2010-06-221-0/+1
| | | | | | literals. Fixes PR7488. llvm-svn: 106607
* Tweak our handling of the notion of a standard conversion sequenceDouglas Gregor2010-06-091-0/+17
| | | | | | | | | | | | | 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
* Make sure to strip off top-level cv-qualifiers as part of aDouglas Gregor2010-05-251-0/+16
| | | | | | derived-to-base conversion on a pointer. Fixes PR7224. llvm-svn: 104607
* An identity conversion is better than any non-identityDouglas Gregor2010-05-231-0/+14
| | | | | | conversion. Fixes PR7095. llvm-svn: 104476
* When we are performing copy initialization of a class type via itsDouglas Gregor2010-04-241-1/+1
| | | | | | | | | | | copy constructor, suppress user-defined conversions on the argument. Otherwise, we can end up in a recursion loop where the bind the argument of the copy constructor to another copy constructor call, whose argument is then a copy constructor call... Found by Boost.Regex which, alas, still isn't building. llvm-svn: 102269
* Whenever we complain about a failed initialization of a function orDouglas Gregor2010-04-221-1/+1
| | | | | | | | | | | | | | | | | method parameter, provide a note pointing at the parameter itself so the user does not have to manually look for the function/method being called and match up parameters to arguments. For example, we now get: t.c:4:5: warning: incompatible pointer types passing 'long *' to parameter of type 'int *' [-pedantic] f(long_ptr); ^~~~~~~~ t.c:1:13: note: passing argument to parameter 'x' here void f(int *x); ^ llvm-svn: 102038
* When performing reference initialization for the purposes of overloadDouglas Gregor2010-04-181-3/+12
| | | | | | | | | | | resolution ([over.ics.ref]), we take some shortcuts required by the standard that effectively permit binding of a const volatile reference to an rvalue. We have to treat lightly here to avoid infinite recursion. Fixes PR6177. llvm-svn: 101712
* When returning the result of a call to an object of class type, do notDouglas Gregor2010-04-131-0/+15
| | | | | | | return a NULL expression; return either an error or a proper expression. Fixes PR6078. llvm-svn: 101133
* Reference binding via user-defined conversion can compute a bindingDouglas Gregor2010-03-071-0/+20
| | | | | | | that is not reference-related (because it requires another implicit conversion to which we can find). Fixes PR6483. llvm-svn: 97922
* Warn about the deprecated string literal -> char* conversion. Fixes PR6428.Douglas Gregor2010-02-281-3/+3
| | | | llvm-svn: 97404
* Allow us to compare derived-to-base conversions between a referenceDouglas Gregor2010-02-251-0/+13
| | | | | | | binding and a copy-construction. Fixes an overloading problem in the Clang-on-Clang build. llvm-svn: 97161
* When comparing two method overload candidates during overload diagnostics,John McCall2010-02-251-1/+2
| | | | | | | | | | | skip the object argument conversion if either of the candidates didn't initialize it. Fixes PR6421, which is such a very straightforward extension of PR6398 that I should have worked it into the last test case (and therefore caught it then). Ah well. llvm-svn: 97135
* Catch more uses of uninitialized implicit conversion sequences.John McCall2010-02-251-0/+13
| | | | | | | When diagnosing bad conversions, skip the conversion for ignored object arguments. Fixes PR 6398. llvm-svn: 97090
* Fix a major oversight in the comparison of standard conversionDouglas Gregor2010-01-271-0/+12
| | | | | | | | | | | | | | sequences, where we would occasionally determine (incorrectly) that one standard conversion sequence was a proper subset of another when, in fact, they contained completely incomparable conversions. This change records the types in each step within a standard conversion sequence, so that we can check the specific comparison types to determine when one sequence is a proper subset of the other. Fixes this testcase (thanks, Anders!), which was distilled from PR6095 (also thanks to Anders). llvm-svn: 94660
* Produce a special diagnostic when users call a function with an argument ofJohn McCall2010-01-231-0/+14
| | | | | | | | | | | | | | | | incomplete type (or a pointer/reference to such). The causes of this problem are different enough to justify a different "design" for the diagnostic. Most notably, it doesn't give an operand index: it's usually pretty obvious which operand is the problem, it adds a lot of clutter to mention it, and the fix is usually in a different part of the file anyway. This is yet another diagnostic that should really have an analogue in the non-overloaded case --- which should be much easier to write because of the weaker space constraints. llvm-svn: 94303
* Improve the diagnostic for bad conversions in overload resolution to talkJohn McCall2010-01-141-2/+2
| | | | | | about 'object argument' vs. 'nth argument'. llvm-svn: 93395
* Don't report ambiguities in the user-defined conversion if we weren't supposedJohn McCall2010-01-131-0/+16
| | | | | | | | | | | | to be considering user-defined conversions in the first place. Doug, please review; I'm not sure what we should be doing if we see a real ambiguity in selecting a copy constructor when otherwise suppressing user-defined conversions. Fixes PR6014. llvm-svn: 93365
* Record some basic information about bad conversion sequences. Use thatJohn McCall2010-01-131-2/+8
| | | | | | | information to feed diagnostics instead of regenerating it. Much room for improvement here, but fixes some unfortunate problems reporting on method calls. llvm-svn: 93316
* Improve the reporting of non-viable overload candidates by noting the reasonJohn McCall2010-01-131-1/+1
| | | | | | | | why the candidate is non-viable. There's a lot we can do to improve this, but it's a good start. Further improvements should probably be integrated with the bad-initialization reporting routines. llvm-svn: 93277
* Reorganize some of the code to note overload candidates. Improves theJohn McCall2010-01-121-0/+10
| | | | | | | fidelity with which we note them as functions/constructors and templates thereof. Also will be helpful when reporting bad conversions (next). llvm-svn: 93224
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - 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
* Don't assume that all conversions to a void pointer are convertingDouglas Gregor2009-12-131-0/+10
| | | | | | from a PointerType. Fixes PR5756. llvm-svn: 91253
* First pass at implementing C++ enum semantics: calculate (and store) anJohn McCall2009-12-091-1/+1
| | | | | | | | | | | | "integer promotion" type associated with an enum decl, and use this type to determine which type to promote to. This type obeys C++ [conv.prom]p2 and is therefore generally signed unless the range of the enumerators forces it to be unsigned. Kills off a lot of false positives from -Wsign-compare in C++, addressing rdar://7455616 llvm-svn: 90965
* When we encounter a derived-to-base conversion when performing anDouglas Gregor2009-11-061-0/+13
| | | | | | | implicit conversion sequence, check the validity of this conversion and then perform it. llvm-svn: 86210
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* In C++, set the type of each of the enumerators in an enumeration toDouglas Gregor2008-12-121-3/+3
| | | | | | | | | | | | | | | the type of the enumeration once the enumeration has been defined. Fix the overloading test-case to properly create enums that promote the way we want them to. Implement C++0x promotions from enumeration types to long long/unsigned long long. We're using these promotions in Carbon.h (since long long is a common extension). Fixes PR clang/2954: http://llvm.org/bugs/show_bug.cgi?id=2954 llvm-svn: 60917
* Test conversion from apointer to incomplete type to void* in C++Douglas Gregor2008-11-261-1/+4
| | | | llvm-svn: 60131
* Simplify and correct the check for function redefinitions. This does two things:Douglas Gregor2008-10-291-2/+2
| | | | | | | | | | - Allows definitions of overloaded functions :) - Eliminates extraneous error messages when we have a definition of a function that isn't an overload but doesn't have exactly the same type as the original. llvm-svn: 58382
* Implement overloading rules for reference bindingDouglas Gregor2008-10-291-0/+22
| | | | llvm-svn: 58381
* Tweak Sema::CheckReferenceInit so that it (optionally) computes an Douglas Gregor2008-10-291-0/+28
| | | | | | | | | | | ImplicitConversionSequence and, when doing so, following the specific rules of [over.best.ics]. The computation of the implicit conversion sequences implements C++ [over.ics.ref], but we do not (yet) have ranking for implicit conversion sequences that use reference binding. llvm-svn: 58357
* Implement initialization of a reference (C++ [dcl.init.ref]) as partDouglas Gregor2008-10-291-0/+11
| | | | | | | | | | | | | | | | | | | of copy initialization. Other pieces of the puzzle: - Try/Perform-ImplicitConversion now handles implicit conversions that don't involve references. - Try/Perform-CopyInitialization uses CheckSingleAssignmentConstraints for C. PerformCopyInitialization is now used for all argument passing and returning values from a function. - Diagnose errors with declaring references and const values without an initializer. (Uses a new Action callback, ActOnUninitializedDecl). We do not yet have implicit conversion sequences for reference binding, which means that we don't have any overloading support for reference parameters yet. llvm-svn: 58353
* Add support for conversions from a pointer-to-derived to aDouglas Gregor2008-10-231-0/+29
| | | | | | | | | | | | pointer-to-base. Also, add overload ranking for pointer conversions (for both pointer-to-void and derived-to-base pointer conversions). Note that we do not yet diagnose derived-to-base pointer conversion errors that stem from ambiguous or inacessible base classes. These aren't handled during overload resolution; rather, when the conversion is actually used we go ahead and diagnose the error. llvm-svn: 58017
* Implement ranking of standard conversion sequences by their qualificationDouglas Gregor2008-10-221-1/+22
| | | | | | | | | | | | conversions (e.g., comparing int* -> const int* against int* -> const volatile int*); see C++ 13.3.3.2p3 bullet 3. Add Sema::UnwrapSimilarPointerTypes to simplify the control flow of IsQualificationConversion and CompareQualificationConversion (and fix the handling of the int* -> volatile int* conversion in the former). llvm-svn: 57978
OpenPOWER on IntegriCloud