On 08/23/2012 05:24 PM, Jason Merrill wrote:
On 08/23/2012 10:04 AM, Paolo Carlini wrote:
+ if (decl
+ && TREE_CODE (decl) == VAR_DECL
+ && ! TYPE_P (CP_DECL_CONTEXT (decl)))
+ {
+ error_at (decl_spec_token_start->location,
+ "%qT is not a template type", TREE_TYPE (decl));
+ decl = error_mark_node;
+ }
Can we just check whether decl has DECL_TEMPLATE_INFO at this point?
I tried, possibly together with a preliminary DECL_LANG_SPECIFIC check
and maybe a check that decl isn't already error_mark_node, but anyway
apparently the idea has issues with friends, testcases like
template/friend17.C (gave me already headaches earlier today, that's why
I'm so quick at replying ;)
template <class T>
struct X {
template <class U> void operator+=(U);
template <class V>
template <class U>
friend void X<V>::operator+=(U);
};
int main() {
X<int>() += 1.0;
}
when we parse the friend declaration, DECL_TEMPLATE_INFO is not set.
Paolo.