summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/overload-call.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implement C++ DR1391 (wg21.link/cwg1391)Richard Smith2017-01-091-1/+1
| | | | | | | | | | | | | | Check for implicit conversion sequences for non-dependent function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation. This re-commits r290808, reverted in r290811 and r291412, with a couple of fixes for handling of explicitly-specified non-trailing template argument packs. llvm-svn: 291427
* Revert r291410 and r291411.Richard Smith2017-01-091-1/+1
| | | | | | The test-suite bots are still failing even after r291410's fix. llvm-svn: 291412
* Implement C++ DR1391 (wg21.link/cwg1391)Richard Smith2017-01-091-1/+1
| | | | | | | | | | | | | Check for implicit conversion sequences for non-dependent function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation. This re-commits r290808, reverted in r290811, with a fix for handling of explicitly-specified template argument packs. llvm-svn: 291410
* Revert "DR1391: Check for implicit conversion sequences for non-dependent ↵Renato Golin2017-01-021-1/+1
| | | | | | | | | | | | | | function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation." This reverts commit r290808, as it broken all ARM and AArch64 test-suite test: MultiSource/UnitTests/C++11/frame_layout Also, please, next time, try to write a commit message in according to our guidelines: http://llvm.org/docs/DeveloperPolicy.html#commit-messages llvm-svn: 290811
* DR1391: Check for implicit conversion sequences for non-dependent functionRichard Smith2017-01-021-1/+1
| | | | | | | | | | | | template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation. This does not implement the partial ordering portion of DR1391, which so far appears to be misguided. llvm-svn: 290808
* [Sema] Compare bad conversions in overload resolution.George Burgess IV2016-09-071-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r280553 introduced an issue where we'd emit ambiguity errors for code like: ``` void foo(int *, int); void foo(unsigned int *, unsigned int); void callFoo() { unsigned int i; foo(&i, 0); // ambiguous: int->unsigned int is worse than int->int, // but unsigned int*->unsigned int* is better than // int*->int*. } ``` This patch fixes this issue by changing how we handle ill-formed (but valid) implicit conversions. Candidates with said conversions now always rank worse than candidates without them, and two candidates are considered to be equally bad if they both have these conversions for the same argument. Additionally, this fixes a case in C++11 where we'd complain about an ambiguity in a case like: ``` void f(char *, int); void f(const char *, unsigned); void g() { f("abc", 0); } ``` ...Since conversion to char* from a string literal is considered ill-formed in C++11 (and deprecated in C++03), but we accept it as an extension. llvm-svn: 280847
* PR5941 - improve diagnostic for * vs & confusion when choosing overload ↵David Blaikie2016-03-041-8/+16
| | | | | | | | | | candidate with a parameter of incomplete (ref or pointer) type Reviewers: dblaikie Differential Revision: http://reviews.llvm.org/D16949 llvm-svn: 262752
* [Lit Test] Updated 20 Lit tests to be C++11 compatible.Charles Li2015-12-101-7/+38
| | | | | | | | This is the 5th Lit test patch. Expanded expected diagnostics to vary by C++ dialect. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 255196
* Update a few more tests in response to the MS ABI enum semanticsDavid Majnemer2015-10-081-1/+1
| | | | | | | Our self hosting buildbots found a few more tests which weren't updated to reflect that the enum semantics are part of the Microsoft ABI. llvm-svn: 249670
* In C++98, if an rvalue reference binds to a function lvalue (or an xvalue or anRichard Smith2014-07-141-10/+6
| | | | | | | | array prvalue), treat that as a direct binding. Only the class prvalue case needs to be excluded here; the rest are extensions anyway, so we can treat them as we would in C++11. llvm-svn: 212978
* Superficial fix for PR20218: binding a function lvalue to a const reference toRichard Smith2014-07-141-0/+22
| | | | | | | | | | | | | a function pointer is neither better nor worse than binding a function lvalue to a function rvalue reference. Don't get confused and think that both bindings are binding to a function lvalue (which would make the lvalue form win); the const reference is binding to an rvalue. The "real" bug in PR20218 is still present: we're getting the wrong answer from template argument deduction, and that's what leads us to this weird overload set. llvm-svn: 212916
* Add testcase for r208062.Nick Lewycky2014-05-061-1/+11
| | | | llvm-svn: 208138
* 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
OpenPOWER on IntegriCloud