Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it.

This fixes the missing warning here:

struct S {
    template <typename T>
    void meth() {
        char arr[3];
        arr[4] = 0; // warning: array index 4 is past the end of the array
    }
};

template <typename T>
void func() {
    char arr[3];
    arr[4] = 0; // no warning
}

llvm-svn: 170180
This commit is contained in:
Argyrios Kyrtzidis 2012-12-14 06:54:03 +00:00
parent 6fada2ddbd
commit 26444c5243
2 changed files with 4 additions and 4 deletions

View File

@ -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,

View File

@ -74,11 +74,11 @@ void test() {
}
template <int I> struct S {
char arr[I]; // expected-note 2 {{declared here}}
char arr[I]; // expected-note 3 {{declared here}}
};
template <int I> 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)}}
}