[cfe-commits] r74030 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp lib/Sema/SemaStmt.cpp test/CXX/class/class.local/p4.cpp
Anders Carlsson
andersca at mac.com
Tue Jun 23 17:28:54 PDT 2009
Author: andersca
Date: Tue Jun 23 19:28:53 2009
New Revision: 74030
URL: http://llvm.org/viewvc/llvm-project?rev=74030&view=rev
Log:
Support for [class.local]p4.
Added:
cfe/trunk/test/CXX/class/class.local/p4.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=74030&r1=74029&r2=74030&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jun 23 19:28:53 2009
@@ -1608,6 +1608,8 @@
"reference to local variable %0 declared in enclosed function %1">;
def note_local_variable_declared_here : Note<
"%0 declared here">;
+def err_static_data_member_not_allowed_in_local_class : Error<
+ "static data member %0 not allowed in local class %1">;
// C++ derived classes
def err_base_clause_on_union : Error<"unions cannot have base classes">;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=74030&r1=74029&r2=74030&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 23 19:28:53 2009
@@ -1807,6 +1807,15 @@
} else if (SC == VarDecl::None)
SC = VarDecl::Static;
}
+ if (SC == VarDecl::Static) {
+ if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
+ if (RD->isLocalClass())
+ Diag(D.getIdentifierLoc(),
+ diag::err_static_data_member_not_allowed_in_local_class)
+ << Name << RD->getDeclName();
+ }
+ }
+
// The variable can not
NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=74030&r1=74029&r2=74030&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Jun 23 19:28:53 2009
@@ -835,7 +835,6 @@
Action::OwningStmtResult
Sema::ActOnReturnStmt(SourceLocation ReturnLoc, FullExprArg rex) {
- bool RetValExprIsValid = !rex->isInvalid();
Expr *RetValExp = rex->takeAs<Expr>();
if (CurBlock)
return ActOnBlockReturnStmt(ReturnLoc, RetValExp);
Added: cfe/trunk/test/CXX/class/class.local/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.local/p4.cpp?rev=74030&view=auto
==============================================================================
--- cfe/trunk/test/CXX/class/class.local/p4.cpp (added)
+++ cfe/trunk/test/CXX/class/class.local/p4.cpp Tue Jun 23 19:28:53 2009
@@ -0,0 +1,10 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void f() {
+ struct X {
+ static int a; // expected-error {{static data member 'a' not allowed in local class 'X'}}
+ int b;
+
+ static void f() { }
+ };
+}
\ No newline at end of file
More information about the cfe-commits
mailing list