Tighten checking of the "overloadable" attribute. If any function by a
given name in a given scope is marked as "overloadable", every
function declaration and definition with that same name and in that
same scope needs to have the "overloadable" attribute. Essentially,
the "overloadable" attribute is not part of attribute merging, so it
must be specified even for redeclarations. This keeps users from
trying to be too sneaky for their own good:
double sin(double) __attribute__((overloadable)); // too sneaky
#include <math.h>
Previously, this would have made "sin" overloadable, and therefore
given it a mangled name. Now, we get an error inside math.h when we
see a (re)declaration of "sin" that doesn't have the "overloadable"
attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64414 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c
index 5118e40..040b7fa 100644
--- a/test/Sema/overloadable.c
+++ b/test/Sema/overloadable.c
@@ -2,9 +2,10 @@
int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}}
-int *f(int) __attribute__((overloadable)); // expected-note{{previous overload of function is here}}
+int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
-int *f(int); // expected-note{{previous declaration is here}}
+int *f(int); // expected-error{{redeclaration of 'f' must have the 'overloadable' attribute}} \
+ // expected-note{{previous declaration is here}}
double *f(double) __attribute__((overloadable)); // okay, new
void test_f(int iv, float fv, double dv) {
@@ -35,3 +36,5 @@
}
double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}}
+
+