DeclarationName Name = D->getDeclName();
void *Ptr = Name.getFETokenInfo<void>();
- if (Pos == iterator() || isDeclPtr(Ptr)) {
- // Simple case: insert at the end of the list (which is the
- // end of the stored vector).
+ if (!Ptr) {
AddDecl(D);
return;
}
+ if (isDeclPtr(Ptr)) {
+ // We only have a single declaration: insert before or after it,
+ // as appropriate.
+ if (Pos == iterator()) {
+ // Add the new declaration before the existing declaration.
+ NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr);
+ RemoveDecl(PrevD);
+ AddDecl(D);
+ AddDecl(PrevD);
+ } else {
+ // Add new declaration after the existing declaration.
+ AddDecl(D);
+ }
+
+ return;
+ }
+
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
II->setIsFromAST(false);
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+//PR9463
+int subfun(const char *text) {
+ const char *tmp = text;
+ return 0;
+}
+
+void fun(const char* text) {
+ int count = 0;
+ bool check = true;
+
+ if (check)
+ {
+ const char *end = text;
+
+ if (check)
+ {
+ do
+ {
+ if (check)
+ {
+ count = subfun(end);
+ goto end;
+ }
+
+ check = !check;
+ }
+ while (check);
+ }
+ // also works, after commenting following line of source code
+ int e = subfun(end);
+ }
+ end:
+ if (check)
+ ++count;
+}
+
+const char *text = "some text";
+
+int main() {
+ const char *ptr = text;
+
+ fun(ptr);
+
+ return 0;
+}