Ensure typos in the default values of template parameters get diagnosed.

llvm-svn: 223177
This commit is contained in:
Kaelyn Takata 2014-12-02 23:32:20 +00:00
parent 5450763dd8
commit 999dd85e16
3 changed files with 11 additions and 1 deletions

View File

@ -676,7 +676,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
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);
}

View File

@ -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;

View File

@ -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;