summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/MicrosoftExtensions.cpp
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2010-12-20 03:51:03 +0000
committerFrancois Pichet <pichet2000@gmail.com>2010-12-20 03:51:03 +0000
commit9dddd40a1caf45695ec94c5f5c46a23461c2bf47 (patch)
tree2d852c11d3e86d245ced04bbedbf0571d4df6734 /clang/test/Parser/MicrosoftExtensions.cpp
parent660bce67f31a1b45eaee55ce0cad440b61ac5b6b (diff)
downloadbcm5719-llvm-9dddd40a1caf45695ec94c5f5c46a23461c2bf47.tar.gz
bcm5719-llvm-9dddd40a1caf45695ec94c5f5c46a23461c2bf47.zip
Emit an error if operator __uuidof() is called on a type with no associated GUID.
llvm-svn: 122226
Diffstat (limited to 'clang/test/Parser/MicrosoftExtensions.cpp')
-rw-r--r--clang/test/Parser/MicrosoftExtensions.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/clang/test/Parser/MicrosoftExtensions.cpp b/clang/test/Parser/MicrosoftExtensions.cpp
index e55e74cb839..ef4a3f6d784 100644
--- a/clang/test/Parser/MicrosoftExtensions.cpp
+++ b/clang/test/Parser/MicrosoftExtensions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
@@ -23,3 +23,49 @@ extern "C" {
}
+void uuidof_test1()
+{
+ __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}}
+}
+
+typedef struct _GUID
+{
+ unsigned long Data1;
+ unsigned short Data2;
+ unsigned short Data3;
+ unsigned char Data4[8];
+} GUID;
+
+struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
+struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
+struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}}
+struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
+struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
+
+
+
+struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
+struct_with_uuid { };
+struct struct_without_uuid { };
+
+
+int uuid_sema_test()
+{
+ struct_with_uuid var_with_uuid[1];
+ struct_without_uuid var_without_uuid[1];
+
+ __uuidof(struct_with_uuid);
+ __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(struct_with_uuid*);
+ __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+
+ __uuidof(var_with_uuid);
+ __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(var_with_uuid[1]);
+ __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(&var_with_uuid[1]);
+ __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+
+ __uuidof(0);
+ __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+}
OpenPOWER on IntegriCloud