[cfe-commits] r74314 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaType.cpp test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
Anders Carlsson
andersca at mac.com
Fri Jun 26 12:33:28 PDT 2009
Author: andersca
Date: Fri Jun 26 14:33:28 2009
New Revision: 74314
URL: http://llvm.org/viewvc/llvm-project?rev=74314&view=rev
Log:
Can't have arrays of auto.
Added:
cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=74314&r1=74313&r2=74314&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 26 14:33:28 2009
@@ -401,6 +401,8 @@
// C++0x auto
def err_auto_variable_cannot_appear_in_own_initializer : Error<
"variable %0 declared with 'auto' type cannot appear in its own initializer">;
+def err_illegal_decl_array_of_auto : Error<
+ "'%0' declared as array of 'auto'">;
// Objective-C++
def err_objc_decls_may_only_appear_in_global_scope : Error<
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=74314&r1=74313&r2=74314&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jun 26 14:33:28 2009
@@ -498,6 +498,12 @@
return QualType();
}
+ if (Context.getCanonicalType(T) == Context.UndeducedAutoTy) {
+ Diag(Loc, diag::err_illegal_decl_array_of_auto)
+ << getPrintableNameForEntity(Entity);
+ return QualType();
+ }
+
if (const RecordType *EltTy = T->getAsRecordType()) {
// If the element type is a struct or union that contains a variadic
// array, accept it as a GNU extension: C99 6.7.2.1p2.
Added: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp?rev=74314&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp (added)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp Fri Jun 26 14:33:28 2009
@@ -0,0 +1,6 @@
+// RUN: clang-cc -fsyntax-only -verify -std=c++0x
+
+void f() {
+ int b[5];
+ auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}}
+}
More information about the cfe-commits
mailing list