summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/conditional-expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Support lifetime-extension of conditional temporaries.Richard Smith2018-07-231-5/+1
| | | | llvm-svn: 337767
* Do not try to perform lifetime-extension through conditionalRichard Smith2018-07-231-1/+21
| | | | | | | | | expressions. CodeGen can't cope with that yet. Instead, produce a "not supported" warning for now and don't extend lifetime. llvm-svn: 337744
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* Fix clang's handling of the copy performed in the second phase of classRichard Smith2016-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | copy-initialization. We previously got this wrong in a couple of ways: - we only looked for copy / move constructors and constructor templates for this copy, and thus would fail to copy in cases where doing so should use some other constructor (but see core issue 670), - we mishandled the special case for disabling user-defined conversions that blocks infinite recursion through repeated application of a copy constructor (applying it in slightly too many cases) -- though as far as I can tell, this does not ever actually affect the result of overload resolution, and - we misapplied the special-case rules for constructors taking a parameter whose type is a (reference to) the same class type by incorrectly assuming that only happens for copy/move constructors (it also happens for constructors instantiated from templates and those inherited from base classes). These changes should only affect strange corner cases (for instance, where the copy constructor exists but has a non-const-qualified parameter type), so for the most part it only causes us to produce more 'candidate' notes, but see the test changes for other cases whose behavior is affected. llvm-svn: 280776
* Implement support for conditional between xvalues of reference-compatibleRichard Smith2016-04-251-0/+9
| | | | | | types. Patch by Erik Pilkington! llvm-svn: 267454
* PR17052 / DR1560 (+DR1550): In a conditional expression between a glvalue and aRichard Smith2014-01-271-5/+22
| | | | | | | throw-expression, the result is also a glvalue and isn't unnecessarily coerced to a prvalue. llvm-svn: 200189
* Allow paren casted throw statements inside of ternary expressionsDavid Majnemer2013-06-021-0/+2
| | | | | | | | | | | | | | clang would incorrectly not allow the following: int x = true ? (throw 1) : 2; The problem exists because we don't see beyond the parens. This, in turn, causes us to believe that we are choosing between void and int which we diagnose as an error. Instead, allow clang to see the 'throw' inside the parens. llvm-svn: 183085
* PR15132: Replace "address expression must be an lvalue or a functionRichard Smith2013-02-021-2/+2
| | | | | | | | | | | | | | designator" diagnostic with more correct and more human-friendly "cannot take address of rvalue of type 'T'". For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully saying "cannot take address of rvalue of type '<overloaded function type>'". For the case of &array_temporary, treat it just like a class temporary (including allowing it as an extension); the existing diagnostic wording for the class temporary case works fine. llvm-svn: 174262
* Fix PR13784: instantiation of an abstract class in a conditional operator.David Blaikie2012-09-101-0/+13
| | | | | | | | | | | | A couple of missing "RequireNonAbstractType" calls in conditional operator handling. I looked for opportunities to tie this check in to all relevant callers of PerformCopyInitialization (couldn't be all callers since this is called for base subobject copying too, where it's acceptable to copy abstract types) but the callers varied too much & in many cases had substantial code or conditionals on the RequireNonAbstractType call, the PerformCopyInitialization call, or the code between the two calls. llvm-svn: 163555
* Implement final piece of DR963 and also DR587:Richard Smith2012-08-081-1/+25
| | | | | | | | | | | A conditional operator between glvalues of types cv1 T and cv2 T produces a glvalue if the expressions are of the same value kind and one of cv1 and cv2 is a subset of the other. A conditional operator between two null pointer constants is permitted if one of them is of type std::nullptr_t. llvm-svn: 161476
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* PR10828: Produce a warning when a no-arguments function is declared in blockRichard Smith2012-01-051-2/+2
| | | | | | | | | | | | | | | | | scope, when no other indication is provided that the user intended to declare a function rather than a variable. Remove some false positives from the existing 'parentheses disambiguated as a function' warning by suppressing it when the declaration is marked as 'typedef' or 'extern'. Add a new warning group -Wvexing-parse containing both of these warnings. The new warning is enabled by default; despite a number of false positives (and one bug) in clang's test-suite, I have only found genuine bugs with it when running it over a significant quantity of real C++ code. llvm-svn: 147599
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-1/+1
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Remove warning for conditional operands of differend signedness from ↵Richard Trieu2011-07-211-8/+15
| | | | | | -Wsign-compare. Cases that previously warn on this will have a different warning emitted from -Wsign-conversion. llvm-svn: 135664
* Add -fcxx-exceptions to all tests that use C++ exceptions.Anders Carlsson2011-02-281-1/+1
| | | | llvm-svn: 126599
* Pass -fexceptions to all tests that use try/catch/throw.Anders Carlsson2011-02-191-1/+1
| | | | llvm-svn: 126037
* Fix a missed case in the NULL operand to conditional operatorChandler Carruth2011-02-191-0/+2
| | | | | | | | diagnostics. Patch by Stephen Hines. llvm-svn: 125998
* Initial steps to improve diagnostics when there is a NULL andChandler Carruth2011-02-181-0/+12
| | | | | | | | a non-pointer on the two sides of a conditional expression. Patch by Stephen Hines and Mihai Rusu. llvm-svn: 125995
* Re-instate r123977/r123978, my updates of the reference-bindingDouglas Gregor2011-01-241-1/+4
| | | | | | | | | | | | | | | | implementation used by overload resolution to support rvalue references. The original commits caused PR9026 and some hard-to-reproduce self-host breakage. The only (crucial!) difference between this commit and the previous commits is that we now properly check the SuppressUserConversions flag before attempting to perform a second user-defined conversion in reference binding, breaking the infinite recursion chain of user-defined conversions. Rvalue references should be working a bit better now. llvm-svn: 124121
* revert r123977 and r123978 to fix PR9026.Rafael Espindola2011-01-221-4/+1
| | | | llvm-svn: 124033
* Update the reference-binding implementation used for overloadDouglas Gregor2011-01-211-1/+4
| | | | | | | | resolution to match the latest C++0x working paper's semantics. The implementation now matching up with the reference-binding implementation used for initialization. llvm-svn: 123977
* 'const std::type_info*' instead of 'std::type_info const*'Chris Lattner2010-09-051-2/+2
| | | | llvm-svn: 113092
* Wire up '-Wignored-qualifiers' to the warning on 'const' in 'const int f()'.Chandler Carruth2010-07-141-2/+2
| | | | | | | | | This flag and warning match GCC semantics. Also, move it to -Wextra as this is a largely cosmetic issue and doesn't seem to mask problems. Subsequent fixes to the tests which no longer by default emit the warning. Added explicit test cases for both C and C++ behavior with the warning turned on. llvm-svn: 108325
* Improve diagnostics for the "type qualifier on return type has noDouglas Gregor2010-07-131-0/+5
| | | | | | | | | | | | effect warning" by printing the qualifiers we saw and correctly pluralizing the message, e.g., test/SemaCXX/conditional-expr.cpp:295:3: warning: 'const volatile' type qualifiers on return type have no effect const volatile Enum g2() { ^~~~~ ~~~~~~~~ llvm-svn: 108236
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-0/+17
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* When performing copy initialization via user-defined conversions,Douglas Gregor2010-07-011-1/+8
| | | | | | don't allow two user-defined conversions. Fixes PR6595 (again). llvm-svn: 107379
* When a conditional operator is an rvalue of class type, we need toDouglas Gregor2010-05-191-0/+20
| | | | | | | | | | create a temporary copy of both the "true" and "false" results. Fixes the Boost.Interprocess failures. Daniel did all the hard work of tracking down the issue, I get to type up the trivial fix for this horrible miscompile. llvm-svn: 104184
* Rearchitect -Wconversion and -Wsign-compare. Instead of computing themJohn McCall2010-05-061-0/+17
| | | | | | | | | | | | | | "bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. llvm-svn: 103174
* When we are performing copy initialization of a class type via itsDouglas Gregor2010-04-241-2/+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
* Improve our handling of user-defined conversions as part of overloadDouglas Gregor2010-04-171-3/+2
| | | | | | | | | | | | | | | | | 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
* Turn access control on by default in -cc1.John McCall2010-04-091-1/+1
| | | | | | | | Remove -faccess-control from -cc1; add -fno-access-control. Make the driver pass -fno-access-control by default. Update a bunch of tests to be correct under access control. llvm-svn: 100880
* Rework our handling of copy construction of temporaries, which was aDouglas Gregor2010-04-021-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | poor (and wrong) approximation of the actual rules governing when to build a copy and when it can be elided. The correct implementation is actually simpler than the approximation. When we only enumerate constructors as part of initialization (e.g., for direct initialization or when we're copying from a class type or one of its derived classes), we don't create a copy. When we enumerate all conversion functions, we do create a copy. Before, we created some extra copies and missed some others. The new test copy-initialization.cpp shows a case where we missed creating a (required, non-elidable) copy as part of a user-defined conversion, which resulted in a miscompile. This commit also fixes PR6757, where the missing copy made us reject well-formed code in the ternary operator. This commit also cleans up our handling of copy elision in the case where we create an extra copy of a temporary object, which became necessary now that we produce the right copies. The code that seeks to find the temporary object being copied has moved into Expr::getTemporaryObject(); it used to have two different not-quite-the-same implementations, one in Sema and one in CodeGen. Note that we still do not attempt to perform the named return value optimization, so we miss copy elisions for return values and throw expressions. llvm-svn: 100196
* When trying to determine whether one operand of a conditionalDouglas Gregor2010-03-261-0/+15
| | | | | | | | | expression can be converted to the type of another, only apply the lvalue-to-rvalue conversion to the type of the expression we're converting, *not* the array-to-pointer or function-to-pointer conversions. Fixes PR6595. llvm-svn: 99652
* Switch semantic analysis of the conditional operator from usingDouglas Gregor2010-03-261-1/+2
| | | | | | CheckReferenceInit to using the new initialization sequence code. llvm-svn: 99647
* Promote enum types during -Wsign-compare. Fixes some spurious warnings,John McCall2010-03-191-3/+3
| | | | | | mostly during conditional expressions. llvm-svn: 98975
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-11/+11
| | | | | | | | | | 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 access control diagnostics. Perform access control on member-pointerJohn McCall2010-02-101-5/+5
| | | | | | | conversions. Fix an access-control bug where privileges were not considered at intermediate points along the inheritance path. Prepare for friends. llvm-svn: 95775
* Chris thinks these diagnostics are better now. :)John McCall2010-01-121-1/+0
| | | | llvm-svn: 93216
* Introduce a specific representation for the ambiguous implicit conversionJohn McCall2010-01-121-8/+8
| | | | | | | sequence. Lots of small relevant changes. Fixes some serious problems with ambiguous conversions; also possibly improves associated diagnostics. llvm-svn: 93214
* Switch initialization of parameters in a call over toDouglas Gregor2009-12-221-6/+5
| | | | | | | | | | | InitializationSequence (when a FunctionDecl is present). This required a few small fixes to initialization sequences: - Make sure to use the adjusted parameter type for initialization of function parameters. - Implement transparent union calling semantics in C llvm-svn: 91902
* 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
* Turn off -Wsign-compare warnings by defaultDouglas Gregor2009-11-061-1/+1
| | | | llvm-svn: 86233
* Implement the conditional-operator part of -Wsign-compare. TurnJohn McCall2009-11-051-2/+20
| | | | | | | | | | | | 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
* Diagnose taking the address of a bit-field inside a conditional operator.Anders Carlsson2009-09-141-1/+3
| | | | llvm-svn: 81808
* Implement support for equality comparisons (!=, ==) of memberDouglas Gregor2009-08-241-1/+1
| | | | | | | | | | pointers, by extending the "composite pointer type" logic to include member pointer types. Introduce test cases for member pointer comparisons, including those that involve the builtin operator candidates implemented earlier. llvm-svn: 79925
* Disable access control by default. It can be enabled with the ↵Anders Carlsson2009-05-131-1/+1
| | | | | | -faccess-control option. When we have better support for it, we can enable it by default again. llvm-svn: 71706
* Make reference class unification in conditional expressions check for ↵Sebastian Redl2009-04-261-5/+5
| | | | | | validity of the conversion. llvm-svn: 70121
* Conditional operator C++ checking complete. What issues remain are in more ↵Sebastian Redl2009-04-191-4/+10
| | | | | | general code. llvm-svn: 69555
* Bring member pointer operands of the conditional operator to a common type. ↵Sebastian Redl2009-04-191-5/+17
| | | | | | We're getting there ... llvm-svn: 69548
* Another piece of the conditional operator puzzle. We'll want to use ↵Sebastian Redl2009-04-191-5/+5
| | | | | | FindCompositePointerType in some other places, too. llvm-svn: 69534
OpenPOWER on IntegriCloud