@@ -595,6 +595,7 @@ class TestSymbolDatabase : public TestFixture {
595595 TEST_CASE(valueTypeThis);
596596 TEST_CASE(valueTypeChar);
597597 TEST_CASE(valueTypeRValueReference);
598+ TEST_CASE(valueTypeGeneric);
598599
599600 TEST_CASE(variadic1); // #7453
600601 TEST_CASE(variadic2); // #7649
@@ -10401,6 +10402,72 @@ class TestSymbolDatabase : public TestFixture {
1040110402 TODO_ASSERT_EQUALS("", "bool", typeOf("void f(std::string&& s = {})\n", "&&"));
1040210403 }
1040310404
10405+ void valueTypeGeneric() {
10406+ ASSERT_EQUALS("float", typeOf(
10407+ "float floatvar;\n"
10408+ "int intvar;\n"
10409+ "void testfunc() {\n"
10410+ " int controlvar;\n"
10411+ " auto testvar = _Generic(controlvar, int: floatvar, default: intvar);\n"
10412+ "}\n", "testvar"));
10413+
10414+ ASSERT_EQUALS("signed int", typeOf(
10415+ "float floatvar;\n"
10416+ "int intvar;\n"
10417+ "void testfunc() {\n"
10418+ " float controlvar;\n"
10419+ " auto testvar = _Generic(controlvar, int: floatvar, default: intvar);\n"
10420+ "}\n", "testvar"));
10421+
10422+ ASSERT_EQUALS("float", typeOf(
10423+ "float floatvar;\n"
10424+ "int intvar;\n"
10425+ "void testfunc() {\n"
10426+ " int *const controlvar;\n"
10427+ " auto testvar = _Generic(controlvar, int*: floatvar, default: intvar);\n"
10428+ "}\n", "testvar"));
10429+
10430+ ASSERT_EQUALS("signed int", typeOf(
10431+ "float floatvar;\n"
10432+ "int intvar;\n"
10433+ "void testfunc() {\n"
10434+ " const int *controlvar;\n"
10435+ " auto testvar = _Generic(controlvar, int*: floatvar, default: intvar);\n"
10436+ "}\n", "testvar"));
10437+
10438+ ASSERT_EQUALS("float", typeOf(
10439+ "float floatfunc();\n"
10440+ "int intfunc();\n"
10441+ "void testfunc() {\n"
10442+ " int controlvar;\n"
10443+ " auto testvar = _Generic(controlvar, int: floatfunc, default: intfunc)();\n"
10444+ "}\n", "testvar"));
10445+
10446+ ASSERT_EQUALS("signed int", typeOf(
10447+ "float floatfunc();\n"
10448+ "int intfunc();\n"
10449+ "void testfunc() {\n"
10450+ " float controlvar;\n"
10451+ " auto testvar = _Generic(controlvar, int: floatfunc, default: intfunc)();\n"
10452+ "}\n", "testvar"));
10453+
10454+ ASSERT_EQUALS("float", typeOf(
10455+ "float floatfunc();\n"
10456+ "int intfunc();\n"
10457+ "void testfunc() {\n"
10458+ " int *const controlvar;\n"
10459+ " auto testvar = _Generic(controlvar, int*: floatfunc, default: intfunc)();\n"
10460+ "}\n", "testvar"));
10461+
10462+ ASSERT_EQUALS("signed int", typeOf(
10463+ "float floatfunc();\n"
10464+ "int intfunc();\n"
10465+ "void testfunc() {\n"
10466+ " const int *controlvar;\n"
10467+ " auto testvar = _Generic(controlvar, int*: floatfunc, default: intfunc)();\n"
10468+ "}\n", "testvar"));
10469+ }
10470+
1040410471 void variadic1() { // #7453
1040510472 {
1040610473 GET_SYMBOL_DB("CBase* create(const char *c1, ...);\n"
0 commit comments