summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class.access/p4.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix implementation of [temp.local]p4.Richard Smith2019-02-151-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | When a template-name is looked up, we need to give injected-class-name declarations of class templates special treatment, as they denote a template rather than a type. Previously we achieved this by applying a filter to the lookup results after completing name lookup, but that is incorrect in various ways, not least of which is that it lost all information about access and how members were named, and the filtering caused us to generally lose all ambiguity errors between templates and non-templates. We now preserve the lookup results exactly, and the few places that need to map from a declaration found by name lookup into a declaration of a template do so explicitly. Deduplication of repeated lookup results of the same injected-class-name declaration is done by name lookup instead of after the fact. This reinstates r354091, which was previously reverted in r354097 because it exposed bugs in lldb and compiler-rt. Those bugs were fixed in r354173 and r354174 respectively. llvm-svn: 354176
* Revert "Fix implementation of [temp.local]p4."Francis Visoiu Mistrih2019-02-151-3/+7
| | | | | | | | | This reverts commit 40bd10b770813bd1471d46f514545437516aa4ba. This seems to now emit an error when building the sanitizer tests: http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull. llvm-svn: 354097
* Fix implementation of [temp.local]p4.Richard Smith2019-02-151-7/+3
| | | | | | | | | | | | | | | | | | | | When a template-name is looked up, we need to give injected-class-name declarations of class templates special treatment, as they denote a template rather than a type. Previously we achieved this by applying a filter to the lookup results after completing name lookup, but that is incorrect in various ways, not least of which is that it lost all information about access and how members were named, and the filtering caused us to generally lose all ambiguity errors between templates and non-templates. We now preserve the lookup results exactly, and the few places that need to map from a declaration found by name lookup into a declaration of a template do so explicitly. Deduplication of repeated lookup results of the same injected-class-name declaration is done by name lookup instead of after the fact. llvm-svn: 354091
* Switch from using a DiagnosticTrap and a note for "while defining a specialRichard Smith2017-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | member function" context notes to registering an entry on the context stack. Also reorder the steps within defining special members to be consistent. This has a few benefits: if multiple diagnostics are produced while checking such a member, the note is now attached to the first such diagnostic rather than the last, this prepares us for persisting these diagnostics between the point at which we require the implicit instantiation of a template and the point at which that instantiation is actually performed, and this fixes some cases where we would fail to produce a full note stack leading back to user code in the case of such a diagnostic. The reordering exposed a case where we could recursively attempt to define a defaulted destructor while we're already defining one (and other such cases also appear to be possible, with or without this change), so this change also reuses the "willHaveBody" flag on function declarations to track that we're in the middle of synthesizing a body for the function and bails out if we try to define a function that we're already defining. llvm-svn: 303930
* Fix all tests under test/CXX (and test/Analysis) to pass if clang's defaultRichard Smith2016-08-311-3/+79
| | | | | | C++ language standard is not C++98. llvm-svn: 280309
* When formatting a C++-only declaration name, enable C++ mode in the formatter'sRichard Smith2014-01-221-2/+2
| | | | | | | | | language options. This is not really ideal -- we should require the right language options to be passed in, or not require language options to format a name -- but it fixes a number of *obviously* wrong formattings. Patch by Olivier Goffart! llvm-svn: 199778
* Fix some confusing diagnostic wording. s/implicit default/implicit/ if we'reRichard Smith2013-06-131-5/+5
| | | | | | not actually talking about a default constructor. llvm-svn: 183885
* Fix several problems with protected access control:John McCall2012-04-071-1/+1
| | | | | | | | | | | | | | | | | | | | | - The [class.protected] restriction is non-trivial for any instance member, even if the access lacks an object (for example, if it's a pointer-to-member constant). In this case, it is equivalent to requiring the naming class to equal the context class. - The [class.protected] restriction applies to accesses to constructors and destructors. A protected constructor or destructor can only be used to create or destroy a base subobject, as a direct result. - Several places were dropping or misapplying object information. The standard could really be much clearer about what the object type is supposed to be in some of these accesses. Usually it's easy enough to find a reasonable answer, but still, the standard makes a very confident statement about accesses to instance members only being possible in either pointer-to-member literals or member access expressions, which just completely ignores concepts like constructor and destructor calls, using declarations, unevaluated field references, etc. llvm-svn: 154248
* Diagnose tag and class template declarations with qualifiedDouglas Gregor2012-03-171-1/+1
| | | | | | declarator-ids that occur at class scope. Fixes PR8019. llvm-svn: 153002
* Update our diagnostics to properly account for move operations.Alexis Hunt2011-05-251-2/+2
| | | | llvm-svn: 132096
* Undo enough of r131143 to make private copy ctor diags say "copy ↵Matt Beaumont-Gay2011-05-191-2/+2
| | | | | | constructor" again llvm-svn: 131706
* Re-do R131114 without breaking code.Alexis Hunt2011-05-101-3/+3
| | | | | | | | | I've edited one diagnostic which would print "copy constructor" for copy constructors and "constructor" for any other constructor. If anyone is extremely enamored with this, it can be reinstated with a simple boolean flag rather than calling getSpecialMember, which is inappropriate. llvm-svn: 131143
* 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
* Change the context correctly when instantiating a static data member definition.John McCall2011-02-141-0/+10
| | | | llvm-svn: 125517
* When building a user-defined conversion sequence, keep track of theDouglas Gregor2011-01-201-0/+10
| | | | | | | declaration that name lookup actually found, so that we can use it for access checking later on. Fixes <rdar://problem/8876150>. llvm-svn: 123867
* Access control polish: drop the note on the original declaration andJohn McCall2010-10-201-1/+31
| | | | | | say 'implicitly' when it was implicit. Resolves PR 7930 and my peace of mind. llvm-svn: 116916
* PR8325: don't do destructor checking when a pointer is thrown.Eli Friedman2010-10-121-0/+8
| | | | llvm-svn: 116336
* Add a quick-and-dirty hack to give a better diagnostic for [class.protected]John McCall2010-09-031-1/+1
| | | | | | | | | | restrictions. The note's not really on the right place given its wording, but putting a second note on the call site (or muddying the wording) doesn't appeal. There are corner cases where this can be wrong, but I'm not concerned. llvm-svn: 112950
* Work around a crash when checking access to injected class namesJohn McCall2010-08-131-0/+14
| | | | | | | | | | qua templates. The current fix suppresses the access check entirely in this case; to do better, we'd need to be able to say that a particular lookup result came from a particular injected class name, which is not easy to do with the current representation of LookupResult. This is on my known-problems list. llvm-svn: 111009
* Perform access control when template lookup finds a class template.John McCall2010-08-131-0/+9
| | | | | | This is *really* hacky. llvm-svn: 110997
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-2/+3
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-3/+2
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Do not use CXXZeroValueInitExpr for class types. Instead, useDouglas Gregor2010-07-071-2/+3
| | | | | | | | | CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as appropriate. Fixes PR7556, and provides a slide codegen improvement when copy-initializing a POD class type from a value-initialized temporary. Previously, we weren't eliding the copy. llvm-svn: 107827
* Make sure to check the accessibility of and mark the destructor for theEli Friedman2010-06-031-0/+6
| | | | | | operand of a throw expression. Fixes PR7281. llvm-svn: 105408
* When we complain about a member being inaccessible due to a constraintDouglas Gregor2010-05-281-2/+2
| | | | | | | along an access path, add another note pointing at the member we actually found. llvm-svn: 104937
* When we emit an error during the implicit definition of a specialDouglas Gregor2010-05-121-9/+11
| | | | | | | | member function (default constructor, copy constructor, copy assignment operator, destructor), emit a note showing where that implicit definition was required. llvm-svn: 103619
* Speculatively revert r103497, "Do not mark the virtual members of anDaniel Dunbar2010-05-111-11/+9
| | | | | | implicitly-instantiated class as ...", which seems to have broken bootstrap. llvm-svn: 103515
* Do not mark the virtual members of an implicitly-instantiated class asDouglas Gregor2010-05-111-9/+11
| | | | | | | | referenced unless we see one of them defined (or the key function defined, if it as one) or if we need the vtable for something. Fixes PR7114. llvm-svn: 103497
* An access is permitted if the current template instantiates to the appropriateJohn McCall2010-05-041-0/+55
| | | | | | class. Add some conservative support for the idea. Fixes PR 7024. llvm-svn: 102999
* Complete reimplementation of the synthesis for implicitly-defined copyDouglas Gregor2010-05-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assignment operators. Previously, Sema provided type-checking and template instantiation for copy assignment operators, then CodeGen would synthesize the actual body of the copy constructor. Unfortunately, the two were not in sync, and CodeGen might pick a copy-assignment operator that is different from what Sema chose, leading to strange failures, e.g., link-time failures when CodeGen called a copy-assignment operator that was not instantiation, run-time failures when copy-assignment operators were overloaded for const/non-const references and the wrong one was picked, and run-time failures when by-value copy-assignment operators did not have their arguments properly copy-initialized. This implementation synthesizes the implicitly-defined copy assignment operator bodies in Sema, so that the resulting ASTs encode exactly what CodeGen needs to do; there is no longer any special code in CodeGen to synthesize copy-assignment operators. The synthesis of the body is relatively simple, and we generate one of three different kinds of copy statements for each base or member: - For a class subobject, call the appropriate copy-assignment operator, after overload resolution has determined what that is. - For an array of scalar types or an array of class types that have trivial copy assignment operators, construct a call to __builtin_memcpy. - For an array of class types with non-trivial copy assignment operators, synthesize a (possibly nested!) for loop whose inner statement calls the copy constructor. - For a scalar type, use built-in assignment. This patch fixes at least a few tests cases in Boost.Spirit that were failing because CodeGen picked the wrong copy-assignment operator (leading to link-time failures), and I suspect a number of undiagnosed problems will also go away with this change. Some of the diagnostics we had previously have gotten worse with this change, since we're going through generic code for our type-checking. I will improve this in a subsequent patch. llvm-svn: 102853
* When we create a temporary of class type that we don't immediatelyDouglas Gregor2010-04-241-0/+13
| | | | | | | bind, check accessibility of the destructor and mark the declaration as referenced. Fixes a bunch of Boost.Regex failures. llvm-svn: 102287
* Keep tack of whether a base in an InitializedEntity is an inherited virtual ↵Anders Carlsson2010-04-211-3/+2
| | | | | | base or not. Use this in CheckConstructorAccess. llvm-svn: 102020
* Pass the InitializedEntity to Sema::CheckConstructorAccess and use it to ↵Anders Carlsson2010-04-211-1/+13
| | | | | | report different diagnostics depending on which entity is being initialized. llvm-svn: 102010
* 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
* Check access for the implicit calls to destructors that occur when weJohn McCall2010-04-071-0/+12
| | | | | | | | have a temporary object in C++. Also fix a tag mismatch that Doug noticed. llvm-svn: 100593
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-0/+18
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* Accumulate all functions and classes that the effective context isJohn McCall2010-03-271-0/+14
| | | | | | | | nested within, and suddenly local classes start working. Wouldn't be necessary if I hadn't used local classes in Clang in the first place. Or, well, wouldn't be necessary yet. :) llvm-svn: 99709
* Do not mark the destructor of a function parameter's type. Fixes PR6709.Douglas Gregor2010-03-261-2/+2
| | | | llvm-svn: 99615
* When finishing a function definition, leave the function definition *after*John McCall2010-03-251-0/+12
| | | | | | | doing all the cleanup tasks and checks. This gives us the proper context for checking access to base and member destructors. llvm-svn: 99559
* Walk out of enums when determining effective context.John McCall2010-03-241-0/+21
| | | | llvm-svn: 99391
* When elevating access along an inheritance path, initialize the computedJohn McCall2010-03-181-0/+12
| | | | | | | | | | | | | | | | access to the (elevated) access of the accessed declaration, if applicable, rather than plunking that access onto the end after we've calculated the inheritance access. Also, being a friend of a derived class gives you public access to its members (subject to later modification by further inheritance); it does not simply ignore a single location of restricted inheritance. Also, when computing the best unprivileged path to a subobject, preserve the information that the worst path might be AS_none (forbidden) rather than a minimum of AS_private. llvm-svn: 98899
* from code inspection, we were treating placement news with one argument asJohn McCall2010-03-181-0/+17
| | | | | | | | non-placement news when selecting the corresponding operator delete; this is fixed. Access and ambiguity control for calls to operator new and delete. Also AFAICT llvm-svn: 98818
* Redeclaration lookups for parameter names should be flagged as redeclaration ↵John McCall2010-03-181-0/+12
| | | | | | | | lookups so they don't trigger diagnostics like (say) access control. llvm-svn: 98806
* Perform access control for the implicit calls to base and member destructorsJohn McCall2010-03-161-8/+9
| | | | | | that occur in constructors (on the unwind path). llvm-svn: 98681
* Access control for implicit calls to copy assignment operators and copyJohn McCall2010-03-161-0/+37
| | | | | | constructors from implicitly-defined members. llvm-svn: 98614
* Perform access control even for the implicit destructor calls from implicitJohn McCall2010-03-161-2/+11
| | | | | | destructor definitions. Remove some code duplication. llvm-svn: 98611
* Perform access control for the implicit base and member destructor callsJohn McCall2010-03-161-4/+22
| | | | | | required when emitting a destructor definition. llvm-svn: 98609
* Remember access paths for visible conversion decls.John McCall2010-03-151-0/+44
| | | | llvm-svn: 98539
* Improve access control diagnostics. Perform access control on member-pointerJohn McCall2010-02-101-17/+17
| | | | | | | conversions. Fix an access-control bug where privileges were not considered at intermediate points along the inheritance path. Prepare for friends. llvm-svn: 95775
OpenPOWER on IntegriCloud