summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules/odr_hash.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2017-03-25 00:48:52 +0000
committerRichard Trieu <rtrieu@google.com>2017-03-25 00:48:52 +0000
commit7583bec0c357918b23b7186e1149e7546bb31902 (patch)
treeeaefe400c09799eae7bd76f0fa68047c9735c6ab /clang/test/Modules/odr_hash.cpp
parent656bc5bb5c0f33b7329bab00071e0d94d7728d85 (diff)
downloadbcm5719-llvm-7583bec0c357918b23b7186e1149e7546bb31902.tar.gz
bcm5719-llvm-7583bec0c357918b23b7186e1149e7546bb31902.zip
[ODRHash] Add support for array and decayed types.
llvm-svn: 298754
Diffstat (limited to 'clang/test/Modules/odr_hash.cpp')
-rw-r--r--clang/test/Modules/odr_hash.cpp201
1 files changed, 81 insertions, 120 deletions
diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp
index 6069601b1e8..3acb23cb316 100644
--- a/clang/test/Modules/odr_hash.cpp
+++ b/clang/test/Modules/odr_hash.cpp
@@ -275,6 +275,33 @@ S11 s11;
// expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}}
#endif
+#if defined(FIRST)
+struct S12 {
+ unsigned x[5];
+};
+#elif defined(SECOND)
+struct S12 {
+ unsigned x[7];
+};
+#else
+S12 s12;
+// expected-error@first.h:* {{'Field::S12::x' from module 'FirstModule' is not present in definition of 'Field::S12' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S13 {
+ unsigned x[7];
+};
+#elif defined(SECOND)
+struct S13 {
+ double x[7];
+};
+#else
+S13 s13;
+// expected-error@first.h:* {{'Field::S13::x' from module 'FirstModule' is not present in definition of 'Field::S13' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
} // namespace Field
namespace Method {
@@ -476,6 +503,20 @@ S13 s13;
// expected-error@second.h:* {{'Method::S13' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter with default argument}}
// expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with different default argument}}
#endif
+
+#if defined(FIRST)
+struct S14 {
+ void A(int x[2]) {}
+};
+#elif defined(SECOND)
+struct S14 {
+ void A(int x[3]) {}
+};
+#else
+S14 s14;
+// expected-error@second.h:* {{'Method::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [3]'}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [2]'}}
+#endif
} // namespace Method
// Naive parsing of AST can lead to cycles in processing. Ensure
@@ -597,74 +638,52 @@ S3 s3;
// Interesting cases that should not cause errors. struct S should not error
// while struct T should error at the access specifier mismatch at the end.
+#define ALL_DECLS \
+public: \
+private: \
+protected: \
+ static_assert(1 == 1, "Message"); \
+ static_assert(2 == 2); \
+ \
+ int x; \
+ double y; \
+ \
+ INT z; \
+ \
+ unsigned a : 1; \
+ unsigned b : 2 * 2 + 5 / 2; \
+ \
+ mutable int c = sizeof(x + y); \
+ \
+ void method() {} \
+ static void static_method() {} \
+ virtual void virtual_method() {} \
+ virtual void pure_virtual_method() = 0; \
+ inline void inline_method() {} \
+ void volatile_method() volatile {} \
+ void const_method() const {} \
+ \
+ typedef int typedef_int; \
+ using using_int = int; \
+ \
+ void method_one_arg(int x) {} \
+ void method_one_arg_default_argument(int x = 5 + 5) {} \
+ void method_decayed_type(int x[5]) {} \
+ \
+ int constant_arr[5]; \
+ \
+ double last_decl;
+
namespace AllDecls {
#if defined(FIRST)
typedef int INT;
struct S {
- public:
- private:
- protected:
-
- static_assert(1 == 1, "Message");
- static_assert(2 == 2);
-
- int x;
- double y;
-
- INT z;
-
- unsigned a : 1;
- unsigned b : 2*2 + 5/2;
-
- mutable int c = sizeof(x + y);
-
- void method() {}
- static void static_method() {}
- virtual void virtual_method() {}
- virtual void pure_virtual_method() = 0;
- inline void inline_method() {}
- void volatile_method() volatile {}
- void const_method() const {}
-
- typedef int typedef_int;
- using using_int = int;
-
- void method_one_arg(int x) {}
- void method_one_arg_default_argument(int x = 5 + 5) {}
+ ALL_DECLS
};
#elif defined(SECOND)
typedef int INT;
struct S {
- public:
- private:
- protected:
-
- static_assert(1 == 1, "Message");
- static_assert(2 == 2);
-
- int x;
- double y;
-
- INT z;
-
- unsigned a : 1;
- unsigned b : 2 * 2 + 5 / 2;
-
- mutable int c = sizeof(x + y);
-
- void method() {}
- static void static_method() {}
- virtual void virtual_method() {}
- virtual void pure_virtual_method() = 0;
- inline void inline_method() {}
- void volatile_method() volatile {}
- void const_method() const {}
-
- typedef int typedef_int;
- using using_int = int;
-
- void method_one_arg(int x) {}
- void method_one_arg_default_argument(int x = 5 + 5) {}
+ ALL_DECLS
};
#else
S *s;
@@ -673,72 +692,14 @@ S *s;
#if defined(FIRST)
typedef int INT;
struct T {
- public:
- private:
- protected:
-
- static_assert(1 == 1, "Message");
- static_assert(2 == 2);
-
- int x;
- double y;
-
- INT z;
-
- unsigned a : 1;
- unsigned b : 2 * 2 + 5 / 2;
-
- mutable int c = sizeof(x + y);
-
- void method() {}
- static void static_method() {}
- virtual void virtual_method() {}
- virtual void pure_virtual_method() = 0;
- inline void inline_method() {}
- void volatile_method() volatile {}
- void const_method() const {}
-
- typedef int typedef_int;
- using using_int = int;
-
- void method_one_arg(int x) {}
- void method_one_arg_default_argument(int x = 5 + 5) {}
+ ALL_DECLS
private:
};
#elif defined(SECOND)
typedef int INT;
struct T {
- public:
- private:
- protected:
-
- static_assert(1 == 1, "Message");
- static_assert(2 == 2);
-
- int x;
- double y;
-
- INT z;
-
- unsigned a : 1;
- unsigned b : 2 * 2 + 5 / 2;
-
- mutable int c = sizeof(x + y);
-
- void method() {}
- static void static_method() {}
- virtual void virtual_method() {}
- virtual void pure_virtual_method() = 0;
- inline void inline_method() {}
- void volatile_method() volatile {}
- void const_method() const {}
-
- typedef int typedef_int;
- using using_int = int;
-
- void method_one_arg(int x) {}
- void method_one_arg_default_argument(int x = 5 + 5) {}
+ ALL_DECLS
public:
};
OpenPOWER on IntegriCloud