def err_standalone_class_nested_name_specifier : Error<
"forward declaration of %select{class|struct|interface|union|enum}0 cannot "
"have a nested name specifier">;
-def err_forward_var_nested_name_specifier : Error<
- "forward declaration of variable template%select{| partial specialization}0 cannot "
- "have a nested name specifier">;
def err_typecheck_sclass_func : Error<"illegal storage class on function">;
def err_static_block_func : Error<
"function declared in block scope cannot have 'static' storage class">;
LookupResult &Previous);
NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D,
LookupResult &Previous, bool &Redeclaration);
- bool HandleVariableRedeclaration(Decl *D, CXXScopeSpec &SS);
NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
TypeSourceInfo *TInfo,
LookupResult &Previous,
ThisDecl = Actions.ActOnTemplateDeclarator(getCurScope(),
*TemplateInfo.TemplateParams,
D);
- if (Tok.is(tok::semi) &&
- Actions.HandleVariableRedeclaration(ThisDecl, D.getCXXScopeSpec())) {
- SkipUntil(tok::semi, true, true);
- return 0;
- }
if (VarTemplateDecl *VT = dyn_cast_or_null<VarTemplateDecl>(ThisDecl))
// Re-direct this decl to refer to the templated decl so that we can
// initialize it.
llvm_unreachable("Unexpected context");
}
-bool Sema::HandleVariableRedeclaration(Decl *D, CXXScopeSpec &SS) {
- // If this is a redeclaration of a variable template or a forward
- // declaration of a variable template partial specialization
- // with nested name specifier, complain.
-
- if (D && SS.isNotEmpty() &&
- (isa<VarTemplateDecl>(D) ||
- isa<VarTemplatePartialSpecializationDecl>(D))) {
- Diag(SS.getBeginLoc(), diag::err_forward_var_nested_name_specifier)
- << isa<VarTemplatePartialSpecializationDecl>(D) << SS.getRange();
- return true;
- }
- return false;
-}
-
NamedDecl *
Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
TypeSourceInfo *TInfo, LookupResult &Previous,
template<typename T, typename T0> static CONST T right = T(100);
template<typename T> static CONST T right<T,int> = T(5);
};
- template<typename T, typename T0> CONST T B3::right; // expected-error {{forward declaration of variable template cannot have a nested name specifier}}
- template<typename T> CONST T B3::right<T,int>; // expected-error {{forward declaration of variable template partial specialization cannot have a nested name specifier}}
+ template<typename T, typename T0> CONST T B3::right;
+ template<typename T> CONST T B3::right<T,int>;
class B4 {
template<typename T, typename T0> static CONST T right;
template<typename T, typename T0> static CONST T right_def = T(100);
template<typename T> static CONST T right_def<T,int>; // expected-note {{explicit instantiation refers here}}
};
- template<typename T, typename T0> CONST T B4::right; // expected-error {{forward declaration of variable template cannot have a nested name specifier}}
- template<typename T> CONST T B4::right<T,int>; // expected-error {{forward declaration of variable template partial specialization cannot have a nested name specifier}} \
- // expected-note {{explicit instantiation refers here}}
+ template<typename T, typename T0> CONST T B4::right;
+ template<typename T> CONST T B4::right<T,int>; // expected-note {{explicit instantiation refers here}}
template CONST int B4::right<int,int>; // expected-error {{explicit instantiation of undefined static data member template 'right' of class}}
template CONST int B4::right_def<int,int>; // expected-error {{explicit instantiation of undefined static data member template 'right_def' of class}}
}
// FIXME: These cases should be accepted.
int *use_before_definition = A<int>::x<char>;
- template<typename T> template<typename U> T A<T>::x<U>[sizeof(U)]; // expected-error {{forward declaration}}
+ template<typename T> template<typename U> T A<T>::x<U>[sizeof(U)];
static_assert(sizeof(A<int>::x<char>) == 1, ""); // expected-error {{incomplete}}
template<typename T> template<typename...U> T A<T>::y<tuple<U...> >[] = { U()... };