Commit Graph

14 Commits

Author SHA1 Message Date
Richard Smith b23c5e8c3d [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose
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
2019-05-09 03:31:27 +00:00
Brian Gesiak 7dda73a223 [SemaCXX] Fix ICE for unexpanded parameter pack
Summary:
The documentation for RecursiveASTVisitor::TraverseDecl states that the
Decl being traversed may be null. In fact, this is the case when a
CXXCatchStmt with no exception decl is traversed. Because the visitor
for diagnosing unexpanded parameter packs does not check for null, it
ends up crashing when it attempts to call the Decl::isParameterPack
method on a null Decl pointer.

Add a null check to prevent an ICE, and a test case that would crash
otherwise. Also, because the test requires C++ exceptions and C++14,
change the test parameters for the entire test file. (Alternatively, I
thought about adding a new test file, but went with this approach for my
own convenience.)

Co-authored-by: Andreas Molzer <andreas.molzer@gmx.de>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56271

llvm-svn: 350501
2019-01-07 03:25:59 +00:00
Erik Pilkington ba88e21f8c [Sema] Make sure we substitute an instantiation-dependent default template argument
Fixes llvm.org/PR39623

Differential revision: https://reviews.llvm.org/D54414

llvm-svn: 346709
2018-11-12 21:31:06 +00:00
Richard Smith 3cbf3f1f59 Push alias-declarations and alias-template declarations into scope even if
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
2016-07-15 20:53:25 +00:00
David Majnemer 16a74704c9 [AST] Perform additional canonicalization for DependentSizedArrayType
We treated DependentSizedArrayTypes with the same element type but
differing size expressions as equivalently canonical.  This would lead
to bizarre behavior during template instantiation.

This fixes PR24212.

llvm-svn: 243093
2015-07-24 05:54:19 +00:00
Richard Smith 88fe69ce21 DR1909: Diagnose all invalid cases of a class member sharing its name with the class.
llvm-svn: 241425
2015-07-06 01:45:27 +00:00
Ismail Pazarbasi 025f428c73 Replace "can not" with "cannot" in diagnostics messages.
llvm-svn: 203302
2014-03-07 22:36:23 +00:00
David Majnemer f703b588b8 Implement DR577
DR18 previously forebode typedefs to be used as parameter types if they
were of type 'void'.  DR577 allows 'void' to be used as a function
parameter type regardless from where it came.

llvm-svn: 201631
2014-02-19 03:00:56 +00:00
Enea Zaffanella 29e1c4b03e Fixed an assertion failure triggered by invalid code.
Set invalid type of declarator after emitting error diagnostics,
so that it won't be later considered when instantiating the template.
Added test5_inst in test/SemaCXX/condition.cpp for non-regression.

llvm-svn: 172201
2013-01-11 14:34:39 +00:00
Richard Smith 72249ba945 PR12647: An alias template instantiation which occurs in a SFINAE context is
itself a SFINAE context.

llvm-svn: 155621
2012-04-26 07:24:08 +00:00
Richard Smith c5b0552055 Fix parsing of type-specifier-seq's. Types are syntactically allowed to be
defined here, but not semantically, so

  new struct S {};

is always ill-formed, even if there is a struct S in scope.

We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being
under-loved (due to it only being used in a few places) so merge it into
ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this
required improving ParseDeclarationSpecifiers' diagnostics in some cases. This
also required teaching ParseSpecifierQualifierList about constexpr... which
incidentally fixes an issue where we'd allow the constexpr specifier in other
bad places.

llvm-svn: 152549
2012-03-12 07:56:15 +00:00
Richard Smith 63168c7533 PR11684, core issue 1417:
o Correct the handling of the restrictions on usage of cv-qualified and
  ref-qualified function types.
o Fix a bug where such types were rejected in template type parameter default
  arguments, due to such arguments not being treated as a template type arg
  context.
o Remove the ExtWarn for usage of such types as template arguments; that was
  a standard defect, not a GCC extension.
o Improve the wording and unify the code for diagnosing cv-qualifiers with the
  code for diagnosing ref-qualifiers.

llvm-svn: 150244
2012-02-10 11:05:11 +00:00
Richard Smith 9ca5c42582 Update all tests other than Driver/std.cpp to use -std=c++11 rather than
-std=c++0x. Patch by Ahmed Charles!

llvm-svn: 141900
2011-10-13 22:29:44 +00:00
Richard Smith 3f1b5d077b Implement support for C++0x alias templates.
llvm-svn: 130953
2011-05-05 21:57:07 +00:00