summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-10 00:53:15 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-10 00:53:15 +0000
commit97f34576d4a50a24f4154b85bcff9e29b240e8ac (patch)
treec507dc5a4c8cc7807d7a3d59474cb18a46c68365 /clang/include
parent85e0f66250637165a815ef78ab4b3fe102d75c8b (diff)
downloadbcm5719-llvm-97f34576d4a50a24f4154b85bcff9e29b240e8ac.tar.gz
bcm5719-llvm-97f34576d4a50a24f4154b85bcff9e29b240e8ac.zip
Teach the type-id/expression disambiguator about different
disambiguation contexts, so that we properly parse template arguments such as A<int()> as type-ids rather than as expressions. Since this can be confusing (especially when the template parameter is a non-type template parameter), we try to give a friendly error message. Almost, eliminate a redundant error message (that should have been a note) and add some ultra-basic checks for non-type template arguments. llvm-svn: 64189
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.def2
-rw-r--r--clang/include/clang/Parse/Parser.h17
2 files changed, 10 insertions, 9 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.def b/clang/include/clang/Basic/DiagnosticSemaKinds.def
index d4d68a4d349..fd6055103b1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.def
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.def
@@ -497,8 +497,6 @@ DIAG(note_template_nontype_parm_prev_declaration, NOTE,
// C++ Template Argument Lists
DIAG(err_template_arg_list_different_arity, ERROR,
"%select{too few|too many}0 template arguments for %select{class template|function template|template template parameter|template}1 %2")
-DIAG(note_template_parameter_here, ERROR,
- "template parameter is declared here")
DIAG(err_template_arg_must_be_type, ERROR,
"template argument for template type parameter must be a type")
DIAG(err_template_arg_must_be_expr, ERROR,
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 2d777ff7ba2..ab43c516cdb 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -819,12 +819,20 @@ private:
return isDeclarationSpecifier();
}
+ /// \brief Specifies the context in which type-id/expression
+ /// disambiguation will occur.
+ enum TentativeCXXTypeIdContext {
+ TypeIdInParens,
+ TypeIdAsTemplateArgument
+ };
+
+
/// isTypeIdInParens - Assumes that a '(' was parsed and now we want to know
/// whether the parens contain an expression or a type-id.
/// Returns true for a type-id and false for an expression.
bool isTypeIdInParens() {
if (getLang().CPlusPlus)
- return isCXXTypeIdInParens();
+ return isCXXTypeId(TypeIdInParens);
return isTypeSpecifierQualifier();
}
@@ -855,12 +863,7 @@ private:
/// the function returns true to let the declaration parsing code handle it.
bool isCXXConditionDeclaration();
- /// isCXXTypeIdInParens - Assumes that a '(' was parsed and now we want to
- /// know whether the parens contain an expression or a type-id.
- /// Returns true for a type-id and false for an expression.
- /// If during the disambiguation process a parsing error is encountered,
- /// the function returns true to let the declaration parsing code handle it.
- bool isCXXTypeIdInParens();
+ bool isCXXTypeId(TentativeCXXTypeIdContext Context);
/// TPResult - Used as the result value for functions whose purpose is to
/// disambiguate C++ constructs by "tentatively parsing" them.
OpenPOWER on IntegriCloud