summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-unused-variables.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Suppress -Wwarn-unused-variables when we don't know the constructorErich Keane2019-12-121-0/+14
| | | | | | | | | | | | | | This warning is supposed to be suppressed when the constructor/destructor are non-trivial, since it might be a RAII type. However, if the type has a trivial destructor and the constructor hasn't been resolved (since it is called with dependent arguments), we were still warning. This patch suppresses the warning if the type could possibly have a be a non-trivial constructor call. Note that this does not take the arity of the constructors into consideration, so it might suppress the warning in cases where it isn't possible to call a non-trivial constructor.
* C++ DR2387: a variable template declared wtih (or instantiated with) aRichard Smith2019-04-261-1/+3
| | | | | | | | | const-qualified type is not implicitly given internal linkage. But a variable template declared 'static' is. This reinstates part of r359048, reverted in r359076. llvm-svn: 359260
* Revert r359048: C++ DR2387: a variable template declared wthiIlya Biryukov2019-04-241-3/+1
| | | | | | | | | | | | | The change breaks libc++ with the follwing error: In file included from valarray:4: .../include/c++/v1/valarray:1062:60: error: explicit instantiation declaration of 'valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t)) ^ .../include/c++/v1/valarray:1063:60: error: explicit instantiation declaration of '~valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray()) llvm-svn: 359076
* C++ DR2387: a variable template declared wtih (or instantiated with) aRichard Smith2019-04-231-1/+3
| | | | | | | const-qualified type is not implicitly given internal linkage. But a variable template declared 'static' is. llvm-svn: 359048
* [Sema] Fix assertion failure when checking for unused variables in a ↵Benjamin Kramer2017-10-191-0/+10
| | | | | | dependent context. llvm-svn: 316177
* Re-land r315787, "[Sema] Warn about unused variables if we can constant ↵Benjamin Kramer2017-10-141-0/+33
| | | | | | | | evaluate the initializer." The warnings in libc++ tests were fixed in the meantime. llvm-svn: 315811
* Revert rL315787, "[Sema] Warn about unused variables if we can constant ↵NAKAMURA Takumi2017-10-141-33/+0
| | | | | | | | evaluate the initializer." check-libcxx dislikes it. llvm-svn: 315806
* [Sema] Warn about unused variables if we can constant evaluate the initializer.Benjamin Kramer2017-10-141-0/+33
| | | | | | | | | | If the variable construction can be constant evaluated it doesn't have side effects, so removing it is always safe. We only try to evaluate variables that are unused, there should be no impact on compile time. Differential Revision: https://reviews.llvm.org/D38678 llvm-svn: 315787
* Simplify the test case from r285289.Alex Lorenz2016-11-021-20/+13
| | | | | | | | | This commit simplifies and clarifies the test code that was added in r285289. Suggested by David Blaikie. llvm-svn: 285825
* [Sema] -Wunused-variable warning for array variables should behaveAlex Lorenz2016-10-271-0/+51
| | | | | | | | | | | | | | similarly to scalar variables. This commit makes the -Wunused-variable warning behaviour more consistent: Now clang won't warn for array variables where it doesn't warn for scalar variables. rdar://24158862 Differential Revision: https://reviews.llvm.org/D25937 llvm-svn: 285289
* PR19558: don't produce an "unused variable" warning for a variable template ↵Richard Smith2014-04-251-0/+11
| | | | | | partial specialization. llvm-svn: 207260
* PR19305: Don't issue -Wunused-variable warnings on variable templates. It's notRichard Smith2014-04-021-24/+12
| | | | | | | | | | | meaningful to odr-use the VarDecl inside a variable template. (Separately, it'd be nice to track referenced-ness for templates, and warn on unused ones, but that's really a distinct issue...) Move a test that generates and tests a warning-suppressing error out to its own test file, so it doesn't have weird effects on the other tests in the same file. llvm-svn: 205448
* PR8455: Handle an attribute between a goto label and a variable declaration perRichard Smith2013-11-151-1/+24
| | | | | | | the GNU documentation: the attribute only appertains to the label if it is followed by a semicolon. Based on a patch by Aaron Ballman! llvm-svn: 194869
* Suppress -Wunused-variable for variables declared in headers, which may inMatt Beaumont-Gay2013-04-101-9/+2
| | | | | | | | | | | fact be defined and used in another TU. Reshuffle some test cases because we suppress -Wunused-variable after we've emitted an error. This fixes PR15558. llvm-svn: 179138
* Fix false positive in -Wunused-variable when a ctor call make involve cleanups.David Blaikie2012-10-241-0/+12
| | | | llvm-svn: 166625
* Fix a crash-on-invalid when parsing a reference to an invalid auto declarationDavid Blaikie2012-10-101-2/+3
| | | | | | | | | auto x((unknown)); int& y = x; would crash because we were not flagging 'x' as an invalid declaration here. llvm-svn: 165675
* Improvements to the uninitialized variable warning: Check if the constructorRafael Espindola2012-01-061-0/+42
| | | | | | | call is elidable or if the constructor is trivial instead of checking if it is user declared. llvm-svn: 147652
* Fix PR10168: don't warn for unused non-dependent variables in both the ↵Richard Smith2011-06-211-0/+26
| | | | | | template definition and each instantiation. llvm-svn: 133580
* Clean up the tests for warning about unused function results given theChandler Carruth2011-02-211-11/+0
| | | | | | | | appropriate attribute. Add a bit more testing that finds a pretty bad regression (since ~forever) in this warning. Fix it with a nice 2 line change. =] llvm-svn: 126098
* Make #pragma unused work for static local variables.Douglas Gregor2010-11-091-0/+6
| | | | llvm-svn: 118500
* Revert r114316, -Wunused-value enabled by default was intended.Argyrios Kyrtzidis2010-09-191-1/+1
| | | | llvm-svn: 114318
* Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.Argyrios Kyrtzidis2010-09-191-1/+1
| | | | llvm-svn: 114316
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-1/+1
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-1/+1
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Do not use CXXZeroValueInitExpr for class types. Instead, useDouglas Gregor2010-07-071-1/+1
| | | | | | | | | CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as appropriate. Fixes PR7556, and provides a slide codegen improvement when copy-initializing a POD class type from a value-initialized temporary. Previously, we weren't eliding the copy. llvm-svn: 107827
* Don't look into incomplete types when trying to warn about unusedDouglas Gregor2010-04-271-0/+8
| | | | | | variables. Fixes PR6948. llvm-svn: 102436
* When we have a dependent direct initializer but not a dependentDouglas Gregor2010-02-111-5/+13
| | | | | | | | variable type, we can (and should) still check for completeness of the variable's type. Do so, to work around an assertion that shows up in Boost's shared_ptr. llvm-svn: 95934
* support the warn_unused_result in C++ class methodsNuno Lopes2009-12-241-0/+11
| | | | llvm-svn: 92095
* Update tests to use %clang instead of 'clang', and forcibly disable use of 'Daniel Dunbar2009-12-151-1/+1
| | | | | | | clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to garbage). llvm-svn: 91460
* Fix PR5531.Anders Carlsson2009-11-171-0/+20
| | | | llvm-svn: 89106
* Add bug number.Anders Carlsson2009-11-071-2/+2
| | | | llvm-svn: 86357
* Don't treat variables with non-trivial ctors or dtors as unused. Fixes PR5407.Anders Carlsson2009-11-071-0/+8
| | | | llvm-svn: 86352
* Implement support for -Wunused-variable, from Oscar Bonilla!Douglas Gregor2009-10-081-0/+6
llvm-svn: 83577
OpenPOWER on IntegriCloud