]> granicus.if.org Git - clang/commitdiff
[AST] Fix a crash on invalid.
authorErik Pilkington <erik.pilkington@gmail.com>
Mon, 10 Sep 2018 21:54:04 +0000 (21:54 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Mon, 10 Sep 2018 21:54:04 +0000 (21:54 +0000)
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

lib/AST/NestedNameSpecifier.cpp
test/SemaCXX/rdar42746401.cpp [new file with mode: 0644]

index a514d57b6b6bc3e867b7dc824d0e54baffb850d4..df23972af2db5b3ca40e5f41f4ac9286155f61fa 100644 (file)
@@ -547,6 +547,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) {
   }
 
   // Deep copy.
+  BufferSize = 0;
   Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
          BufferCapacity);
   return *this;
diff --git a/test/SemaCXX/rdar42746401.cpp b/test/SemaCXX/rdar42746401.cpp
new file mode 100644 (file)
index 0000000..ff9dff4
--- /dev/null
@@ -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}}