summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [modules] Mark deleted functions as implicitly inline to allow mergingEric Fiselier2016-10-311-0/+3
| | | | | | | | | | | | Summary: When merging definitions with ModulesLocalVisibility enabled it's important to make deleted definitions implicitly inline, otherwise they'll be diagnosed as a redefinition. Reviewers: silvas, manmanren, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26143 llvm-svn: 285655
* When diagnosing that a defaulted function is ill-formed because it would beRichard Smith2016-10-311-1/+6
| | | | | | | implicitly deleted and overrides a non-deleted function, explain why the function is deleted. For PR30844. llvm-svn: 285610
* [modules] PR28812: Modules can return duplicate field decls.Vassil Vassilev2016-10-261-2/+9
| | | | | | | | | | | | | If two modules contain duplicate class definitions the lookup result can contain more than 2 elements. Sift the lookup results until we find a field decl. It is not necessary to do ODR checks in place as they done elsewhere. This should fix issues when compiling with libstdc++ 5.2 and 6.2. Patch developed in collaboration with Richard Smith! llvm-svn: 285184
* Don't try to use !Previous.empty() as a proxy for "Is this a redeclaration?" --Richard Smith2016-10-211-4/+3
| | | | | | | | | | | we don't collapse that down to a single entry if it's not a redeclaration. Instead, set the Redeclaration bit on the Declarator to indicate whether a function is a redeclaration (which may not have been linked into the redeclaration chain if it's a dependent context friend). Fixes a rejects-valid; see testcase. llvm-svn: 284802
* [c++1z] Fix assertion failure when using the wrong number of bindings for aRichard Smith2016-10-201-1/+3
| | | | | | struct with unnamed bitfields. llvm-svn: 284761
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-161-3/+0
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* Sema: honour dllexport in itanium more faithfullySaleem Abdulrasool2016-10-141-1/+2
| | | | | | | | | Although the itanium environment uses the itanium layout for C++, treat the dllexport semantics more similarly to the MSVC specification. This preserves the existing behaviour for the use of the itanium ABI on non-windows-itanium environments. Export the inline definitions too. llvm-svn: 284288
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-101-15/+11
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* [Sema] Prevent using member declaration diagnostic if the base class is invalid.Eric Fiselier2016-10-101-5/+7
| | | | | | | | | | | | | | | Summary: Once a base class has been made invalid (by a static_assert for example) all using-member declarations in the derived classes will result in a "not a base class" diagnostic. This diagnostic is very misleading and should not be emitted. This change is needed to help libc++ produce reasonable diagnostics in `std::optional` and `std::variant`. Reviewers: rsmith, majnemer, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25430 llvm-svn: 283755
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-101-11/+15
| | | | | | | | | | | | 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-101-15/+11
| | | | | | allocation. llvm-svn: 283722
* Do not find friend function definitions inside non-instantiated class.Serge Pavlov2016-10-041-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if a file-level function was defined inside befriending template class, it always was treated as defined. For instance, the code like: ``` int func(int x); template<typename T> class C1 { friend int func(int x) { return x; } }; template<typename T> class C2 { friend int func(int x) { return x; } }; ``` could not be compiled due to function redefinition, although not of the templates is instantiated. Moreover, the body of friend function can contain use of template parameters, attempt to get definition of such function outside any instantiation causes compiler abnormal termination. Other compilers (gcc, icc) follow viewpoint that the body of the function defined in friend declaration becomes available when corresponding class is instantiated. This patch implements this viewpoint in clang. Definitions introduced by friend declarations in template classes are not added to the redeclaration chain of corresponding function. Only when the template is instantiated, instantiation of the function definition is placed to the chain. The fix was made in collaboration with Richard Smith. This change fixes PR8035, PR17923, PR22307 and PR25848. Differential Revision: http://reviews.llvm.org/D16989 llvm-svn: 283207
* [coroutines] Switch to using std::experimental namespace per P0057R5Gor Nishanov2016-10-041-0/+14
| | | | | | | | | | | | | | Summary: Look for coroutine_traits and friends in std::experimental namespace. Patch (mostly) by EricWF. Reviewers: cfe-commits, EricWF, rsmith Subscribers: majnemer, mehdi_amini Differential Revision: https://reviews.llvm.org/D25068 llvm-svn: 283170
* Fix bogus "inline namespace cannot be reopened as non-inline" diagnostic toRichard Smith2016-09-301-1/+1
| | | | | | | just warn that the second declaration is missing the 'inline' keyword. This is valid, and we shouldn't be suggesting otherwise. llvm-svn: 282981
* P0035R4: add std::align_val_t overloads of operator new/delete in C++17 mode.Richard Smith2016-09-291-0/+4
| | | | llvm-svn: 282800
* Revert r282547 and add test to show correct behavior.Richard Trieu2016-09-271-2/+6
| | | | llvm-svn: 282555
* Fix defaulted member functions for templated classes.Richard Trieu2016-09-271-6/+2
| | | | | | | | | | In some cases, non-special member functions were being marked as being defaulted in templated classes. This can cause interactions with later code that expects the default function to be one of the specific member functions. Fix the check so that templated class members are checked the same way as non-templated class members are. llvm-svn: 282547
* Fix mishandling of deletedness for assignment operators of classes withRichard Smith2016-08-311-3/+4
| | | | | | | | indirect virtual bases. We don't need to be able to invoke such an assignment operator from the derived class, and we shouldn't delete the derived assignment op if we can't do so. llvm-svn: 280288
* [CUDA] Raise an error if a wrong-side call is codegen'ed.Justin Lebar2016-08-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Some function calls in CUDA are allowed to appear in semantically-correct programs but are an error if they're ever codegen'ed. Specifically, a host+device function may call a host function, but it's an error if such a function is ever codegen'ed in device mode (and vice versa). Previously, clang made no attempt to catch these errors. For the most part, they would be caught by ptxas, and reported as "call to unknown function 'foo'". Now we catch these errors and report them the same as we report other illegal calls (e.g. a call from a host function to a device function). This has a small change in error-message behavior for calls that were previously disallowed (e.g. calls from a host to a device function). Previously, we'd catch disallowed calls fairly early, before doing additional semantic checking e.g. of the call's arguments. Now we catch these illegal calls at the very end of our semantic checks, so we'll only emit a "illegal CUDA call" error if the call is otherwise well-formed. Reviewers: tra, rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23242 llvm-svn: 278759
* P0217R3: code generation support for decomposition declarations.Richard Smith2016-08-151-2/+4
| | | | llvm-svn: 278642
* Explicitly generate a reference variable to hold the initializer for aRichard Smith2016-08-141-3/+22
| | | | | | | | tuple-like decomposition declaration. This significantly simplifies the semantics of BindingDecls for AST consumers (they can now always be evalated at the point of use). llvm-svn: 278640
* P0217R3: template instantiation support for decomposition declarations.Richard Smith2016-08-121-10/+7
| | | | llvm-svn: 278458
* Remove unused and undesirable reference from BindingDecl to DecompositionDecl.Richard Smith2016-08-121-1/+1
| | | | llvm-svn: 278448
* P0217R3: Constant expression evaluation for decomposition declarations.Richard Smith2016-08-121-2/+3
| | | | llvm-svn: 278447
* P0217R3: Perform semantic checks and initialization for the bindings in aRichard Smith2016-08-111-0/+748
| | | | | | | decomposition declaration for arrays, aggregate-like structs, tuple-like types, and (as an extension) for complex and vector types. llvm-svn: 278435
* P0217R3: Parsing support and framework for AST representation of C++1zRichard Smith2016-07-221-1/+2
| | | | | | | | | | | decomposition declarations. There are a couple of things in the wording that seem strange here: decomposition declarations are permitted at namespace scope (which we partially support here) and they are permitted as the declaration in a template (which we reject). llvm-svn: 276492
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+1
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Push alias-declarations and alias-template declarations into scope even ifRichard Smith2016-07-151-3/+1
| | | | | | | | they're redeclarations. This is necessary in order for name lookup to correctly find the most recent declaration of the name (which affects default template argument lookup and cross-module merging, among other things). llvm-svn: 275612
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-061-3/+2
| | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274601
* Re-land "[MS] Don't expect vftables to be provided for extern template ↵Reid Kleckner2016-06-291-13/+11
| | | | | | | | | | | | | | instantiations" Reverts r273305 and re-instates r273296. We needed to fix a bug in Sema::MarkVTableUsed to ensure that operator delete lookup occurs when the vtable is referenced. We already had a special case to look up operator delete when dllimport was used, but I think should really mark virtual destructors referenced any time the vtable is used. llvm-svn: 274147
* Mark inheriting constructors as deleted if the corresponding defaulted defaultRichard Smith2016-06-291-22/+62
| | | | | | | | constructor would be; this is effectively required by P0136R1. This has the effect of exposing the validity of the base class initialization steps to SFINAE checks. llvm-svn: 274088
* P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith2016-06-281-403/+345
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace inheriting constructors implementation with new approach, voted into C++ last year as a DR against C++11. Instead of synthesizing a set of derived class constructors for each inherited base class constructor, we make the constructors of the base class visible to constructor lookup in the derived class, using the normal rules for using-declarations. For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived class that tracks the requisite additional information. We create shadow constructors (not found by name lookup) in the derived class to model the actual initialization, and have a new expression node, CXXInheritedCtorInitExpr, to model the initialization of a base class from such a constructor. (This initialization is special because it performs real perfect forwarding of arguments.) In cases where argument forwarding is not possible (for inalloca calls, variadic calls, and calls with callee parameter cleanup), the shadow inheriting constructor is not emitted and instead we directly emit the initialization code into the caller of the inherited constructor. Note that this new model is not perfectly compatible with the old model in some corner cases. In particular: * if B inherits a private constructor from A, and C uses that constructor to construct a B, then we previously required that A befriends B and B befriends C, but the new rules require A to befriend C directly, and * if a derived class has its own constructors (and so its implicit default constructor is suppressed), it may still inherit a default constructor from a base class llvm-svn: 274049
* Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith2016-06-251-0/+3
| | | | | | | variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
* Use more ArrayRefsDavid Majnemer2016-06-241-3/+3
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Re-commit r273548, reverted in r273589, with a fix to not produceRichard Smith2016-06-231-4/+4
| | | | | | | | | | | | | | | | -Wfor-loop-analysis warnings for a for-loop with a condition variable. In such a case, the loop condition variable is modified on each iteration of the loop by definition. Original commit message: Rearrange condition handling so that semantic checks on a condition variable are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. llvm-svn: 273600
* Revert r273548, "Rearrange condition handling so that semantic checks on a ↵Peter Collingbourne2016-06-231-4/+4
| | | | | | | | condition variable" as it caused a regression in -Wfor-loop-analysis. llvm-svn: 273589
* Rearrange condition handling so that semantic checks on a condition variableRichard Smith2016-06-231-4/+4
| | | | | | | | | are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. llvm-svn: 273548
* Remove a few gendered pronouns.Nico Weber2016-06-101-1/+1
| | | | llvm-svn: 272415
* Remove CXXConstructExpr::getFoundDecl(); it turned out to not be useful.Richard Smith2016-06-101-2/+19
| | | | llvm-svn: 272357
* [Sema] Don't permit catching variably modified typesDavid Majnemer2016-06-081-0/+5
| | | | | | | | Variably modified types shouldn't be permitted in catch clauses. This fixes PR28047. llvm-svn: 272159
* [modules] Ask the canonical decl whether the constructor was defaulted.Vassil Vassilev2016-05-241-4/+4
| | | | | | | | | | | In case of template instantiations query the template instantiation pattern, which had actually '=default'. Fixes https://llvm.org/bugs/show_bug.cgi?id=27739 Patch reviewed by Richard Smith. llvm-svn: 270553
* [MSVC2015] dllexport for defaulted special class membersDmitry Polukhin2016-05-241-29/+52
| | | | | | | | | | | | Clang doesn't dllexport defaulted special member function defaulted inside class but does it if they defaulted outside class. MSVC doesn't make any distinction where they were defaulted. Also MSVC 2013 and 2015 export different set of members. MSVC2015 doesn't emit trivial defaulted x-tors but does emit copy assign operator. Differential revision: http://reviews.llvm.org/D20422 llvm-svn: 270535
* When typo-correcting a using-declaration, actually correct the name of theRichard Smith2016-05-141-0/+4
| | | | | | UsingDecl (so that redeclaration lookup can find it). llvm-svn: 269530
* Use marginally more appropriate functions to detect if we should declare anRichard Smith2016-05-131-3/+4
| | | | | | | implicit copy constructor/assignment, and other minor cleanups. No functionality change intended. llvm-svn: 269457
* [ms][dll] #27212: Generating of implicit special members should take into ↵Dmitry Polukhin2016-05-131-4/+6
| | | | | | | | | | | | | | account MSVC compatibility version Clang creates implicit move constructor/assign operator in all cases if there is std=c++11. But MSVC supports such generation starting from version 1900 only. As result we have some binary incompatibility. Differential Revision: http://reviews.llvm.org/D19156 Patch by Andrew V. Tischenko llvm-svn: 269400
* Add support for derived class special members hiding functions brought in fromRichard Smith2016-05-131-35/+72
| | | | | | | | | a base class via a using-declaration. If a class has a using-declaration declaring either a constructor or an assignment operator, eagerly declare its special members in case they need to displace a shadow declaration from a using-declaration. llvm-svn: 269398
* Preserve the FoundDecl when performing overload resolution for constructors.Richard Smith2016-05-111-5/+9
| | | | | | | | | This is in preparation for C++ P0136R1, which switches the model for inheriting constructors over from synthesizing a constructor to finding base class constructors (via using shadow decls) when looking for derived class constructors. llvm-svn: 269231
* Add a FixItHint for the new diagnostic for a non-class-scope ↵Richard Smith2016-05-051-0/+14
| | | | | | using-declaration that names a class-scope enumerator. llvm-svn: 268664
* Fix implementation of C++'s restrictions on using-declarations referring to ↵Richard Smith2016-05-051-5/+17
| | | | | | | | | | | enumerators: * an unscoped enumerator whose enumeration is a class member is itself a class member, so can only be the subject of a class-scope using-declaration. * a scoped enumerator cannot be the subject of a class-scope using-declaration. llvm-svn: 268594
* Fix crash in BuildCXXDefaultInitExpr.Reid Kleckner2016-04-291-2/+13
| | | | | | | | | | | Fix crash in BuildCXXDefaultInitExpr when member of template class has same name as the class itself. Based on patch by Raphael "Teemperor" Isemann! Differential Revision: http://reviews.llvm.org/D19721 llvm-svn: 268082
OpenPOWER on IntegriCloud