From: Argyrios Kyrtzidis Date: Fri, 14 Dec 2012 06:54:03 +0000 (+0000) Subject: Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9990e80f5d1236277c87aa6fac03e0992c52341;p=clang Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it. This fixes the missing warning here: struct S { template void meth() { char arr[3]; arr[4] = 0; // warning: array index 4 is past the end of the array } }; template void func() { char arr[3]; arr[4] = 0; // no warning } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170180 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index b4f77988bd..cae0cfaf4c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -7945,7 +7945,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { diag::err_attribute_can_be_applied_only_to_symbol_declaration) << "dllimport"; FD->setInvalidDecl(); - return FD; + return D; } // Visual C++ appears to not think this is an issue, so only issue @@ -7962,7 +7962,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { // We want to attach documentation to original Decl (which might be // a function template). ActOnDocumentableDecl(D); - return FD; + return D; } /// \brief Given the set of return statements within a function body, diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp index 57a9e3de6a..80b3ee4289 100644 --- a/test/SemaCXX/array-bounds.cpp +++ b/test/SemaCXX/array-bounds.cpp @@ -74,11 +74,11 @@ void test() { } template struct S { - char arr[I]; // expected-note 2 {{declared here}} + char arr[I]; // expected-note 3 {{declared here}} }; template void f() { S<3> s; - s.arr[4] = 0; // expected-warning {{array index 4 is past the end of the array (which contains 3 elements)}} + s.arr[4] = 0; // expected-warning 2 {{array index 4 is past the end of the array (which contains 3 elements)}} s.arr[I] = 0; // expected-warning {{array index 5 is past the end of the array (which contains 3 elements)}} }