r223177 - Ensure typos in the default values of template parameters get diagnosed.
Kaelyn Takata
rikka at google.com
Tue Dec 2 15:32:20 PST 2014
Author: rikka
Date: Tue Dec 2 17:32:20 2014
New Revision: 223177
URL: http://llvm.org/viewvc/llvm-project?rev=223177&view=rev
Log:
Ensure typos in the default values of template parameters get diagnosed.
Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/SemaCXX/default2.cpp
cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=223177&r1=223176&r2=223177&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Tue Dec 2 17:32:20 2014
@@ -676,7 +676,7 @@ Parser::ParseNonTypeTemplateParameter(un
GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
- DefaultArg = ParseAssignmentExpression();
+ DefaultArg = Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
if (DefaultArg.isInvalid())
SkipUntil(tok::comma, tok::greater, StopAtSemi | StopBeforeMatch);
}
Modified: cfe/trunk/test/SemaCXX/default2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default2.cpp?rev=223177&r1=223176&r2=223177&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/default2.cpp (original)
+++ cfe/trunk/test/SemaCXX/default2.cpp Tue Dec 2 17:32:20 2014
@@ -122,3 +122,9 @@ class XX {
void A(int length = -1 ) { }
void B() { A(); }
};
+
+template <int I = (1 * I)> struct S {}; // expected-error-re {{use of undeclared identifier 'I'{{$}}}}
+S<1> s;
+
+template <int I1 = I2, int I2 = 1> struct T {}; // expected-error-re {{use of undeclared identifier 'I2'{{$}}}}
+T<0, 1> t;
Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=223177&r1=223176&r2=223177&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Tue Dec 2 17:32:20 2014
@@ -102,3 +102,7 @@ void f(int *i) {
__atomic_load(i, i, something_something); // expected-error-re {{use of undeclared identifier 'something_something'{{$}}}}
}
}
+
+const int DefaultArg = 9; // expected-note {{'DefaultArg' declared here}}
+template <int I = defaultArg> struct S {}; // expected-error {{use of undeclared identifier 'defaultArg'; did you mean 'DefaultArg'?}}
+S<1> s;
More information about the cfe-commits
mailing list