r203168 - Exclude invalid old decl from mismatching linkage assertion

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Thu Mar 6 13:48:46 PST 2014


Author: ismailp
Date: Thu Mar  6 15:48:45 2014
New Revision: 203168

URL: http://llvm.org/viewvc/llvm-project?rev=203168&view=rev
Log:
Exclude invalid old decl from mismatching linkage assertion

This patch fixes PR18964. In linkage computation, assertion fails when
an old invalid declaration's linkage mismatches with the current
decl's one.

Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/test/SemaCXX/linkage2.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=203168&r1=203167&r2=203168&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Mar  6 15:48:45 2014
@@ -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;
       }

Modified: cfe/trunk/test/SemaCXX/linkage2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage2.cpp?rev=203168&r1=203167&r2=203168&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage2.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage2.cpp Thu Mar  6 15:48:45 2014
@@ -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
+}





More information about the cfe-commits mailing list