summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/dependent-base-classes.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith2019-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
* Improve diagnostics and error recovery for template name lookup.Richard Smith2018-05-111-2/+2
| | | | | | | | | | | | | 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
* Recover properly if a class member declaration starts with a scope specifierRichard Smith2012-05-091-2/+1
| | | | | | or template-id which can't be parsed. llvm-svn: 156468
* When we run into an error parsing or type-checking the left-hand sideDouglas Gregor2010-09-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | of a binary expression, continue on and parse the right-hand side of the binary expression anyway, but don't call the semantic actions to type-check. Previously, we would see the error and then, effectively, skip tokens until the end of the statement. The result should be more useful recovery, both in the normal case (we'll actually see errors beyond the first one in a statement), but it also helps code completion do a much better job, because we do "real" code completion on the right-hand side of an invalid binary expression rather than completing with the recovery completion. For example, given x = p->y if there is no variable named "x", we can still complete after the p-> as a member expression. Along the recovery path, we would have completed after the "->" as if we were in an expression context, which is mostly useless. llvm-svn: 114225
* Improve recovery when we see a dependent template name that is missingDouglas Gregor2010-05-211-1/+1
| | | | | | | | | | | | | | | the required "template" keyword, using the same heuristics we do for dependent template names in member access expressions, e.g., test/SemaTemplate/dependent-template-recover.cpp:11:8: error: use 'template' keyword to treat 'getAs' as a dependent template name T::getAs<U>(); ^ template Fixes PR5404. llvm-svn: 104409
* Improve diagnostics when an elaborated-type-specifer containing aDouglas Gregor2010-03-311-1/+1
| | | | | | | | | | | | | | | | nested-name-specifier (e.g., "class T::foo") fails to find a tag member in the scope nominated by the nested-name-specifier. Previously, we gave a bland error: 'Nested' does not name a tag member in the specified scope which didn't actually say where we were looking, which was rather horrible when the nested-name-specifier was instantiated. Now, we give something a bit better: error: no class named 'Nested' in 'NoDepBase<T>' llvm-svn: 100060
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-2/+2
| | | | | | | | | | 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
* Add test case from PR5812, which works now.Douglas Gregor2010-03-021-0/+12
| | | | llvm-svn: 97535
* Skip dependent virtual base classes; fixes PR6413.Douglas Gregor2010-02-271-0/+12
| | | | llvm-svn: 97291
* Fix an assertion-on-error during tentative constructor parsing byJohn McCall2010-02-261-1/+0
| | | | | | | | | | propagating error conditions out of the various annotate-me-a-snowflake routines. Generally (but not universally) removes redundant diagnostics as well as, you know, not crashing on bad code. On the other hand, I have just signed myself up to fix fiddly parser errors for the next week. Again. llvm-svn: 97221
* Teach Sema::ActOnDependentTemplateName that a dependent template nameDouglas Gregor2010-01-191-0/+28
| | | | | | | | in a member access expression referring into the current instantiation need not be resolved at template definition *if* the current instantiation has any dependent base classes. Fixes PR6081. llvm-svn: 93877
* When performing qualified name lookup into the current instantiation,Douglas Gregor2010-01-151-0/+19
| | | | | | | | | | | | | do not look into base classes if there are any dependent base classes. Instead, note in the lookup result that we couldn't look into any dependent bases. Use that new result kind to detect when this case occurs, so that we can fall back to treating the type/value/etc. as a member of an unknown specialization. Fixes an issue where we were resolving lookup at template definition time and then missing an ambiguity at template instantiation time. llvm-svn: 93497
* When qualified lookup into the current instantiation fails (because itDouglas Gregor2010-01-141-0/+53
| | | | | | | | finds nothing), and the current instantiation has dependent base classes, treat the qualified lookup as if it referred to an unknown specialization. Fixes PR6031. llvm-svn: 93433
* Improve recovery for template-ids whose template-name doesn't actuallyDouglas Gregor2010-01-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | name a template, when they occur in a base-specifier. This is one of the (few) places where we know for sure that an identifier followed by a '<' must be a template name, so we can diagnose and recover well: test/SemaTemplate/dependent-base-classes.cpp:9:16: error: missing 'template' keyword prior to dependent template name 'T::apply' struct X1 : T::apply<U> { }; // expected-error{{missing 'template' ... ^ template test/SemaTemplate/dependent-base-classes.cpp:12:13: error: unknown template name 'vector' struct X2 : vector<T> { }; // expected-error{{unknown template name 'vector'}} ^ 2 diagnostics generated. llvm-svn: 93257
* Parse dependent template-ids in base clauses and memberDouglas Gregor2010-01-121-0/+6
initializers. This isn't actually in the C++ grammar (in any version), but that's clearly an oversight: both GCC and EDG support this syntax, and it's used within Boost code. I'll file a core issue proposing precisely the change made here. Fixes PR6008. llvm-svn: 93243
OpenPOWER on IntegriCloud