r296099 - Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

Roger Ferrer Ibanez via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 00:41:09 PST 2017


Author: rogfer01
Date: Fri Feb 24 02:41:09 2017
New Revision: 296099

URL: http://llvm.org/viewvc/llvm-project?rev=296099&view=rev
Log:
Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

Fix an assertion that is hit when a redeclaration with differing types only
differs in the unaligned type-qualifier.

Differential Revision: https://reviews.llvm.org/D29986


Added:
    cfe/trunk/test/Sema/unaligned-qualifier.c
Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=296099&r1=296098&r2=296099&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 24 02:41:09 2017
@@ -8077,7 +8077,8 @@ QualType ASTContext::mergeTypes(QualType
     // mismatch.
     if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
         LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
-        LQuals.getObjCLifetime() != RQuals.getObjCLifetime())
+        LQuals.getObjCLifetime() != RQuals.getObjCLifetime() ||
+        LQuals.hasUnaligned() != RQuals.hasUnaligned())
       return QualType();
 
     // Exactly one GC qualifier difference is allowed: __strong is

Added: cfe/trunk/test/Sema/unaligned-qualifier.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unaligned-qualifier.c?rev=296099&view=auto
==============================================================================
--- cfe/trunk/test/Sema/unaligned-qualifier.c (added)
+++ cfe/trunk/test/Sema/unaligned-qualifier.c Fri Feb 24 02:41:09 2017
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fms-extensions
+
+int __unaligned * p1; // expected-note {{previous definition is here}}
+int * p1; // expected-error {{redefinition of 'p1' with a different type: 'int *' vs '__unaligned int *'}}




More information about the cfe-commits mailing list