Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ Improvements to Clang's diagnostics

- Clang now omits shadowing warnings for parameter names in explicit object member functions (#GH95707).

- For an rvalue reference bound to a temporary struct with an integer member, Clang will detect constant integer overflow
in the initializer for the integer member (#GH46755).

Improvements to Clang's time-trace
----------------------------------

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12048,7 +12048,8 @@ void Sema::CheckForIntOverflow (const Expr *E) {
New && New->isArray()) {
if (auto ArraySize = New->getArraySize())
Exprs.push_back(*ArraySize);
}
} else if (const auto *Mte = dyn_cast<MaterializeTemporaryExpr>(OriginalE))
Exprs.push_back(Mte->getSubExpr());
} while (!Exprs.empty());
}

Expand Down
6 changes: 6 additions & 0 deletions clang/test/SemaCXX/integer-overflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,10 @@ int m() {
return 0;
}
}

namespace GH46755 {
void f() {
struct { int v; } &&r = {512 * 1024 * 1024 * 1024}; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
}
}
#endif
Loading