summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/nullptr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.Richard Smith2016-10-211-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | This has two significant effects: 1) Direct relational comparisons between null pointer constants (0 and nullopt) and pointers are now ill-formed. This was always the case for C, and it appears that C++ only ever permitted by accident. For instance, cases like nullptr < &a are now rejected. 2) Comparisons and conditional operators between differently-cv-qualified pointer types now work, and produce a composite type that both source pointer types can convert to (when possible). For instance, comparison between 'int **' and 'const int **' is now valid, and uses an intermediate type of 'const int *const *'. Clang previously supported #2 as an extension. We do not accept the cases in #1 as an extension. I've tested a fair amount of code to check that this doesn't break it, but if it turns out that someone is relying on this, we can easily add it back as an extension. This is a re-commit of r284800. llvm-svn: 284890
* Revert "DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' ↵Renato Golin2016-10-211-23/+23
| | | | | | | | rules." This reverts commit r284800, as it failed all ARM/AArch64 bots. llvm-svn: 284811
* DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.Richard Smith2016-10-211-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | This has two significant effects: 1) Direct relational comparisons between null pointer constants (0 and nullopt) and pointers are now ill-formed. This was always the case for C, and it appears that C++ only ever permitted by accident. For instance, cases like nullptr < &a are now rejected. 2) Comparisons and conditional operators between differently-cv-qualified pointer types now work, and produce a composite type that both source pointer types can convert to (when possible). For instance, comparison between 'int **' and 'const int **' is now valid, and uses an intermediate type of 'const int *const *'. Clang previously supported #2 as an extension. We do not accept the cases in #1 as an extension. I've tested a fair amount of code to check that this doesn't break it, but if it turns out that someone is relying on this, we can easily add it back as an extension. llvm-svn: 284800
* Improvements to -Wnull-conversionRichard Trieu2014-10-151-1/+1
| | | | | | | | | Split logic to separate checking function Refine the macro checking Catch nullptr->bool conversions Add some explanatory comments llvm-svn: 219774
* Add a few more tests for casts.Eli Friedman2013-06-201-0/+3
| | | | llvm-svn: 184392
* PR15132: Replace "address expression must be an lvalue or a functionRichard Smith2013-02-021-1/+1
| | | | | | | | | | | | | | 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
* Implement final piece of DR963 and also DR587:Richard Smith2012-08-081-1/+3
| | | | | | | | | | | 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
* Convert ad-hoc `int array[expr ? -1 : 1]' assertionsDmitri Gribenko2012-02-151-24/+24
| | | | | | in test/SemaCXX/nullptr.cpp to static_assert llvm-svn: 150579
* constexpr: evaluation support for nullptr comparisons.Richard Smith2012-02-141-3/+14
| | | | llvm-svn: 150521
* Pending clear answer from WG21 on whether core issue 903 is intended to apply toRichard Smith2012-02-141-0/+11
| | | | | | | C++11 or just C++17, restrict the set of null pointer constants in C++11 mode back to those which were considered null in C++98. llvm-svn: 150510
* 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
* Audit and finish the implementation of C++0x nullptr, fixing twoDouglas Gregor2011-05-211-0/+57
| | | | | | | | | | | | | | minor issues along the way: - Non-type template parameters of type 'std::nullptr_t' were not permitted. - We didn't properly introduce built-in operators for nullptr ==, !=, <, <=, >=, or > as candidate functions . To my knowledge, there's only one (minor but annoying) part of nullptr that hasn't been implemented: catching a thrown 'nullptr' as a pointer or pointer-to-member, per C++0x [except.handle]p4. llvm-svn: 131813
* 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-1/+1
| | | | | | | | diagnostics. Patch by Stephen Hines. llvm-svn: 125998
* Initial steps to improve diagnostics when there is a NULL andChandler Carruth2011-02-181-0/+2
| | | | | | | | a non-pointer on the two sides of a conditional expression. Patch by Stephen Hines and Mihai Rusu. llvm-svn: 125995
* Don't warn when matching %p to nullptr.Anders Carlsson2010-11-061-0/+9
| | | | llvm-svn: 118344
* Expressions of type std::nullptr_t can be used as sentinels.Anders Carlsson2010-11-051-0/+9
| | | | llvm-svn: 118276
* Implement [over.ics.rank]p4: A conversion that does not convert an ↵Anders Carlsson2010-11-051-2/+17
| | | | | | std::nullptr_t to bool is better than one than does. llvm-svn: 118269
* It's OK to use nullptr in relational operators if the other side is a null ↵Anders Carlsson2010-11-041-0/+4
| | | | | | pointer constant. llvm-svn: 118234
* tests: Use -ffreestanding when including stdint.h, to avoid platform ↵Daniel Dunbar2010-09-071-1/+1
| | | | | | dependencies. llvm-svn: 113301
* Initialization improvements: addition of string initialization and a fewEli Friedman2009-12-191-1/+1
| | | | | | | | small bug fixes in SemaInit, switch over SemaDecl to use it more often, and change a bunch of diagnostics which are different with the new initialization code. llvm-svn: 91767
* 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
* Implement C++0x nullptr.Sebastian Redl2009-05-101-0/+67
llvm-svn: 71405
OpenPOWER on IntegriCloud