diff options
author | Kaelyn Uhrain <rikka@google.com> | 2012-02-22 01:03:07 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2012-02-22 01:03:07 +0000 |
commit | e43fe993a079795ac3d2ba7c9ec5e2a0c8069918 (patch) | |
tree | bad21e008e9e31f7083a020c00b379e6704c4ee5 | |
parent | 2639ac628cff5dedb4fa60169082b2a1a9dd8694 (diff) |
Fix typo correction of template arguments to once again allow type names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151112 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Parser.h | 2 | ||||
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 4 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/typo-correction.cpp | 16 |
4 files changed, 20 insertions, 4 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 242ef3857c..27e86ebab6 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1288,7 +1288,7 @@ private: }; ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast); - ExprResult ParseConstantExpression(); + ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast); // Expr that doesn't include commas. ExprResult ParseAssignmentExpression(TypeCastState isTypeCast = NotTypeCast); diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index fada2e319c..d2e8752468 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -249,7 +249,7 @@ Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc, } -ExprResult Parser::ParseConstantExpression() { +ExprResult Parser::ParseConstantExpression(TypeCastState isTypeCast) { // C++03 [basic.def.odr]p2: // An expression is potentially evaluated unless it appears where an // integral constant expression is required (see 5.19) [...]. @@ -257,7 +257,7 @@ ExprResult Parser::ParseConstantExpression() { EnterExpressionEvaluationContext Unevaluated(Actions, Sema::ConstantEvaluated); - ExprResult LHS(ParseCastExpression(false)); + ExprResult LHS(ParseCastExpression(false, false, isTypeCast)); return ParseRHSOfBinaryExpression(LHS, prec::Conditional); } diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index a30ef96d63..d4a0502859 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -1037,7 +1037,7 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() { // Parse a non-type template argument. SourceLocation Loc = Tok.getLocation(); - ExprResult ExprArg = ParseConstantExpression(); + ExprResult ExprArg = ParseConstantExpression(MaybeTypeCast); if (ExprArg.isInvalid() || !ExprArg.get()) return ParsedTemplateArgument(); diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp index 55fead5c62..6fe31c7c33 100644 --- a/test/SemaCXX/typo-correction.cpp +++ b/test/SemaCXX/typo-correction.cpp @@ -167,3 +167,19 @@ class Parent { }; class Child: public Parent {}; void Child::add_types(int value) {} // expected-error{{out-of-line definition of 'add_types' does not match any declaration in 'Child'}} + +// Fix the callback based filtering of typo corrections within +// Sema::ActOnIdExpression by Parser::ParseCastExpression to allow type names as +// potential corrections for template arguments. +namespace clash { +class ConstructExpr {}; // expected-note{{'clash::ConstructExpr' declared here}} +} +class ClashTool { + bool HaveConstructExpr(); + template <class T> T* getExprAs(); + + void test() { + ConstructExpr *expr = // expected-error{{unknown type name 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}} + getExprAs<ConstructExpr>(); // expected-error{{use of undeclared identifier 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}} + } +}; |