From c587164422194d55acf772f4920bcdeefe310743 Mon Sep 17 00:00:00 2001 From: Erik Pilkington Date: Mon, 10 Sep 2018 21:54:04 +0000 Subject: [PATCH] [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 llvm-svn: 341869 --- clang/lib/AST/NestedNameSpecifier.cpp | 1 + clang/test/SemaCXX/rdar42746401.cpp | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 clang/test/SemaCXX/rdar42746401.cpp diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp index a514d57..df23972 100644 --- a/clang/lib/AST/NestedNameSpecifier.cpp +++ b/clang/lib/AST/NestedNameSpecifier.cpp @@ -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/clang/test/SemaCXX/rdar42746401.cpp b/clang/test/SemaCXX/rdar42746401.cpp new file mode 100644 index 0000000..ff9dff4 --- /dev/null +++ b/clang/test/SemaCXX/rdar42746401.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +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}} -- 2.7.4