testsuite: add infinite recursion test case [PR63388]

gcc/testsuite/ChangeLog:
	PR c++/63388
	* g++.dg/analyzer/infinite-recursion-pr63388.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2024-11-06 08:45:29 -05:00
parent 6f4977ee54
commit 85736ba8e1

View File

@ -0,0 +1,21 @@
// { dg-do compile { target c++11 } }
namespace std
{
class ostream;
extern ostream cout;
}
enum class Month {jan=1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec};
std::ostream& operator<<(std::ostream& os, Month m)
{
return os << m; // { dg-warning "infinite recursion" }
}
int main()
{
Month m = Month::may;
std::cout << m;
return 0;
}