Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit d86a4ad

Browse files
author
Kaelyn Takata
committed
Ensure typos in the default values of template parameters get diagnosed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223177 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4cd38f7 commit d86a4ad

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/Parse/ParseTemplate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
676676
GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
677677
EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
678678

679-
DefaultArg = ParseAssignmentExpression();
679+
DefaultArg = Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
680680
if (DefaultArg.isInvalid())
681681
SkipUntil(tok::comma, tok::greater, StopAtSemi | StopBeforeMatch);
682682
}

test/SemaCXX/default2.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ class XX {
122122
void A(int length = -1 ) { }
123123
void B() { A(); }
124124
};
125+
126+
template <int I = (1 * I)> struct S {}; // expected-error-re {{use of undeclared identifier 'I'{{$}}}}
127+
S<1> s;
128+
129+
template <int I1 = I2, int I2 = 1> struct T {}; // expected-error-re {{use of undeclared identifier 'I2'{{$}}}}
130+
T<0, 1> t;

test/SemaCXX/typo-correction-delayed.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ void f(int *i) {
102102
__atomic_load(i, i, something_something); // expected-error-re {{use of undeclared identifier 'something_something'{{$}}}}
103103
}
104104
}
105+
106+
const int DefaultArg = 9; // expected-note {{'DefaultArg' declared here}}
107+
template <int I = defaultArg> struct S {}; // expected-error {{use of undeclared identifier 'defaultArg'; did you mean 'DefaultArg'?}}
108+
S<1> s;

0 commit comments

Comments
 (0)