summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/attr-nonnull.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang] prevent crash for nonnull attribut in constant context (Bug 43601)Gauthier Harnisch2019-10-101-3/+4
| | | | | | | | | | | | | | | | | | Summary: bug : https://bugs.llvm.org/show_bug.cgi?id=43601 Reviewers: rnk Reviewed By: rnk Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68716 llvm-svn: 374285
* [clang] perform semantic checking in constant contextGauthier Harnisch2019-06-151-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Since the addition of __builtin_is_constant_evaluated the result of an expression can change based on whether it is evaluated in constant context. a lot of semantic checking performs evaluations with out specifying context. which can lead to wrong diagnostics. for example: ``` constexpr int i0 = (long long)__builtin_is_constant_evaluated() * (1ll << 33); //#1 constexpr int i1 = (long long)!__builtin_is_constant_evaluated() * (1ll << 33); //#2 ``` before the patch, #2 was diagnosed incorrectly and #1 wasn't diagnosed. after the patch #1 is diagnosed as it should and #2 isn't. Changes: - add a flag to Sema to passe in constant context mode. - in SemaChecking.cpp calls to Expr::Evaluate* are now done in constant context when they should. - in SemaChecking.cpp diagnostics for UB are not checked for in constant context because an error will be emitted by the constant evaluator. - in SemaChecking.cpp diagnostics for construct that cannot appear in constant context are not checked for in constant context. - in SemaChecking.cpp diagnostics on constant expression are always emitted because constant expression are always evaluated. - semantic checking for initialization of constexpr variables is now done in constant context. - adapt test that were depending on warning changes. - add test. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62009 llvm-svn: 363488
* Fix representation of __attribute__((nonnull)) to support correctly modelingRichard Smith2014-08-271-2/+2
| | | | | | | | | | | | | | | the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B, C))) attribute, since that does the wrong thing for function templates and varargs functions. In passing, fix a grammar error in the diagnostic, a crash if __attribute__((nonnull(N))) is applied to a varargs function, a bug where the same null argument could be diagnosed multiple times if there were multiple nonnull attributes referring to it, and a bug where nonnull attributes would not be accumulated correctly across redeclarations. llvm-svn: 216520
* Start checking nonnull (as well as format and argument_with_type_tag) onNick Lewycky2013-01-241-0/+12
| | | | | | overloaded binary operators. llvm-svn: 173315
* Make __attribute__((nonnull)) use the general expression evaluator to search forNick Lewycky2013-01-231-0/+9
| | | | | | | nulls instead of limiting itself to the language-defined "null pointer constant". llvm-svn: 173227
* Apply the nonnull attribute to constructor expressions too.Nick Lewycky2011-03-251-1/+5
| | | | llvm-svn: 128253
* __attribute__((nonnull)) can apply to reference-to-pointerDouglas Gregor2010-12-151-0/+11
| | | | | | parameters. Fixes <rdar://problem/8769025>. llvm-svn: 121864
* Re-work the handling of implicit 'this' arguments and silly GCC-style attributeChandler Carruth2010-11-161-0/+18
argument indexes. This handles the offsets in a consistent manner for all of the attributes which I saw working with these concepts. I've also added tests for the attribute that motivated this: nonnull. I consolidated the tests for format attributes into one file, and fleshed them out a bit to trigger more of the warning cases. Also improved the quality of some of the diagnostics that occur with invalid argument indices. The only really questionable change here is supporting the implicit this argument for the ownership attribute. I'm not sure it's really a sensible concept there, but implemented the logic for consistency. llvm-svn: 119339
OpenPOWER on IntegriCloud