зеркало из https://github.com/microsoft/clang-1.git
Don't reject __restrict applied to a dependent type; it might instantiate to a pointer or reference type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
cbd739410b
Коммит
9807a2e0dd
|
@ -1106,7 +1106,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
|
|||
<< EltTy << DS.getSourceRange();
|
||||
TypeQuals &= ~DeclSpec::TQ_restrict; // Remove the restrict qualifier.
|
||||
}
|
||||
} else {
|
||||
} else if (!Result->isDependentType()) {
|
||||
S.Diag(DS.getRestrictSpecLoc(),
|
||||
diag::err_typecheck_invalid_restrict_not_pointer)
|
||||
<< Result << DS.getSourceRange();
|
||||
|
|
|
@ -3396,7 +3396,9 @@ TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB,
|
|||
}
|
||||
if (!Quals.empty()) {
|
||||
Result = SemaRef.BuildQualifiedType(Result, T.getBeginLoc(), Quals);
|
||||
TLB.push<QualifiedTypeLoc>(Result);
|
||||
// BuildQualifiedType might not add qualifiers if they are invalid.
|
||||
if (Result.hasLocalQualifiers())
|
||||
TLB.push<QualifiedTypeLoc>(Result);
|
||||
// No location information to preserve.
|
||||
}
|
||||
|
||||
|
|
|
@ -46,3 +46,11 @@ T f1(T t1, U u1, int i1)
|
|||
|
||||
return u1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void f2(__restrict T x) {} // expected-note {{substitution failure [with T = int]: pointer to function type 'int' may not be 'restrict' qualified}}
|
||||
|
||||
void f3() {
|
||||
f2<int*>(0);
|
||||
f2<int>(0); // expected-error {{no matching function for call to 'f2'}}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче