[cfe-commits] r170180 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/array-bounds.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Dec 13 22:54:03 PST 2012
Author: akirtzidis
Date: Fri Dec 14 00:54:03 2012
New Revision: 170180
URL: http://llvm.org/viewvc/llvm-project?rev=170180&view=rev
Log:
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
}
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/array-bounds.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=170180&r1=170179&r2=170180&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 14 00:54:03 2012
@@ -7945,7 +7945,7 @@
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 @@
// 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,
Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=170180&r1=170179&r2=170180&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Fri Dec 14 00:54:03 2012
@@ -74,11 +74,11 @@
}
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)}}
}
More information about the cfe-commits
mailing list