diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-09-07 06:59:46 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-09-07 06:59:46 +0000 |
commit | 59c0ec23966acc3f6f2631b6cf09e56d2f2c2af0 (patch) | |
tree | 80e511242550c55e3c00d3da77a83da4a37ac49b /clang/test/Parser/MicrosoftExtensions.cpp | |
parent | 76e98feb578c0cba1500554227699dafd9afe600 (diff) | |
download | bcm5719-llvm-59c0ec23966acc3f6f2631b6cf09e56d2f2c2af0.tar.gz bcm5719-llvm-59c0ec23966acc3f6f2631b6cf09e56d2f2c2af0.zip |
AST: __uuidof should leak through templated types
Summary:
__uuidof on templated types should exmaine if any of its template
parameters have a uuid declspec. If exactly one does, then take it.
Otherwise, issue an appropriate error.
Reviewers: rsmith, thakis, rnk
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1419
llvm-svn: 190240
Diffstat (limited to 'clang/test/Parser/MicrosoftExtensions.cpp')
-rw-r--r-- | clang/test/Parser/MicrosoftExtensions.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/Parser/MicrosoftExtensions.cpp b/clang/test/Parser/MicrosoftExtensions.cpp index c2d749a288f..ef873d64306 100644 --- a/clang/test/Parser/MicrosoftExtensions.cpp +++ b/clang/test/Parser/MicrosoftExtensions.cpp @@ -116,6 +116,25 @@ COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg; COM_CLASS_TEMPLATE<int, __uuidof(struct_with_uuid)> bad_template_arg; // expected-error {{non-type template argument of type 'const _GUID' is not a constant expression}} +namespace PR16911 { +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid2; + +template <typename T, typename T2> +struct thing { +}; + +struct empty {}; +struct inher : public thing<empty, uuid2> {}; + +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; +const struct _GUID *w = &__uuidof(inher); // expected-error{{cannot call operator __uuidof on a type with no GUID}} +const struct _GUID *x = &__uuidof(thing<uuid, inher>); +const struct _GUID *y = &__uuidof(thing<uuid2, uuid>); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} +thing<uuid2, uuid> thing_obj = thing<uuid2, uuid>(); +const struct _GUID *z = &__uuidof(thing_obj); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} +} + class CtorCall { public: CtorCall& operator=(const CtorCall& that); |