summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/conditional-expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Implement lvalue test for conditional expressions.Sebastian Redl2009-04-171-13/+32
| | | | | | Add a few commented lines to the test case that point out things that don't work yet. llvm-svn: 69354
* Fix a crash bug when comparing overload quality of conversion operators with ↵Sebastian Redl2009-04-161-0/+144
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
OpenPOWER on IntegriCloud