File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ void CheckExceptionSafety::noexceptThrows()
192192 if (scope->function && scope->function ->isNoExcept &&
193193 (!scope->function ->noexceptArg || scope->function ->noexceptArg ->str () == " true" )) {
194194 for (const Token *tok = scope->classStart ->next (); tok != scope->classEnd ; tok = tok->next ()) {
195- if (tok->str () ! = " throw" ) {
195+ if (tok->str () = = " throw" ) {
196196 noexceptThrowError (tok);
197197 }
198198 }
@@ -213,7 +213,7 @@ void CheckExceptionSafety::nothrowThrows()
213213 // onlycheck throw() functions
214214 if (scope->function && scope->function ->isThrow && !scope->function ->throwArg ) {
215215 for (const Token *tok = scope->classStart ->next (); tok != scope->classEnd ; tok = tok->next ()) {
216- if (tok->str () ! = " throw" ) {
216+ if (tok->str () = = " throw" ) {
217217 nothrowThrowError (tok);
218218 }
219219 }
Original file line number Diff line number Diff line change @@ -317,12 +317,20 @@ class TestExceptionSafety : public TestFixture {
317317 " void func3() noexcept(false) { throw 1; }\n " );
318318 ASSERT_EQUALS (" [test.cpp:1]: (error) Exception thrown in noexcept function.\n "
319319 " [test.cpp:2]: (error) Exception thrown in noexcept function.\n " , errout.str ());
320+
321+ // avoid false positives
322+ check (" const char *func() noexcept { return 0; }\n " );
323+ ASSERT_EQUALS (" " , errout.str ());
320324 }
321325
322326 void nothrowThrow () {
323327 check (" void func1() throw() { throw 1; }\n "
324328 " void func2() throw(int) { throw 1; }\n " );
325329 ASSERT_EQUALS (" [test.cpp:1]: (error) Exception thrown in throw() function.\n " , errout.str ());
330+
331+ // avoid false positives
332+ check (" const char *func() throw() { return 0; }\n " );
333+ ASSERT_EQUALS (" " , errout.str ());
326334 }
327335};
328336
You can’t perform that action at this time.
0 commit comments