mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 11:26:07 +00:00

- When substituting template arguments as part of template argument deduction, introduce a new local instantiation scope. - When substituting into a function prototype type, introduce a new "temporary" local instantiation scope that merges with its outer scope but also keeps track of any additions it makes, removing them when we exit that scope. Fixes PR6700, where we were getting too much mixing of local instantiation scopes due to template argument deduction that substituted results into function types. llvm-svn: 99509
45 lines
2.1 KiB
C++
45 lines
2.1 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
// PR6619
|
|
template<bool C> struct if_c { };
|
|
template<typename T1> struct if_ {
|
|
typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 7{{in instantiation}}
|
|
};
|
|
template <class Model, void (Model::*)()> struct wrap_constraints { };
|
|
template <class Model>
|
|
inline char has_constraints_(Model* , // expected-note 4{{while substituting}} \
|
|
// expected-note 3{{candidate template ignored}}
|
|
wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 4{{in instantiation}}
|
|
|
|
template <class Model> struct not_satisfied {
|
|
static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}}
|
|
};
|
|
template <class ModelFn> struct requirement_;
|
|
template <void(*)()> struct instantiate {
|
|
};
|
|
template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-error 3{{no type named}} \
|
|
// expected-note 7{{in instantiation}}
|
|
};
|
|
template <class Model> struct usage_requirements {
|
|
};
|
|
template < typename TT > struct InputIterator {
|
|
typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note 2{{in instantiation}}
|
|
};
|
|
template < typename TT > struct ForwardIterator : InputIterator<TT> { // expected-note 2{{in instantiation}}
|
|
typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note 2 {{in instantiation}}
|
|
|
|
};
|
|
typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX; // expected-error{{no member named}} \
|
|
// expected-note 6{{in instantiation}}
|
|
|
|
template<typename T> struct X0 { };
|
|
template<typename R, typename A1> struct X0<R(A1 param)> { };
|
|
|
|
template<typename T, typename A1, typename A2>
|
|
void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) {
|
|
X0<T(A1)> x0c;
|
|
X0<T(A2)> x0d;
|
|
}
|
|
|
|
template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>);
|