summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX
Commit message (Collapse)AuthorAgeFilesLines
...
* PR38627: Fix handling of exception specification adjustment forRichard Smith2018-09-052-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. llvm-svn: 341499
* Improve diagnostic for missing comma in template parameter list.Richard Smith2018-08-171-3/+6
| | | | | | | | | | Given 'typename T typename U', we would correctly diagnose the missing comma, but incorrectly disambiguate the first parameter as being a non-type parameter and complain that the 'T' is not a qualified-id. See also gcc.gnu.org/PR86998. llvm-svn: 340074
* [Sema] P0961R1: Relaxing the structured bindings customization point finding ↵Erik Pilkington2018-08-091-6/+71
| | | | | | | | rules Differential revision: https://reviews.llvm.org/D50418 llvm-svn: 339375
* Clean up and simplify RequireCompleteType.Richard Smith2018-08-071-1/+1
| | | | | | | No functional change intended, except that we will now produce more "declared here" notes. llvm-svn: 339187
* Diagnose invalid cv-qualifiers for friend decls.Eli Friedman2018-08-031-2/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D45712 llvm-svn: 338931
* Add missing temporary materialization conversion on left-hand side of .Richard Smith2018-07-271-1/+1
| | | | | | | | | in some member function calls. Specifically, when calling a conversion function, we would fail to create the AST node representing materialization of the class object. llvm-svn: 338135
* Warn if a local variable's initializer retains a pointer/reference to aRichard Smith2018-07-241-2/+2
| | | | | | non-lifetime-extended temporary object. llvm-svn: 337790
* Fold -Wreturn-stack-address into general initialization lifetimeRichard Smith2018-07-235-25/+26
| | | | | | checking. llvm-svn: 337743
* [Sema] Diagnose an invalid dependent function template specializationErik Pilkington2018-07-191-0/+28
| | | | | | | | | | | Previously, clang marked the specialization as invalid without emitting a diagnostic. This lead to an assert in CodeGen. rdar://41806724 Differential revision: https://reviews.llvm.org/D49085 llvm-svn: 337497
* DR330: when determining whether a cast casts away constness, considerRichard Smith2018-07-181-0/+22
| | | | | | | | | | | | | | | | qualifiers from all levels matching a multidimensional array. For example, this allows casting from pointer to array of array of const volatile int to pointer to const pointer to volatile pointer to int because the multidimensional array part of the source type corresponds to a part of the destination type that contains both 'const' and 'volatile'. Differential Revision: https://reviews.llvm.org/D49457 llvm-svn: 337422
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-176-10/+128
| | | | | | | | | | | | | This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. This reinstates r337226, reverted in r337255, with a fix for the InitializedEntity alignment problem that was breaking ARM buildbots. llvm-svn: 337329
* Temporarily revert r337226 "Restructure checking for, and warning on, ↵Florian Hahn2018-07-176-128/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | lifetime extension." This change breaks on ARM because pointers to clang::InitializedEntity are only 4 byte aligned and do not have 3 bits to store values. A possible solution would be to change the fields in clang::InitializedEntity to enforce a bigger alignment requirement. The error message is llvm/include/llvm/ADT/PointerIntPair.h:132:3: error: static_assert failed "PointerIntPair with integer size too large for pointer" static_assert(IntBits <= PtrTraits::NumLowBitsAvailable, include/llvm/ADT/PointerIntPair.h:73:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> >' requested here Value = Info::updateInt(Info::updatePointer(0, PtrVal), llvm/include/llvm/ADT/PointerIntPair.h:51:5: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::setPointerAndInt' requested here setPointerAndInt(PtrVal, IntVal); ^ llvm/tools/clang/lib/Sema/SemaInit.cpp:6237:12: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::PointerIntPair' requested here return {Entity, LK_Extended}; Full log here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/1330 http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/1394 llvm-svn: 337255
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-176-10/+128
| | | | | | | | | | This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. llvm-svn: 337226
* PR38136: improve handling of template argument deduction of non-trailingRichard Smith2018-07-122-2/+54
| | | | | | | | | | | | | | | | | | | | | function parameter packs. This makes our handling of non-trailing function parameter packs consistent between the case of deduction at the top level in a function call and other cases where deduction encounters a non-trailing function parameter pack. Instead of treating a non-trailing pack and all later parameters as being non-deduced, we treat a non-trailing pack as exactly matching any explicitly-specified template arguments (or being an empty pack if there are no such arguments). This corresponds to the "never deduced" rule in [temp.deduct.call]p1, but generalized to all deduction contexts. Non-trailing template argument packs still result in the entire template argument list being treated as non-deduced, as specified in [temp.deduct.type]p9. llvm-svn: 336962
* PR38141: check whether noexcept-specifications are equivalent in redeclarationsRichard Smith2018-07-121-0/+10
| | | | llvm-svn: 336946
* Add tests for function conversions in conversion function templateRichard Smith2018-07-121-0/+17
| | | | | | deduction. llvm-svn: 336931
* [C++17] Disallow lambdas in template parameters (PR33696).Nicolas Lesser2018-07-121-0/+7
| | | | | | | | | | | | | | Summary: This revision disallows lambdas in template parameters, as reported in PR33696. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37442 llvm-svn: 336930
* Fix deduction for conversion function templates converting to referenceRichard Smith2018-07-111-0/+68
| | | | | | | | | | | | | | | | | | | types. We previously tried to use the "parameter is a reference" logic here, but that doesn't work because it gets P and A backwards. Instead, add a separate implementation of the "deduced A can be less qualified than A" rule. This also exposes that we incorrectly stripped cv-qualifiers from the referent of A if it was a reference. However, if we don't do that, we get the wrong results when P is a reference. In an attempt to match what sanity dictates and what other implementations are doing, we now remove cv-qualifiers from A and P unless both are reference types. I've brought this up on the core reflector too, to try to get the standard fixed. llvm-svn: 336867
* Fix determination of whether one set of cvr-qualifiers is compatibleRichard Smith2018-07-111-0/+10
| | | | | | | | | | with another in template argument deduction. We happened to typically get away with getting this wrong, because the cases where we'd produce a bogus deduction were caught by the final "deduced A is compatible with A" check. llvm-svn: 336852
* DR330: look through array types when forming the cv-decomposition of a type.Richard Smith2018-07-111-0/+51
| | | | | | | | | | This allows more qualification conversions, eg. conversion from 'int *(*)[]' -> 'const int *const (*)[]' is now permitted, along with all the consequences of that: more types are similar, more cases are permitted by const_cast, and conversely, fewer "casting away constness" cases are permitted by reinterpret_cast. llvm-svn: 336745
* Fix determination of whether a reinterpret_cast casts away constness.Richard Smith2018-07-101-0/+26
| | | | | | | | | | | | | | The "casts away constness" check doesn't care at all how the different layers of the source and destination type were formed: for example, if the source is a pointer and the destination is a pointer-to-member, the types are still decomposed and their pointee qualifications are still checked. This rule is bizarre and somewhat ridiculous, so as an extension we accept code making use of such reinterpret_casts with a warning outside of SFINAE contexts. llvm-svn: 336738
* Per C++ [over.match.copy]p1, direct-initialization of a reference canRichard Smith2018-07-021-0/+9
| | | | | | only invoke converting constructors of the reference's underlying type. llvm-svn: 336153
* Specify an explicit underlying type for this enum to fix WindowsRichard Smith2018-06-291-1/+1
| | | | | | | | | | buildbots. On Windows targets, enums always get an underlying type of 'int', even if they have wider enumerators. (This is non-conforming, but it's effectively part of the target ABI.) llvm-svn: 336013
* PR37979: integral promotions in C++ treat enum bit-fields like enums,Richard Smith2018-06-281-0/+19
| | | | | | | | | | | | | | | | | not like bit-fields. We used to get this right "by accident", because conversions for the selected built-in overloaded operator would convert the enum bit-field to its corresponding underlying type early. But after DR1687 that no longer happens. Technically this change should also apply to C, where bit-fields only have special promotion rules if the bit-field's declared type is _Bool, int, signed int, or unsigned int, but for GCC compatibility we only look at the bit-width and not the underlying type when performing bit-field integral promotions in C. llvm-svn: 335925
* DR1687: When overload resolution selects a built-in operator, implicitRichard Smith2018-06-273-36/+48
| | | | | | | | | | | conversions are only applied to operands of class type, and the second standard conversion sequence is not applied. When diagnosing an invalid builtin binary operator, talk about the original types rather than the converted types. If these differ by a user-defined conversion, tell the user what happened. llvm-svn: 335781
* DR1213: Ignore implicit conversions when determining if an operand of anRichard Smith2018-06-271-1/+14
| | | | | | | | array subscript expression is an array prvalue. Also apply DR1213 to vector prvalues for consistency. llvm-svn: 335779
* Restore pre-r335182 behavior for naming inherited constructors asRichard Smith2018-06-221-0/+15
| | | | | | | | | | | | | | members of dependent contexts. This permits cases where the names before and after the '::' in a dependent inherited constructor using-declaration do not match, but where we can nonetheless tell when parsing the template that a constructor is being named. Under (open) core language DR 2070, such cases will probably be ill-formed, but r335182 does not quite give that result and didn't intend to change this, so restore the old behavior for now. llvm-svn: 335381
* When a dependent alignas is applied to a non-dependent typedef,Richard Smith2018-06-201-0/+6
| | | | | | | prioritize the error for the bad subject over the error for the dependent / non-dependent mismatch. llvm-svn: 335191
* Related to PR37768: improve diagnostics for class name shadowing.Richard Smith2018-06-203-6/+51
| | | | | | | | | | | | Diagnose the name of the class being shadowed by using declarations, and improve the diagnostics for the case where the name of the class is shadowed by a non-static data member in a class with constructors. In the latter case, we now always give the "member with the same name as its class" diagnostic regardless of the relative order of the member and the constructor, rather than giving an inscrutible diagnostic if the constructor appears second. llvm-svn: 335182
* [c++17] If a class inherits virtual functions from a base class, it isRichard Smith2018-06-141-0/+5
| | | | | | not an aggregtae. llvm-svn: 334763
* [Sema] Use %sub to cleanup overload diagnosticsEric Fiselier2018-05-302-4/+4
| | | | | | | | | | | | | | | | | | | | Summary: This patch adds the newly added `%sub` diagnostic modifier to cleanup repetition in the overload candidate diagnostics. I think this should be good to go. @rsmith: Some of the notes now emit `function template` where they only said `function` previously. It seems OK to me, but I would like your sign off on it. Reviewers: rsmith, EricWF Reviewed By: EricWF Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D47101 llvm-svn: 333485
* Adjust and fix failing CXX tests after r332799Eric Fiselier2018-05-192-9/+9
| | | | llvm-svn: 332800
* Fix regression in r332076.Richard Smith2018-05-141-2/+1
| | | | | | | | | If the name after 'template' is an unresolved using declaration (not containing 'typename'), then we don't yet know if it's a valid template-name, so don't reject it prior to instantiation. Instead, treat it as naming a dependent member of the current instantiation. llvm-svn: 332291
* PR37450: Fix bug that disabled some type checks for variables with deduced ↵Richard Smith2018-05-141-2/+10
| | | | | | | | types. Also improve diagnostic for the case where a type is non-literal because it's a lambda. llvm-svn: 332286
* Improve diagnostics and error recovery for template name lookup.Richard Smith2018-05-112-3/+3
| | | | | | | | | | | | | For 'x::template y', consistently give a "no member named 'y' in 'x'" diagnostic if there is no such member, and give a 'template keyword not followed by a template' name error if there is such a member but it's not a template. In the latter case, add a note pointing at the non-template. Don't suggest inserting a 'template' keyword in 'X::Y<' if X is dependent if the lookup of X::Y was actually not a dependent lookup and found only non-templates. llvm-svn: 332076
* [Sema] Do not match function type with const T in template argument deductionLei Liu2018-05-032-16/+14
| | | | | | | | | | | From http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584, function type should not match cv-qualified type in template argument deduction. This also matches what GCC and EDG do in template argument deduction. Differential Revision: https://reviews.llvm.org/D45755 llvm-svn: 331424
* Parse A::template B as an identifier rather than as a template-id with noRichard Smith2018-04-273-4/+7
| | | | | | | | | | template arguments. This fixes some cases where we'd incorrectly accept "A::template B" when B is a kind of template that requires template arguments (in particular, a variable template or a concept). llvm-svn: 331013
* DR727: remove wrong assertion for use of class-scope explicitRichard Smith2018-04-231-1/+28
| | | | | | specialization without -fms-extensions. llvm-svn: 330626
* Allow [[maybe_unused]] on static data members; these are considered ↵Aaron Ballman2018-04-121-1/+1
| | | | | | | | variables and the attribute should appertain to them. Patch by S. B. Tam. llvm-svn: 329904
* 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
* Add a couple more tests for DR372.Richard Smith2018-04-051-0/+19
| | | | llvm-svn: 329352
* DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standardRichard Smith2018-04-055-2/+85
| | | | | | | | | | | | | | | | | layout" rules. The new rules say that a standard-layout struct has its first non-static data member and all base classes at offset 0, and consider a class to not be standard-layout if that would result in multiple subobjects of a single type having the same address. We track "is C++11 standard-layout class" separately from "is standard-layout class" so that the ABIs that need this information can still use it. Differential Revision: https://reviews.llvm.org/D45176 llvm-svn: 329332
* [C++17] Fix class template argument deduction for default constructors ↵Zhihao Yuan2018-03-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | without an initializer Summary: As the title says, this makes following code compile: ``` template<typename> struct Foo {}; Foo() -> Foo<void>; Foo f; // ok ``` Thanks Nicolas Lesser for coining the fix. Reviewers: rsmith, lichray Reviewed By: rsmith, lichray Subscribers: lichray, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D38216 llvm-svn: 328409
* [C++17] Allow an empty expression in an if init statementZhihao Yuan2018-03-171-1/+59
| | | | | | | | | | | | | | | | | | | Summary: This fixes [PR35381](https://llvm.org/pr35381) and an additional bug where clang didn't warn about the C++17 extension when having an expression in the init statement. Thanks Nicolas Lesser for contributing the patch. Reviewers: rsmith Reviewed By: rsmith Subscribers: erik.pilkington, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D40445 llvm-svn: 327782
* Implement DR2229, which prohibits unnamed bit-fields from having qualifiers ↵Aaron Ballman2018-03-172-1/+18
| | | | | | in C++. llvm-svn: 327781
* Implement C++ DR727, which permits explicit specializations at class scope.Richard Smith2018-03-168-86/+71
| | | | | | | | | More generally, this permits a template to be specialized in any scope in which it could be defined, so this also supersedes DR44 and DR374 (the latter of which we previously only implemented in C++11 mode onwards due to unclarity as to whether it was a DR). llvm-svn: 327705
* When substituting previously-checked template arguments into a templateRichard Smith2018-03-081-3/+2
| | | | | | | | | | | | | template parameter that is an expanded parameter pack, only substitute into the current slice, not the entire pack. This reduces the checking of N template template arguments for an expanded parameter pack containing N parameters from quadratic time to linear time in the length of the pack. This is important because one (and possibly the only?) general technique for splitting a template parameter pack in linear time depends on doing this. llvm-svn: 326973
* [Sema] Improve test coverage of narrowing conversion diagnosticsMikhail Maltsev2018-03-021-6/+11
| | | | | | | | | | | | | | | | Summary: This patch adds tests of narrowing conversion diagnostics for the 'unscoped enum -> integer' case. Reviewers: faisalv, rsmith, rogfer01 Reviewed By: rogfer01 Subscribers: cfe-commits, rogfer01 Differential Revision: https://reviews.llvm.org/D43572 llvm-svn: 326551
* Fix a couple of cases where we would fail to correctly parse deduced class ↵Richard Smith2018-02-281-2/+2
| | | | | | | | | | | | | | | | template specialization types. Specifically, we would not properly parse these types within template arguments (for non-type template parameters), and in tentative parses. Fixing both of these essentially requires that we parse deduced template specialization types as types in all contexts, even in template argument lists -- in particular, tentative parsing may look ahead and annotate a deduced template specialization type before we figure out that we're actually supposed to treat the tokens as a template-name. We deal with this by simply permitting deduced template specialization types when parsing template arguments, and converting them to template template arguments. llvm-svn: 326299
* Bring r325915 back.Rafael Espindola2018-02-234-37/+37
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325940
OpenPOWER on IntegriCloud