summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/conversion-function.cpp
Commit message (Collapse)AuthorAgeFilesLines
* When diagnosing the lack of a viable conversion function, also listRichard Smith2020-01-091-1/+1
| | | | | | | | | | | | | | explicit functions that are not candidates. It's not always obvious that the reason a conversion was not possible is because the function you wanted to call is 'explicit', so explicitly say if that's the case. It would be nice to rank the explicit candidates higher in the diagnostic if an implicit conversion sequence exists for their arguments, but unfortunately we can't determine that without potentially triggering non-immediate-context errors that we're not permitted to produce.
* Correctly diagnose when a conversion function is declared with a type ↵Aaron Ballman2018-04-121-0/+10
| | | | | | qualifier in the declaration specifiers rather than in the conversion type id. Fixes PR30595. llvm-svn: 329924
* Bail out if we try to build a DeclRefExpr naming an invalid declaration.Richard Smith2017-01-041-1/+1
| | | | | | | | | | | Most code paths would already bail out in this case, but certain paths, particularly overload resolution and typo correction, would not. Carrying on with an invalid declaration could in some cases result in crashes due to downstream code relying on declaration invariants that are not necessarily met for invalid declarations, and in other cases just resulted in undesirable follow-on diagnostics. llvm-svn: 291030
* Mark invalid RecordDecls as completed.Erik Verbruggen2016-10-271-1/+5
| | | | | | | | | | | | | | | Sema::ActOnTag creates TagDecls for records. However, if those record declarations are invalid, and the parser is in C++ mode, it would silently drop the TagDecl (and leave it as "beingDefined"). The problem is that other code (e.g. the ASTWriter) will serialize all types, and expects them to be complete. So, leaving them open would result in failing asserts. Fixes PR20320 Differential Revision: http://reviews.llvm.org/D21176 llvm-svn: 285275
* Lit C++11 Compatibility Patch #8Charles Li2016-04-141-3/+26
| | | | | | 24 tests have been updated for C++11 compatibility. llvm-svn: 266387
* 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
* PR21969: Improve diagnostics for a conversion function that has any pieces of aRichard Smith2014-12-191-6/+4
| | | | | | declared return type (including a trailing-return-type in C++14). llvm-svn: 224561
* Change -Wbind-to-temporary-copy from an ExtWarn to an Extension.Nico Weber2014-09-181-1/+1
| | | | | | | | | | | | | | | | | The reasoning is that this construct is accepted by all compilers and valid in C++11, so it doesn't seem like a useful warning to have enabled by default. Building with -pedantic, -Wbind-to-temporary-copy, or -Wc++98-compat still shows the warning. The motivation is that I built re2, and this was the only warning that was emitted during the build. Both changing re2 to fix the warning and detecting clang and suppressing the warning in re2's build seem inferior than just giving the compiler a good default for this warning. Also move the cxx98compat version of this warning to CXX98CompatPedantic, and update tests accordingly. llvm-svn: 218008
* Follow-up to r208481: Free all default arguments, not just the first one.Nico Weber2014-05-111-1/+1
| | | | | | Also add test coverage for this case. Found by Richard Smith! llvm-svn: 208484
* Add test coverage for invalid conversion functions with default args.Nico Weber2014-05-101-0/+3
| | | | | | | This currently leaks memory (PR19689) but wasn't covered by tests, so LSan couldn't find it. llvm-svn: 208477
* Replace "can not" with "cannot" in diagnostics messages.Ismail Pazarbasi2014-03-071-2/+2
| | | | llvm-svn: 203302
* PR18234: Mark a tag definition as invalid early if it appears in aRichard Smith2014-01-081-0/+11
| | | | | | | | type-specifier in C++. Some checks will assert in this case otherwise (in particular, the access specifier may be missing if this happens inside a class definition, due to a violation of an AST invariant). llvm-svn: 198721
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-1/+1
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
* Clean up warning and add a test.Eli Friedman2013-06-201-0/+2
| | | | llvm-svn: 184466
* A conversion operator in a base class shouldn't hide another conversion operatorRichard Smith2012-05-061-0/+11
| | | | | | in the same class, even if they convert to the same type. Fixes PR12712. llvm-svn: 156247
* PR8800: When building a conversion to A& using a member operatorA&(), do not ↵Richard Smith2011-07-131-0/+14
| | | | | | require A to be a complete type. llvm-svn: 135101
* When performing template argument deduction for a non-referenceDouglas Gregor2011-03-061-0/+25
| | | | | | | | | conversion function when we're binding the result to a reference, drop cv-qualifiers on the type we're referring to, since we should be deducing a type that can be adjusted (via cv-qualification) to the requested type. Fixes PR9336, and the remaining Boost.Assign failure. llvm-svn: 127117
* When performing overload resolution, only compare the final conversionDouglas Gregor2010-09-121-0/+10
| | | | | | | sequences for two conversion functions when in fact we are in the text of initialization by a user-defined conversion sequences. Fixes PR8034. llvm-svn: 113724
* Don't complain about useless user-defined conversion functions whenDouglas Gregor2010-09-121-0/+18
| | | | | | | they were instantiated from a template. In template metaprogramming, stuff happens. Fixes PR8065. llvm-svn: 113722
* make clang print types as "const int *" instead of "int const*",Chris Lattner2010-09-051-1/+1
| | | | | | | 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
* We don't actually need to check the implicit object argument'sDouglas Gregor2010-08-191-0/+18
| | | | | | | | | conversion a second time for a conversion candidate (with the real acting context), because the only problems we would find are access or ambiguity issues that won't be diagnosed until we pick this candidate. Add a test case to prove it to myself. llvm-svn: 111526
* Properly implement the part of C++ [over.match.funcs]p4 that treatsDouglas Gregor2010-08-191-0/+37
| | | | | | | | | | | conversion functions as if their acting context were the class that we're converting from (the implicit object argument's type). Retroactively tweaking the implicit conversion sequence, as we were trying to do before, breaks the invariants of that implicit conversion sequence (e.g., the types and conversions don't match up). Fixes <rdar://problem/8018274>. llvm-svn: 111520
* There is no pointer conversion between to similar types (i.e., sameDouglas Gregor2010-08-181-0/+22
| | | | | | | type ignoring cv-qualifiers). These are qualification conversions. Fixes PR7934. llvm-svn: 111428
* Improve our handling of user-defined conversions when computingDouglas Gregor2010-08-111-0/+34
| | | | | | | | | | | | | | | | | | | | | | implicit conversion sequences. In particular, model the "standard conversion" from a class to its own type (or a base type) directly as a standard conversion in the normal path *without* trying to determine if there is a valid copy constructor. This appears to match the intent of C++ [over.best.ics]p6 and more closely matches GCC and EDG. As part of this, model non-lvalue reference initialization via user-defined conversion in overloading the same way we handle it in InitializationSequence, separating the "general user-defined conversion" and "conversion to compatible class type" cases. The churn in the overload-call-copycon.cpp test case is because the test case was originally wrong; it assumed that we should do more checking for copy constructors that we actually should, which affected overload resolution. Fixes PR7055. Bootstrapped okay. llvm-svn: 110773
* Ted pointed out that this test case could be using access control instead ofJohn McCall2010-07-221-6/+5
| | | | | | | __attribute__((unavailable)). I've done so, but unfortunately there's still a case of redundant diagnostics. llvm-svn: 109192
* When we are performing copy initialization of a class type via itsDouglas Gregor2010-04-241-1/+14
| | | | | | | | | | | 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
* Improve our handling of user-defined conversions as part of overloadDouglas Gregor2010-04-171-1/+27
| | | | | | | | | | | | | | | | | resolution. There are two sources of problems involving user-defined conversions that this change eliminates, along with providing simpler interfaces for checking implicit conversions: - It eliminates a case of infinite recursion found in Boost. - It eliminates the search for the constructor needed to copy a temporary generated by an implicit conversion from overload resolution. Overload resolution assumes that, if it gets a value of the parameter's class type (or a derived class thereof), there is a way to copy if... even if there isn't. We now model this properly. llvm-svn: 101680
* Diagnose declarations of conversion functions with declarators other than '()'.John McCall2010-04-131-0/+11
| | | | llvm-svn: 101098
* Improve source-location information for C++ conversion functions, byDouglas Gregor2010-04-121-0/+34
| | | | | | | | | | | | | | | | | copying the type location information from the conversion-type-id into the type location information for the function type. Do something similar for constructors and destructors, by giving their "void" return type source-location information. In all of these cases, we previously left this type-source information uninitialized, which led to various unfortunate crashes. We still aren't tracking good source-location information for the actual names. That's PR6357. John, please check my sanity on this. llvm-svn: 101088
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-5/+5
| | | | | | | | | | therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag). Most of these testcase changes were done by script, so don't feel too sorry for my fingers. llvm-svn: 98149
* Improve the diagnostics used to report implicitly-generated class membersJohn McCall2010-01-061-2/+2
| | | | | | | | | as parts of overload sets. Also, refer to constructors as 'constructors' rather than functions. Adjust a lot of tests. llvm-svn: 92832
* Switch more of Sema::CheckInitializerTypes over toDouglas Gregor2009-12-191-4/+4
| | | | | | | | | | InitializationSequence. Specially, switch initialization of a C++ class type (either copy- or direct-initialization). Also, make sure that we create an elidable copy-construction when performing copy initialization of a C++ class variable. Fixes PR5826. llvm-svn: 91750
* Switch the initialization required by return statements over to theDouglas Gregor2009-12-181-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | new InitializationSequence. This fixes some bugs (e.g., PR5808), changed some diagnostics, and caused more churn than expected. What's new: - InitializationSequence now has a "C conversion sequence" category and step kind, which falls back to - Changed the diagnostics for returns to always have the result type of the function first and the type of the expression second. CheckSingleAssignmentConstraints to peform checking in C. - Improved ASTs for initialization of return values. The ASTs now capture all of the temporaries we need to create, but intentionally do not bind the tempoary that is actually returned, so that it won't get destroyed twice. - Make sure to perform an (elidable!) copy of the class object that is returned from a class. - Fix copy elision in CodeGen to properly see through the subexpressions that occur with elidable copies. - Give "new" its own entity kind; as with return values and thrown objects, we don't bind the expression so we don't call a destructor for it. Note that, with this patch, I've broken returning move-only types in C++0x. We'll fix it later, when we tackle NRVO. llvm-svn: 91669
* Introduce a centralized routine in Sema for diagnosing failed lookups (whenJohn McCall2009-12-161-1/+1
| | | | | | | | | used as expressions). In dependent contexts, try to recover by doing a lookup in previously-dependent base classes. We get better diagnostics out, but unfortunately the recovery fails: we need to turn it into a method call expression, not a bare call expression. Thus this is still a WIP. llvm-svn: 91525
* 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
* When performing copy initialization (= "implicit conversion", here) toDouglas Gregor2009-11-131-1/+29
| | | | | | | | | a class type from itself or a derived class thereof, enumerate constructors and permit user-defined conversions to the arguments of those constructors. This fixes the wacky implicit conversion sequence used in std::auto_ptr's lame emulation of move semantics. llvm-svn: 88670
* Issue a good diagnostics when attempt to selectFariborz Jahanian2009-09-151-3/+3
| | | | | | a type convesion function results in ambiguity. llvm-svn: 81812
* Used visible conversion function api to do overloadFariborz Jahanian2009-09-141-0/+18
| | | | | | | resolution of type conversion functions in base and current class. llvm-svn: 81784
* Perform the C++ specific semantic checks of a function declaration after ↵Anders Carlsson2009-09-131-0/+11
| | | | | | it's been merged with the previous declaration. This ensures that getPreviousDecl() will have the right value when ActOnConversionDeclarator is called. llvm-svn: 81720
* change a couple more c++ sema methods to be based on isinvalid bits.Chris Lattner2009-04-251-2/+5
| | | | llvm-svn: 70022
* Fix a crash bug when comparing overload quality of conversion operators with ↵Sebastian Redl2009-04-161-0/+11
| | | | | | | | | | | conversion constructors. Remove an atrocious amount of trailing whitespace in the overloaded operator mangler. Sorry, couldn't help myself. Change the DeclType parameter of Sema::CheckReferenceInit to be passed by value instead of reference. It wasn't changed anywhere. Let the parser handle C++'s irregular grammar around assignment-expression and conditional-expression. And finally, the reason for all this stuff: implement C++ semantics for the conditional operator. The implementation is complete except for determining lvalueness. llvm-svn: 69299
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Fix our semantic analysis ofDouglas Gregor2009-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | unqualified-id '(' in C++. The unqualified-id might not refer to any declaration in our current scope, but declarations by that name might be found via argument-dependent lookup. We now do so properly. As part of this change, CXXDependentNameExpr, which was previously designed to express the unqualified-id in the above constructor within templates, has become UnresolvedFunctionNameExpr, which does effectively the same thing but will work for both templates and non-templates. Additionally, we cope with all unqualified-ids, since ADL also applies in cases like operator+(x, y) llvm-svn: 63733
* Make all the 'redefinition' diagnostics more consistent, and make the Chris Lattner2008-11-231-2/+2
| | | | | | "previously defined here" diagnostics all notes. llvm-svn: 59920
* As threatened previously: consolidate name lookup and the creation ofDouglas Gregor2008-11-181-1/+1
| | | | | | | | | | | | | | DeclRefExprs and BlockDeclRefExprs into a single function Sema::ActOnDeclarationNameExpr, eliminating a bunch of duplicate lookup-name-and-check-the-result code. Note that we still have the three parser entry points for identifiers, operator-function-ids, and conversion-function-ids, since the parser doesn't (and shouldn't) know about DeclarationNames. This is a Good Thing (TM), and there will be more entrypoints coming (e.g., for C++ pseudo-destructor expressions). llvm-svn: 59527
* Eliminate all of the placeholder identifiers used for constructors,Douglas Gregor2008-11-171-0/+2
| | | | | | | | | destructors, and conversion functions. The placeholders were used to work around the fact that the parser and some of Sema really wanted declarators to have simple identifiers; now, the code that deals with declarators will use DeclarationNames. llvm-svn: 59469
* Updated IdentifierResolver to deal with DeclarationNames. The names ofDouglas Gregor2008-11-171-0/+8
| | | | | | | | | | | | | | | | | | | | | C++ constructors, destructors, and conversion functions now have a FETokenInfo field that IdentifierResolver can access, so that these special names are handled just like ordinary identifiers. A few other Sema routines now use DeclarationNames instead of IdentifierInfo*'s. To validate this design, this code also implements parsing and semantic analysis for id-expressions that name conversion functions, e.g., return operator bool(); The new parser action ActOnConversionFunctionExpr takes the result of parsing "operator type-id" and turning it into an expression, using the IdentifierResolver with the DeclarationName of the conversion function. ActOnDeclarator pushes those conversion function names into scope so that the IdentifierResolver can find them, of course. llvm-svn: 59462
* Parsing, ASTs, and semantic analysis for the declaration of conversionDouglas Gregor2008-11-071-0/+42
functions in C++, e.g., struct X { operator bool() const; }; Note that these conversions don't actually do anything, since we don't yet have the ability to use them for implicit or explicit conversions. llvm-svn: 58860
OpenPOWER on IntegriCloud