]> granicus.if.org Git - clang/commitdiff
Merge transparent union types using member's canonical param type
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 2 Dec 2010 20:02:29 +0000 (20:02 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 2 Dec 2010 20:02:29 +0000 (20:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120729 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/Sema/transparent-union.c

index 1bbe08e38d48a65529bcc4b934eefdcd3feafed0..42efcfbee7037b37152b659931ca3432e1b3db84 100644 (file)
@@ -4736,7 +4736,7 @@ QualType ASTContext::mergeTransparentUnionType(QualType T, QualType SubType,
     if (UD->hasAttr<TransparentUnionAttr>()) {
       for (RecordDecl::field_iterator it = UD->field_begin(),
            itend = UD->field_end(); it != itend; ++it) {
-        QualType ET = it->getType();
+        QualType ET = getCanonicalParamType(it->getType());
         QualType MT = mergeTypes(ET, SubType, OfBlockPointer, Unqualified);
         if (!MT.isNull())
           return MT;
index d13b4045a918f482232822a4f700b01d1d4de863..a825ed8a2e4b4759b2a01b6653795e0a259ad807 100644 (file)
@@ -2,6 +2,7 @@
 typedef union {
   int *ip;
   float *fp;
+  long *__restrict rlp;
 } TU __attribute__((transparent_union));
 
 void f(TU); // expected-note{{passing argument to parameter here}}
@@ -26,6 +27,9 @@ void fip(int *i) {}
 void ffp(TU);
 void ffp(float *f) {}
 
+void flp(TU);
+void flp(long *l) {}
+
 void fvp(TU); // expected-note{{previous declaration is here}}
 void fvp(void *p) {} // expected-error{{conflicting types}}