def ext_extra_ivar_semi : Extension<
"extra ';' inside instance variable list">;
+def auto_storage_class : ExtWarn<
+ "'auto' storage class specifier is redundant and will be "
+ "removed in future releases">;
+
def ext_duplicate_declspec : Extension<"duplicate '%0' declaration specifier">;
def ext_plain_complex : ExtWarn<
"plain '_Complex' requires a type specifier; assuming '_Complex double'">;
DiagID, getLang());
break;
case tok::kw_auto:
- if (getLang().CPlusPlus0x || getLang().ObjC1)
- isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec,
- DiagID);
+ if (getLang().CPlusPlus0x || getLang().ObjC2) {
+ if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
+ isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_auto, Loc, PrevSpec,
+ DiagID, getLang());
+ if (!isInvalid)
+ Diag(Tok, diag::auto_storage_class)
+ << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
+ }
+ else
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec,
+ DiagID);
+ }
else
isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_auto, Loc, PrevSpec,
DiagID, getLang());
else
Diag(Tok, DiagID) << PrevSpec;
}
+
DS.SetRangeEnd(Tok.getLocation());
ConsumeToken();
}
auto x = 5;
const auto *v = &x, u = 6;
static auto y = 0.0;
- auto int r; // expected-error{{cannot combine with previous}} expected-error{{requires an initializer}}
+ auto int r; // expected-warning {{'auto' storage class specifier is redundant and will be removed in future releases}}
same<decltype(x), int> xHasTypeInt;
same<decltype(v), const int*> vHasTypeConstIntPtr;
--- /dev/null
+/* RUN: cp %s %t
+ RUN: %clang_cc1 -x objective-c -fixit %t
+ RUN: %clang_cc1 -x objective-c -Werror %t
+ */
+
+// rdar://9036633
+
+int main() {
+ auto int i = 0;
+ return i;
+}
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
void f() {
- auto int a; // expected-error{{cannot combine with previous 'auto' declaration specifier}} // expected-error{{declaration of variable 'a' with type 'auto' requires an initializer}}
+ auto int a; // expected-warning {{'auto' storage class specifier is redundant and will be removed in future releases}}
int auto b; // expected-error{{cannot combine with previous 'int' declaration specifier}}
}
return my_block;
}
@end
+
+
+// rdar://9036633
+int main() {
+ auto int auto_i = 7; // expected-warning {{'auto' storage class specifier is redundant and will be removed in future releases}}
+}