Преглед на файлове

[AST] Fix a crash on invalid.

Problem was that we were appending to the source location info buffer in the
copy assignment operator (instead of overwriting).

rdar://42746401

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341869 91177308-0d34-0410-b5e6-96231b3b80d8
Erik Pilkington преди 7 години
родител
ревизия
e2195ee646
променени са 2 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 1 0
      lib/AST/NestedNameSpecifier.cpp
  2. 7 0
      test/SemaCXX/rdar42746401.cpp

+ 1 - 0
lib/AST/NestedNameSpecifier.cpp

@@ -547,6 +547,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) {
   }
   }
 
 
   // Deep copy.
   // Deep copy.
+  BufferSize = 0;
   Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
   Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
          BufferCapacity);
          BufferCapacity);
   return *this;
   return *this;

+ 7 - 0
test/SemaCXX/rdar42746401.cpp

@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <int>
+class b;
+class c; // expected-note{{forward declaration}}
+
+::b<0> struct c::d // expected-error{{incomplete type}} expected-error{{cannot combine}} expected-error{{expected unqualified-id}}