summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/class.access/class.friend
Commit message (Collapse)AuthorAgeFilesLines
* DR674, PR38883, PR40238: Qualified friend lookup should look for aRichard Smith2019-01-072-11/+5
| | | | | | | | | | | | | | | | | | template specialization if there is no matching non-template function. This exposed a couple of related bugs: - we would sometimes substitute into a friend template instead of a suitable non-friend declaration; this would now crash because we'd decide the specialization of the friend is a redeclaration of itself - ADL failed to properly handle the case where an invisible local extern declaration redeclares an invisible friend Both are fixed herein: in particular, we now never make invisible friends or local extern declarations visible to name lookup unless they are the only declaration of the entity. (We already mostly did this for local extern declarations.) llvm-svn: 350505
* Diagnose invalid cv-qualifiers for friend decls.Eli Friedman2018-08-031-2/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D45712 llvm-svn: 338931
* Fix all tests under test/CXX (and test/Analysis) to pass if clang's defaultRichard Smith2016-08-311-3/+18
| | | | | | C++ language standard is not C++98. llvm-svn: 280309
* [Lit Test] Updated 26 Lit tests to be C++11 compatible.Charles Li2015-11-111-1/+8
| | | | | | | Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11. llvm-svn: 252785
* [modules] In C++, stop serializing and deserializing a list of declarations inRichard Smith2015-07-212-7/+9
| | | | | | | | | the identifier table. This is redundant, since the TU-scope lookups are also serialized as part of the TU DeclContext, and wasteful in a number of ways. We still emit the decls for PCH / preamble builds, since for those we want identical results, not merely semantically equivalent ones. llvm-svn: 242855
* Add a new flag, -fspell-checking-limit=<number> to control how many times ↵Nick Lewycky2014-12-161-3/+7
| | | | | | | | we'll do spell checking. Note that spell checking will change the produced AST, so we don't automatically change this value when someone sets -ferror-limit=. With this, merge test typo-correction-pt2.cpp into typo-correction.cpp. Remove Sema::UnqualifiedTyposCorrected, a cache of corrected typos. It would only cache typo corrections that didn't provide ValidateCandidate of which there were few left, and it had a bug when we had the same identifier spelled wrong twice. See the last two tests in typo-correction.cpp for cases this fires. llvm-svn: 224375
* Issue a diagnostic if we see a templated friend declaration that we do notRichard Smith2013-11-081-3/+10
| | | | | | support. llvm-svn: 194273
* Allow CorrectTypo to replace CXXScopeSpecifiers that refer to classes.Kaelyn Uhrain2013-10-191-12/+12
| | | | | | | | | | | Now that CorrectTypo knows how to correctly search classes for typo correction candidates, there is no good reason to only replace an existing CXXScopeSpecifier if it refers to a namespace. While the actual enablement was a matter of changing a single comparison, the fallout from enabling the functionality required a lot more code changes (including my two previous commits). llvm-svn: 193020
* Implement [class.friend]p11's special name lookup rules for friend declarationsRichard Smith2013-08-091-0/+80
| | | | | | | | of local classes. We were previously handling this by performing qualified lookup within a function declaration(!!); replace it with the proper scope lookup. llvm-svn: 188050
* Reinstate r185229, reverted in r185256, with a tweak: further ignore theRichard Smith2013-06-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | standard's rule that an extern "C" declaration conflicts with any entity in the global scope with the same name. Now we only care if the global scope entity is a variable declaration (and so might have the same mangled name as the extern "C" declaration). This has been reported as a standard defect. Original commit message: PR7927, PR16247: Reimplement handling of matching extern "C" declarations across scopes. When we declare an extern "C" name that is not a redeclaration of an entity in the same scope, check whether it redeclares some extern "C" entity from another scope, and if not, check whether it conflicts with a (non-extern-"C") entity in the translation unit. When we declare a name in the translation unit that is not a redeclaration, check whether it conflicts with any extern "C" entities (possibly from other scopes). llvm-svn: 185281
* Revert r185229 as it breaks compilation of <windows.h>Timur Iskhodzhanov2013-06-291-5/+5
| | | | llvm-svn: 185256
* PR7927, PR16247: Reimplement handling of matching extern "C" declarationsRichard Smith2013-06-281-5/+5
| | | | | | | | | | | | | | | across scopes. When we declare an extern "C" name that is not a redeclaration of an entity in the same scope, check whether it redeclares some extern "C" entity from another scope, and if not, check whether it conflicts with a (non-extern-"C") entity in the translation unit. When we declare a name in the translation unit that is not a redeclaration, check whether it conflicts with any extern "C" entities (possibly from other scopes). llvm-svn: 185229
* Add a couple more tests.Eli Friedman2013-06-201-0/+4
| | | | llvm-svn: 184501
* Don't check whether a friend declaration is correctly formed when instantiating,Nick Lewycky2013-02-061-0/+7
| | | | | | we already checked it when parsing. llvm-svn: 174486
* Per C++11 [class.friend]p3, the 'friend' keyword must appear first in aRichard Smith2012-09-201-0/+26
| | | | | | non-function friend declaration. Patch by Josh Magee! llvm-svn: 164273
* When computing the effective context for access control,John McCall2012-08-241-0/+16
| | | | | | | | make sure we walk up the DC chain for the current context, rather than allowing ourselves to get switched over to the canonical DC chain. Fixes PR13642. llvm-svn: 162616
* When disambiguating an expression-statement from a declaraton-statement, if theRichard Smith2012-08-231-4/+4
| | | | | | | statement starts with an identifier for which name lookup will fail either way, look at later tokens to disambiguate in order to improve error recovery. llvm-svn: 162464
* Check access to friend declarations. There's a number of differentJohn McCall2012-08-102-0/+119
| | | | | | | | | | | | | | things going on here that were problematic: - We were missing the actual access check, or rather, it was suppressed on account of being a redeclaration lookup. - The access check would naturally happen during delay, which isn't appropriate in this case. - We weren't actually emitting dependent diagnostics associated with class templates, which was unfortunate. - Access was being propagated incorrectly for friend method declarations that couldn't be matched at parse-time. llvm-svn: 161652
* 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
* Switch diagnostic text from "C++0x" over to "C++11".Douglas Gregor2011-10-121-1/+1
| | | | | | | | We'd also like for "C++11" or "c++11" to be used for the warning groups, but without removing the old warning flags. Patches welcome; I've run out of time to work on this today. llvm-svn: 141801
* Implement the restrictions in C++ [class.friend]p6, which disallowDouglas Gregor2011-10-101-0/+20
| | | | | | | defining a friend function with a qualified name or in a local class. Fixes PR9853. llvm-svn: 141524
* The effective context of a friend function is its lexicalDouglas Gregor2011-10-091-0/+13
| | | | | | context. Fixes PR9103. llvm-svn: 141520
* Tweak the diagnostics for the C++0x extensions to friend types to noteDouglas Gregor2011-05-101-1/+1
| | | | | | | | that they are C++0x extensions, and put them in the appropriate group. We already support most of the semantics. Addresses <rdar://problem/9407525>. llvm-svn: 131153
* Don't crash on hierarchy static_casts which appear in variable initializers.John McCall2011-02-141-0/+15
| | | | | | PR9221. llvm-svn: 125532
* When parsing an out-of-line member function declaration, we must delayJohn McCall2011-02-141-0/+21
| | | | | | | | | | | | | | | | | | | | | | access-control diagnostics which arise from the portion of the declarator following the scope specifier, just in case access is granted by friending the individual method. This can also happen with in-line member function declarations of class templates due to templated-scope friend declarations. We were really playing fast-and-loose before with this sort of thing, and it turned out to work because *most* friend functions are in file scope. Making us delay regardless of context exposed several bugs with how we were manipulating delay. I ended up needing a concept of a context that's independent of the declarations in which it appears, and then I actually had to make some things save contexts correctly, but delay should be much cleaner now. I also encapsulated all the delayed-diagnostics machinery in a single subobject of Sema; this is a pattern we might want to consider rolling out to other components of Sema. llvm-svn: 125485
* Access control polish: drop the note on the original declaration andJohn McCall2010-10-201-3/+2
| | | | | | say 'implicitly' when it was implicit. Resolves PR 7930 and my peace of mind. llvm-svn: 116916
* Support friend function declarations in local classes correctly.John McCall2010-10-131-0/+19
| | | | | | | | Fixes a crash and diagnoses the error condition of an unqualified friend which doesn't resolve to something. I'm still not certain how this is useful. llvm-svn: 116393
* When we complain about a member being inaccessible due to a constraintDouglas Gregor2010-05-281-1/+1
| | | | | | | along an access path, add another note pointing at the member we actually found. llvm-svn: 104937
* When filtering out previous declarations of friend functions, consider theJohn McCall2010-05-281-3/+22
| | | | | | lookup context, not the direct semantic context. Fixes PR7230. llvm-svn: 104917
* I hate this commit.Douglas Gregor2010-05-181-2/+2
| | | | | | | | | | | | | | | | | | | | | Revert much of the implementation of C++98/03 [temp.friend]p5 in r103943 and its follow-ons r103948 and r103952. While our implementation was technically correct, other compilers don't seem to implement this paragraph (which forces the instantiation of friend functions defined in a class template when a class template specialization is instantiated), and doing so broke a bunch of Boost libraries. Since this behavior has changed in C++0x (which instantiates the friend function definitions when they are used), we're going to skip the nowhere-implemented C++98/03 semantics and go straight to the C++0x semantics. This commit is a band-aid to get Boost up and running again. It doesn't really fix PR6952 (which this commit un-fixes), but it does deal with the way Boost.Units abuses this particular paragraph. llvm-svn: 104014
* C++98/03 [temp.friend]p4 requires that inline function definitionsDouglas Gregor2010-05-171-2/+2
| | | | | | | | within class templates be instantiated along with each class template specialization, even if the functions are not used. Do so, as a baby step toward PR6952. llvm-svn: 103943
* Recommit my change to how C++ does elaborated type lookups, now withJohn McCall2010-04-231-0/+7
| | | | | | two bugfixes which fix selfhost and (hopefully) the nightly tests. llvm-svn: 102198
* Revert "C++ doesn't really use "namespaces" for different kinds of names the ↵Daniel Dunbar2010-04-231-7/+0
| | | | | | same", which seems to break most C++ nightly test apps. llvm-svn: 102174
* C++ doesn't really use "namespaces" for different kinds of names the sameJohn McCall2010-04-231-0/+7
| | | | | | | | | | | | | way that C does. Among other differences, elaborated type specifiers are defined to skip "non-types", which, as you might imagine, does not include typedefs. Rework our use of IDNS masks to capture the semantics of different kinds of declarations better, and remove most current lookup filters. Removing the last remaining filter is more complicated and will happen in a separate patch. Fixes PR 6885 as well some spectrum of unfiled bugs. llvm-svn: 102164
* Fix the access checking of function and function template argument types,Chandler Carruth2010-04-181-0/+24
| | | | | | | return types, and default arguments. This fixes PR6855 along with several similar cases where we rejected valid code. llvm-svn: 101706
* Support befriending members of class template specializations.John McCall2010-04-131-0/+34
| | | | llvm-svn: 101173
* Allow classes to befriend implicitly-declared members. Fixes PR6207 forJohn McCall2010-04-131-0/+11
| | | | | | members of non-templated classes. llvm-svn: 101122
* Don't try to find a scope corresponding to the search DC for an unfoundJohn McCall2010-04-131-0/+19
| | | | | | | friend declaration; this used to be important but is now just a waste of time plus an unreasonable assertion. Fixes PR6174. llvm-svn: 101112
* 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
* Improve handling of friend types in several ways:Douglas Gregor2010-04-072-0/+42
| | | | | | | | | | | - When instantiating a friend type template, perform semantic analysis on the resulting type. - Downgrade the errors concerning friend type declarations that do not refer to classes to ExtWarns in C++98/03. C++0x allows practically any type to be befriended, and ignores the friend declaration if the type is not a class. llvm-svn: 100635
* add a slight variation of test3, whereGabor Greif2010-03-261-0/+12
| | | | | | | argument list seems to be different, but in fact is semantically equivalent; check that we do not error here llvm-svn: 99617
* Reapply r99596 with a fix: link an instantiated friend function to itsJohn McCall2010-03-261-0/+15
| | | | | | pattern if it has a body. llvm-svn: 99610
* Fix a very minor oversight in privileges-elevation: we were only consideringJohn McCall2010-03-251-0/+16
| | | | | | | friendship for a derived class if the base class specifier was non-public, and thus not considering friendship for non-public members of public bases. llvm-svn: 99554
* When elevating access along an inheritance path, initialize the computedJohn McCall2010-03-181-0/+34
| | | | | | | | | | | | | | | | 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
* Add an extra test to this test-case.John McCall2010-03-121-1/+7
| | | | llvm-svn: 98322
* Implement basic support for friend types and functions in non-dependentJohn McCall2010-03-121-1/+50
| | | | | | contexts. llvm-svn: 98321
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-9/+9
| | | | | | | | | | therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag). Most of these testcase changes were done by script, so don't feel too sorry for my fingers. llvm-svn: 98149
* Fix the lookup of names used in a friend declaration to not attempt toChandler Carruth2010-03-011-0/+62
re-declare them. This fixes PR6317. Also add the beginnings of an interesting test case for p1 of [class.friend] which also covers PR6317. llvm-svn: 97499
OpenPOWER on IntegriCloud