diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-08-23 05:39:39 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-08-23 05:39:39 +0000 |
commit | 61c39a1ccddf7550d43deb5c3bae13a98aa78775 (patch) | |
tree | 682e23cc00e8cb1d76dc200c8de0c7999d0d15f9 /clang/test/Parser/MicrosoftExtensions.cpp | |
parent | 8c8f4325a597564aab8fd1baac2915bb35f830d1 (diff) | |
download | bcm5719-llvm-61c39a1ccddf7550d43deb5c3bae13a98aa78775.tar.gz bcm5719-llvm-61c39a1ccddf7550d43deb5c3bae13a98aa78775.zip |
Sema: Properly support Microsoft-mode template arguments
Summary:
There were two things known to be wrong with our implementation of MSVC
mode template arguments:
- We didn't properly handle __uuidof/CXXUuidofExpr and skipped all type
checking completely.
- We didn't allow for MSVC's extension of allowing certain constant
"foldable" expressions from showing up in template arguments.
They allow various casts dereference and address-of operations.
We can make it more general as we find further peculiarities but this
is the known extent.
Reviewers: rsmith, doug.gregor, rjmccall
Reviewed By: doug.gregor
CC: cfe-commits, rnk
Differential Revision: http://llvm-reviews.chandlerc.com/D1444
llvm-svn: 189087
Diffstat (limited to 'clang/test/Parser/MicrosoftExtensions.cpp')
-rw-r--r-- | clang/test/Parser/MicrosoftExtensions.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/test/Parser/MicrosoftExtensions.cpp b/clang/test/Parser/MicrosoftExtensions.cpp index 3df461053d4..1102fcbcec8 100644 --- a/clang/test/Parser/MicrosoftExtensions.cpp +++ b/clang/test/Parser/MicrosoftExtensions.cpp @@ -95,10 +95,10 @@ void template_uuid() } -template <class T, const GUID* g = &__uuidof(T)> +template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}} class COM_CLASS_TEMPLATE { }; -typedef COM_CLASS_TEMPLATE<struct_with_uuid, &__uuidof(struct_with_uuid)> COM_TYPE_1; +typedef COM_CLASS_TEMPLATE<struct_with_uuid, &*&__uuidof(struct_with_uuid)> COM_TYPE_1; // expected-warning {{non-type template argument containing a dereference operation is a Microsoft extension}} typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; template <class T, const GUID& g> @@ -112,6 +112,9 @@ typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM } struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid; +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}} class CtorCall { public: |