summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr
Commit message (Collapse)AuthorAgeFilesLines
...
* [c++1z] P0003R5: Removing dynamic exception specifications.Richard Smith2016-12-081-1/+1
| | | | | | | | | | | | | | | | | | We continue to support dynamic exception specifications in C++1z as an extension, but produce an error-by-default warning when we encounter one. This allows users to opt back into the feature with a warning flag, and implicitly opts system headers back into the feature should they happen to use it. There is one semantic change implied by P0003R5 but not implemented here: violating a throw() exception specification should now call std::terminate directly instead of calling std::unexpected(), but since P0003R5 also removes std::unexpected() and std::set_unexpected, and the default unexpected handler calls std::terminate(), a conforming C++1z program cannot tell that we are still calling it. The upside of this strategy is perfect backwards compatibility; the downside is that we don't get the more efficient 'noexcept' codegen for 'throw()'. llvm-svn: 289019
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-031-3/+3
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* PR23281: Fix implementation of DR1891 to implement the intent: that is, aRichard Smith2016-11-161-2/+2
| | | | | | lambda-expression does not have a move-assignment operator. llvm-svn: 287057
* [Sema] Allow static_cast<T&&>(e) to check explicit conversions for ↵Eric Fiselier2016-11-031-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | non-reference-related types. Summary: [expr.cast.static] states: > 3. A glvalue of type “cv1 T1” can be cast to type “rvalue reference to cv2 T2” if “cv2 T2” is reference-compatible > with “cv1 T1”. The result refers to the object or the specified base class subobject thereof. If T2 is > an inaccessible or ambiguous base class of T1, a program that necessitates such a cast is > ill-formed. > > 4. Otherwise, an expression e can be explicitly converted to a type T using a static_cast of the form static_- > cast<T>(e) if the declaration T t(e); is well-formed, for some invented temporary variable t. [...] Currently when checking p3 Clang will diagnose `static_cast<T&&>(e)` as invalid if the argument is not reference compatible with `T`. However I believe the correct behavior is to also check p4 in those cases. For example: ``` double y = 42; static_cast<int&&>(y); // this should be OK. 'int&& t(y)' is well formed ``` Note that we still don't check p4 for non-reference-compatible types which are reference-related since `T&& t(e);` should never be well formed in those cases. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26231 llvm-svn: 285872
* [c++1z] P0012R1: Implement a few remaining pieces: downgrade diagnostic forRichard Smith2016-10-222-4/+14
| | | | | | | | | | | | | | mismatched dynamic exception specifications in expressions from an error to a warning, since this is no longer ill-formed in C++1z. Allow reference binding of a reference-to-non-noexcept function to a noexcept function lvalue. As defect resolutions, also allow a conditional between noexcept and non-noexcept function lvalues to produce a non-noexcept function lvalue (rather than decaying to a function pointer), and allow function template argument deduction to deduce a reference to non-noexcept function when binding to a noexcept function type. llvm-svn: 284905
* DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.Richard Smith2016-10-211-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+9
| | | | | | | | 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-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Re-commit r284753, reverted in r284778, with a fix for PR30749.Richard Smith2016-10-201-0/+51
| | | | | | | | | | Original commit message: [c++1z] Teach composite pointer type computation how to compute the composite pointer type of two function pointers with different noexcept specifications. While I'm here, also teach it how to merge dynamic exception specifications. llvm-svn: 284785
* Revert r284753 "[c++1z] Teach composite pointer type computation how to ↵Hans Wennborg2016-10-201-45/+0
| | | | | | | | compute the composite" It caused PR30749. llvm-svn: 284778
* [c++1z] Teach composite pointer type computation how to compute the compositeRichard Smith2016-10-201-0/+45
| | | | | | | pointer type of two function pointers with different noexcept specifications. While I'm here, also teach it how to merge dynamic exception specifications. llvm-svn: 284753
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-162-2/+23
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-103-1/+150
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-103-150/+1
| | | | | | | | | | | | allocation." This reverts commit r283722. Breaks: Clang.SemaCUDA.device-var-init.cu Clang.CodeGenCUDA.device-var-init.cu http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/ llvm-svn: 283750
* P0035R4: Semantic analysis and code generation for C++17 overalignedRichard Smith2016-10-103-1/+150
| | | | | | allocation. llvm-svn: 283722
* Warn when a reference is bound to an empty l-value (dereferenced null pointer).Nick Lewycky2016-05-141-2/+2
| | | | llvm-svn: 269572
* [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)Faisal Vali2016-03-211-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement lambda capture of *this by copy. For e.g.: struct A { int d = 10; auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; } }; auto L = A{}.foo(); // A{}'s lifetime is gone. // Below is still ok, because *this was captured by value. assert(L(10) == 20); assert(L(100) == 120); If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined. Implementation Strategy: - amend the parser to accept *this in the lambda introducer - add a new king of capture LCK_StarThis - teach Sema::CheckCXXThisCapture to handle by copy captures of the enclosing object (i.e. *this) - when CheckCXXThisCapture does capture by copy, the corresponding initializer expression for the closure's data member direct-initializes it thus making a copy of '*this'. - in codegen, when assigning to CXXThisValue, if *this was captured by copy, make sure it points to the corresponding field member, and not, unlike when captured by reference, what the field member points to. - mark feature as implemented in svn Much gratitude to Richard Smith for his carefully illuminating reviews! llvm-svn: 263921
* Improve -Wconstant-conversionRichard Trieu2016-01-291-2/+2
| | | | | | | | | | | | | | Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt. EvaluateAsInt will evaluate more types of expressions than isIntegerConstantExpr. Move one case from -Wsign-conversion to -Wconstant-conversion. The case is: 1) Source and target types are signed 2) Source type is wider than the target type 3) The source constant value is positive 4) The conversion will store the value as negative in the target. llvm-svn: 259271
* PR17381: Treat undefined behavior during expression evaluation as an unmodeledRichard Smith2015-12-031-2/+2
| | | | | | | | | | | | | | | | | | | | | side-effect, so that we don't allow speculative evaluation of such expressions during code generation. This caused a diagnostic quality regression, so fix constant expression diagnostics to prefer either the first "can't be constant folded" diagnostic or the first "not a constant expression" diagnostic depending on the kind of evaluation we're doing. This was always the intent, but didn't quite work correctly before. This results in certain initializers that used to be constant initializers to no longer be; in particular, things like: float f = 1e100; are no longer accepted in C. This seems appropriate, as such constructs would lead to code being executed if sanitizers are enabled. llvm-svn: 254574
* N3922: direct-list-initialization of an auto-typed variable no longer deduces aRichard Smith2015-11-111-2/+3
| | | | | | | | | | | | | | | | | | | std::initializer_list<T> type. Instead, the list must contain a single element and the type is deduced from that. In Clang 3.7, we warned by default on all the cases that would change meaning due to this change. In Clang 3.8, we will support only the new rules -- per the request in N3922, this change is applied as a Defect Report against earlier versions of the C++ standard. This change is not entirely trivial, because for lambda init-captures we previously did not track the difference between direct-list-initialization and copy-list-initialization. The difference was not previously observable, because the two forms of initialization always did the same thing (the elements of the initializer list were always copy-initialized regardless of the initialization style used for the init-capture). llvm-svn: 252688
* Update tests touched by r249656David Majnemer2015-10-081-1/+1
| | | | | | | | | These test updates almost exclusively around the change in behavior around enum: enums without a definition are considered incomplete except when targeting MSVC ABIs. Since these tests are interested in the 'incomplete-enum' behavior, restrict them to %itanium_abi_triple. llvm-svn: 249660
* Clarify the error message when the reason the conversion is not viable is ↵Nick Lewycky2015-08-251-1/+1
| | | | | | because the returned value does not match the function return type. llvm-svn: 245979
* Instantiate function declarations in instantiated functions.Serge Pavlov2015-08-231-5/+8
| | | | | | | | | | | | | | | | | If a function declaration is found inside a template function as in: template<class T> void f() { void g(int x = T::v) except(T::w); } it must be instantiated along with the enclosing template function, including default arguments and exception specification. Together with the patch committed in r240974 this implements DR1484. Differential Revision: http://reviews.llvm.org/D11194 llvm-svn: 245810
* [Sema] Be consistent about diagnostic wording: always use "cannot".Davide Italiano2015-08-151-1/+1
| | | | | | Discussed with Richard Smith. llvm-svn: 245162
* Revert "Revert r241620 and follow-up commits" and move the initializationAdrian Prantl2015-07-081-0/+1
| | | | | | of the llvm targets from clang/CodeGen into ClangCheck.cpp and CIndex.cpp. llvm-svn: 241653
* Revert r241620 and follow-up commits while investigating linux buildbot ↵Adrian Prantl2015-07-071-1/+0
| | | | | | failures. llvm-svn: 241642
* Wrap clang modules and pch files in an object file container.Adrian Prantl2015-07-071-0/+1
| | | | | | | | | | | | | This patch adds ObjectFilePCHContainerOperations uses the LLVM backend to put the contents of a PCH into a __clangast section inside a COFF, ELF, or Mach-O object file container. This is done to facilitate module debugging by makeing it possible to store the debug info for the types defined by a module alongside the AST. rdar://problem/20091852 llvm-svn: 241620
* [Sema] Warn when shifting a negative value.Davide Italiano2015-07-061-1/+1
| | | | | | | | | | | | | | | Example: % ./clang -Wshift-negative-value emit.c emit.c:3:14: warning: shifting a negative signed value is undefined [-Wshift-negative-value] int a = -1 << 3; ~~ ^ 1 warning generated. PR: 24026 Differential Revision: http://reviews.llvm.org/D10938 Reviewed by: rsmith llvm-svn: 241478
* Fix typo from r237482. "to reference of type" --> "to reference to type"Richard Trieu2015-05-161-4/+4
| | | | llvm-svn: 237507
* When emitting a dropped qualifier error, show which qualifiers are dropped.Richard Trieu2015-05-161-4/+4
| | | | llvm-svn: 237505
* Reverse the order of types in the reference dropping qualifiers error.Richard Trieu2015-05-151-4/+4
| | | | | | | | The error has the form ... 'int' ... 'const int' ... dropped qualifiers. At first glance, it appears that the const qualifier is added. Reverse the types so that the second type is less qualified than the first. llvm-svn: 237482
* PR23334: Perform semantic checking of lambda capture initialization in the ↵Richard Smith2015-04-272-6/+6
| | | | | | | | | | | | | | | | | | right context. Previously we'd try to perform checks on the captures from the middle of parsing the lambda's body, at the point where we detected that a variable needed to be captured. This was wrong in a number of subtle ways. In PR23334, we couldn't correctly handle the list of potential odr-uses resulting from the capture, and our attempt to recover from that resulted in a use-after-free. We now defer building the initialization expression until we leave the lambda body and return to the enclosing context, where the initialization does the right thing. This patch only covers lambda-expressions, but we should apply the same change to blocks and captured statements too. llvm-svn: 235921
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-11/+11
| | | | llvm-svn: 230795
* Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl2015-02-251-1/+0
| | | | llvm-svn: 230454
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-251-0/+1
| | | | | | | | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. This reapplies r230044 with a fixed configure+make build and updated dependencies and testcase requirements. Over the last iteration this version adds - missing target requirements for testcases that specify an x86 triple, - a missing clangCodeGen.a dependency to libClang.a in the make build. rdar://problem/19104245 llvm-svn: 230423
* Add a warning for direct-list-initialization of a variable with a deduced typeRichard Smith2015-02-111-2/+2
| | | | | | | | (or of a lambda init-capture, which is sort-of such a variable). The semantics of such constructs will change when we implement N3922, so we intend to warn on this in Clang 3.6 then change the semantics in Clang 3.7. llvm-svn: 228792
* Update error message text.Serge Pavlov2015-01-181-2/+2
| | | | | | | | | Previously if an enumeration was used in a nested name specifier in pre-C++11 language dialect, error message was 'XXX is not a class, namespace, or scoped enumeration'. This patch removes the word 'scoped' as in C++11 any enumeration may be used in this context. llvm-svn: 226410
* DR1048: drop top-level cv-qualifiers when deducing the return type of aRichard Smith2014-12-191-5/+2
| | | | | | lambda-expression in C++11, to match the C++14 rules. llvm-svn: 224620
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-173-3/+3
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* DR1891, PR21787: a lambda closure type has no default constructor, rather thanRichard Smith2014-12-102-5/+5
| | | | | | having a deleted default constructor. llvm-svn: 223953
* [c++1z] Most of N4268 (allow constant evaluation for non-type template ↵Richard Smith2014-11-261-3/+3
| | | | | | | | | arguments). We don't yet support pointer-to-member template arguments that have undergone pointer-to-member conversions, mostly because we don't have a mangling for them yet. llvm-svn: 222807
* Handle use of default member initializers before end of outermost classReid Kleckner2014-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, when we have this situation: struct A { template <typename T> struct B { int m1 = sizeof(A); }; B<int> m2; }; We can't parse m1's initializer eagerly because we need A to be complete. Therefore we wait until the end of A's class scope to parse it. However, we can trigger instantiation of B before the end of A, which will attempt to instantiate the field decls eagerly, and it would build a bad field decl instantiation that said it had an initializer but actually lacked one. Fixed by deferring instantiation of default member initializers until they are needed during constructor analysis. This addresses a long standing FIXME in the code. Fixes PR19195. Reviewed By: rsmith Differential Revision: http://reviews.llvm.org/D5690 llvm-svn: 222192
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-3/+2
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* PR21180: Lambda closure types are neither aggregates nor literal types.Richard Smith2014-10-072-1/+6
| | | | llvm-svn: 219222
* More fixes for isBetterOverloadCandidate not being a strict weak ordering. TheRichard Smith2014-05-171-0/+18
| | | | | | bug was obvious from inspection, figuring out a way to test it was... less so. llvm-svn: 209060
* PR19346: Adding 0 to a null pointer has defined behavior in C++. Allow it in ↵Richard Smith2014-04-081-1/+3
| | | | | | constant expressions. llvm-svn: 205757
* Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda ↵David Blaikie2014-04-021-1/+1
| | | | | | | | | | | | at ... )') For namespaces, this is consistent with mangling and GCC's debug info behavior. For structs, GCC uses <anonymous struct> but we prefer consistency between all anonymous entities but don't want to confuse them with template arguments, etc, so we'll just go with parens in all cases. llvm-svn: 205398
* Creating a printing policy for "half":Yunzhong Gao2014-03-181-1/+1
| | | | | | | | | | | | Since "half" is an OpenCL keyword and clang accepts __fp16 as an extension for other languages, error messages and metadata (and hence debug info) should refer to the half-precision floating point as "__fp16" instead of "half" when compiling for non-OpenCL languages. This patch creates a new printing policy for half in a similar manner to what is done for bool and wchar_t. Differential Revision: http://llvm-reviews.chandlerc.com/D2952 llvm-svn: 204164
* DR1346: a parenthesized braced-init-list cannot be used as the initializer whenRichard Smith2014-03-121-0/+2
| | | | | | performing auto type deduction. llvm-svn: 203683
* Normalize line endingsDavid Majnemer2014-03-022-156/+156
| | | | | | | Some files had CRLF line terminators, some only had a mixture of CRLF and LF. Switch to LF. llvm-svn: 202659
OpenPOWER on IntegriCloud