This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Change diagnostic for function declaration
AbandonedPublic

Authored by svenvh on Jul 8 2019, 3:51 AM.

Details

Reviewers
Anastasia
Pierre
Summary

When declaring functions only differing by their return type,
diagnostic was indicating "conflicting types for" the function.
Similarly to c++, it is now indicating that "functions that differ
only in their return type cannot be overloaded".

For this code example:

float test (float p) {return 2.;}
double test (float p) {return 2.;}

This is changing this diagnostic:

tmp.cl:5:37: error: conflicting types for 'tee'
float __attribute__((overloadable)) test (float p) {return 2.;}
                                    ^
tmp.cl:4:38: note: previous definition is here
double __attribute__((overloadable)) test (float p) {return 2.;}
                                     ^
1 error generated.

To this:

tmp.cl:5:37: error: functions that differ only in their return type cannot be overloaded
float __attribute__((overloadable)) test (float p) {return 2.;}
~~~~~                               ^
1 error generated.

This should maybe be extended to other languages.

Diff Detail

Event Timeline

Pierre created this revision.Jul 8 2019, 3:51 AM
svenvh commandeered this revision.Apr 6 2020, 10:00 AM
svenvh abandoned this revision.
svenvh edited reviewers, added: Pierre; removed: svenvh.

Abandoning after an offline discussion with @Anastasia. Overloading is not a feature of OpenCL C in the first place so adding complexity to Clang isn't really justifiable.