forked from apple/swift-clang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve diagnostic checking for va_start to also warn on other instan…
…ces of undefined behavior, such as a parameter declared with the register keyword in C, or a parameter of a type that undergoes default argument promotion. This helps cover some more of the CERT secure coding rule EXP58-CPP. Pass an object of the correct type to va_start (https://www.securecoding.cert.org/confluence/display/cplusplus/EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267338 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
102c3e1
commit 2340dc0
Showing
6 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -std=c++03 -verify %s | ||
|
||
class string; | ||
void f(const string& s, ...) { // expected-note {{parameter of type 'const string &' is declared here}} | ||
__builtin_va_list ap; | ||
__builtin_va_start(ap, s); // expected-warning {{passing an object of reference type to 'va_start' has undefined behavior}} | ||
} | ||
|
||
void g(register int i, ...) { | ||
__builtin_va_list ap; | ||
__builtin_va_start(ap, i); // okay | ||
} |