forked from OSchip/llvm-project
Permit auto SCS on parameter declarations, C++03 [dcl.stc]p2
llvm-svn: 142649
This commit is contained in:
parent
d315157f12
commit
99eddc3d92
|
@ -6592,11 +6592,16 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
|
|||
const DeclSpec &DS = D.getDeclSpec();
|
||||
|
||||
// Verify C99 6.7.5.3p2: The only SCS allowed is 'register'.
|
||||
// C++03 [dcl.stc]p2 also permits 'auto'.
|
||||
VarDecl::StorageClass StorageClass = SC_None;
|
||||
VarDecl::StorageClass StorageClassAsWritten = SC_None;
|
||||
if (DS.getStorageClassSpec() == DeclSpec::SCS_register) {
|
||||
StorageClass = SC_Register;
|
||||
StorageClassAsWritten = SC_Register;
|
||||
} else if (getLangOptions().CPlusPlus &&
|
||||
DS.getStorageClassSpec() == DeclSpec::SCS_auto) {
|
||||
StorageClass = SC_Auto;
|
||||
StorageClassAsWritten = SC_Auto;
|
||||
} else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified) {
|
||||
Diag(DS.getStorageClassSpecLoc(),
|
||||
diag::err_invalid_storage_class_in_func_decl);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-compat %s
|
||||
|
||||
// The auto or register specifiers can be applied only to names of objects
|
||||
// declared in a block (6.3) or to function parameters (8.4).
|
||||
|
||||
auto int ao; // expected-error {{illegal storage class on file-scoped variable}}
|
||||
auto void af(); // expected-error {{illegal storage class on function}}
|
||||
|
||||
register int ro; // expected-error {{illegal storage class on file-scoped variable}}
|
||||
register void rf(); // expected-error {{illegal storage class on function}}
|
||||
|
||||
struct S {
|
||||
auto int ao; // expected-error {{storage class specified for a member declaration}}
|
||||
auto void af(); // expected-error {{storage class specified for a member declaration}}
|
||||
|
||||
register int ro; // expected-error {{storage class specified for a member declaration}}
|
||||
register void rf(); // expected-error {{storage class specified for a member declaration}}
|
||||
};
|
||||
|
||||
void foo(auto int ap, register int rp) {
|
||||
auto int abo;
|
||||
auto void abf(); // expected-error {{illegal storage class on function}}
|
||||
|
||||
register int rbo;
|
||||
register void rbf(); // expected-error {{illegal storage class on function}}
|
||||
}
|
Loading…
Reference in New Issue