AST: Handle multidimensional arrays inside of __uuidof()
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 27 Sep 2013 07:57:34 +0000 (07:57 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 27 Sep 2013 07:57:34 +0000 (07:57 +0000)
We previously handled one-dimensional arrays but didn't consider the
general case.  The fix is simple: keep going through subsequent
dimensions until we get to the base element.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191493 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprCXX.cpp
test/Parser/MicrosoftExtensions.cpp

index c7d2f78104bfc336da15a4bd16f0c9c5a7047df1..a13d6f79c86e8f93e752ebde4ecb55f29f3751b1 100644 (file)
@@ -62,7 +62,7 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT,
   if (QT->isPointerType() || QT->isReferenceType())
     Ty = QT->getPointeeType().getTypePtr();
   else if (QT->isArrayType())
-    Ty = cast<ArrayType>(QT)->getElementType().getTypePtr();
+    Ty = Ty->getBaseElementTypeUnsafe();
 
   // Loop all record redeclaration looking for an uuid attribute.
   CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
index ef873d6430604d31d453c084d8415bf0e5bbade2..0327499f272d25ea76e7301bf49eff0d8733da0b 100644 (file)
@@ -72,6 +72,10 @@ int uuid_sema_test()
    __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(struct_with_uuid[1]);
+   __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(const struct_with_uuid[1][1]);
+   __uuidof(const struct_with_uuid*[1][1]); // 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}}