summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-04 17:13:46 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-04 17:13:46 +0000
commitb258569405a020161fb8991913f03b938987dab5 (patch)
tree0e0bb1baedc042fbe09ab6fd7f3775163caf3986 /clang/test/Modules
parent9b7b39116ea07aea979ea49c4ec32ded85a5019f (diff)
downloadbcm5719-llvm-b258569405a020161fb8991913f03b938987dab5.tar.gz
bcm5719-llvm-b258569405a020161fb8991913f03b938987dab5.zip
Implement declaration merging for non-template functions from
different modules. This implementation is a first approximation of what we want, using only the function type to determine equivalence. Later, we'll want to deal with some of the more subtle issues, including: - C allows a prototyped declaration and a non-prototyped declaration to be merged, which we should support - We may want to ignore the return type when merging, then complain if the return types differ. Or, we may want to leave it as it us, so that we only complain if overload resolution eventually fails. - C++ non-static member functions need to consider cv-qualifiers and ref-qualifiers. - Function templates need to consider the template parameters and return type. - Function template specializations will have special rules. - We can now (accidentally!) end up overloading in C, even without the "overloadable" attribute, and will need to detect this at some point. The actual detection of "is this an overload?" is implemented by Sema::IsOverload(), which will need to be moved into the AST library for re-use here. That will be a future refactor. llvm-svn: 147534
Diffstat (limited to 'clang/test/Modules')
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-left.h4
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-right.h7
-rw-r--r--clang/test/Modules/redecl-merge.m8
3 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/redecl-merge-left.h b/clang/test/Modules/Inputs/redecl-merge-left.h
index 47f3492f309..3eb0a735fa9 100644
--- a/clang/test/Modules/Inputs/redecl-merge-left.h
+++ b/clang/test/Modules/Inputs/redecl-merge-left.h
@@ -59,6 +59,10 @@ void consume_S4(struct S4*);
typedef int T1;
typedef float T2;
+int func0(int);
+int func1(int);
+int func2(int);
+
#ifdef __cplusplus
template<typename T> class Vector;
diff --git a/clang/test/Modules/Inputs/redecl-merge-right.h b/clang/test/Modules/Inputs/redecl-merge-right.h
index 315a9c37fff..9660199c72d 100644
--- a/clang/test/Modules/Inputs/redecl-merge-right.h
+++ b/clang/test/Modules/Inputs/redecl-merge-right.h
@@ -62,6 +62,13 @@ struct S4 *produce_S4(void);
typedef int T1;
typedef double T2;
+int func0(int);
+int func1(int);
+int func1(int);
+int func1(int);
+int func1(int);
+static int func2(int);
+
#ifdef __cplusplus
template<typename T> class Vector {
public:
diff --git a/clang/test/Modules/redecl-merge.m b/clang/test/Modules/redecl-merge.m
index 44d427c4c75..b8752610fb4 100644
--- a/clang/test/Modules/redecl-merge.m
+++ b/clang/test/Modules/redecl-merge.m
@@ -61,9 +61,17 @@ void testTypedefMerge(int i, double d) {
// FIXME: Typedefs aren't actually merged in the sense of other merges, because
// we should only merge them when the types are identical.
// in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // in other file: expected-note{{candidate function}}
T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}}
}
+void testFuncMerge(int i) {
+ func0(i);
+ // in other file: expected-note{{candidate function}}
+ func1(i);
+ func2(i); // expected-error{{call to 'func2' is ambiguous}}
+}
+
// Test redeclarations of entities in explicit submodules, to make
// sure we're maintaining the declaration chains even when normal name
// lookup can't see what we're looking for.
OpenPOWER on IntegriCloud