Skip to content

Commit 16479cf

Browse files
committed
Fix regression where function overload candidates might not be reported and add test.
1 parent 2e2e2fe commit 16479cf

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
267267
operator-overloading
268268
oslc-comma oslc-D
269269
oslc-err-arrayindex oslc-err-closuremul oslc-err-field
270-
oslc-err-format oslc-err-funcredef oslc-err-intoverflow
271-
oslc-err-noreturn oslc-err-notfunc
270+
oslc-err-format oslc-err-funcoverload oslc-err-funcredef
271+
oslc-err-intoverflow oslc-err-noreturn oslc-err-notfunc
272272
oslc-err-outputparamvararray oslc-err-paramdefault
273273
oslc-err-struct-array-init oslc-err-struct-ctr
274274
oslc-err-struct-dup

src/liboslcomp/typecheck.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,9 @@ ASTfunction_call::typecheck (TypeSpec expected)
13921392
return typecheck_struct_constructor ();
13931393
}
13941394

1395+
// Save the current symbol to maybe report an error later.
1396+
FunctionSymbol *poly = func();
1397+
13951398
CandidateFunctions candidates(m_compiler, expected, args(), func());
13961399
std::tie(m_sym, m_typespec) = candidates.best(this);
13971400

@@ -1418,8 +1421,10 @@ ASTfunction_call::typecheck (TypeSpec expected)
14181421
// message.
14191422
candidates.reportError(this, m_name);
14201423

1421-
for (FunctionSymbol *poly = func(); poly; poly = poly->nextpoly())
1424+
while (poly) {
14221425
candidates.reportAmbiguity(poly);
1426+
poly = poly->nextpoly();
1427+
}
14231428

14241429
return TypeSpec();
14251430
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test.osl:8: error: No matching function call to 'funca ()'
2+
test.osl:3 candidate function:
3+
void funca (int, int)
4+
test.osl:2 candidate function:
5+
void funca (int)
6+
test.osl:9: error: No matching function call to 'funca (int, int, int)'
7+
test.osl:3 candidate function:
8+
void funca (int, int)
9+
test.osl:2 candidate function:
10+
void funca (int)
11+
FAILED test.osl
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
3+
# command = oslc("test.osl")
4+
# don't even need that -- it's automatic
5+
failureok = 1 # this test is expected to have oslc errors
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
void funca(int a) {}
3+
void funca(int a, int b) {}
4+
5+
6+
shader test()
7+
{
8+
funca();
9+
funca(1,2,3);
10+
}
11+

0 commit comments

Comments
 (0)