]> granicus.if.org Git - clang/commitdiff
Exclude invalid old decl from mismatching linkage assertion
authorIsmail Pazarbasi <ismail.pazarbasi@gmail.com>
Thu, 6 Mar 2014 21:48:45 +0000 (21:48 +0000)
committerIsmail Pazarbasi <ismail.pazarbasi@gmail.com>
Thu, 6 Mar 2014 21:48:45 +0000 (21:48 +0000)
This patch fixes PR18964. In linkage computation, assertion fails when
an old invalid declaration's linkage mismatches with the current
decl's one.

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

lib/AST/Decl.cpp
test/SemaCXX/linkage2.cpp

index e362c730d404d2c6895c678ee206982d60953975..db404ec5fe3c625037e29c46d1bf23fa9d5615cb 100644 (file)
@@ -1243,8 +1243,7 @@ public:
 
     // We have just computed the linkage for this decl. By induction we know
     // that all other computed linkages match, check that the one we just
-    // computed
-    // also does.
+    // computed also does.
     NamedDecl *Old = NULL;
     for (NamedDecl::redecl_iterator I = D->redecls_begin(),
                                     E = D->redecls_end();
@@ -1252,7 +1251,7 @@ public:
       NamedDecl *T = cast<NamedDecl>(*I);
       if (T == D)
         continue;
-      if (T->hasCachedLinkage()) {
+      if (!T->isInvalidDecl() && T->hasCachedLinkage()) {
         Old = T;
         break;
       }
index 075f5e70c247d253c9be60f8b3ed206c3e40a309..a7eb15f7c6be6b2babb8fd2a0fc9496daf55cac6 100644 (file)
@@ -213,3 +213,7 @@ namespace PR16247 {
   void pr16247_bar(int) {}
   void pr16247_bar(double) {}
 }
+namespace PR18964 {
+  unsigned &*foo; //expected-error{{'foo' declared as a pointer to a reference of type}}
+  extern struct {} *foo; // don't assert
+}