]> granicus.if.org Git - clang/commitdiff
Fix infinite recursion for invalid declaration, by Dmitry Polukhin
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 12 Jan 2016 09:01:25 +0000 (09:01 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 12 Jan 2016 09:01:25 +0000 (09:01 +0000)
Fix for a case found by fuzzing PR23057 (comment #25 https://llvm.org/bugs/show_bug.cgi?id=23057#c25).
Differential Revision: http://reviews.llvm.org/D16065

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257461 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/SemaCXX/linkage-invalid-decl.cpp [new file with mode: 0644]

index 797e07b4b78b1d7dc4688f5ada58eb7102e6309e..427ca5efcd6930503e59df16e537950b62907e7b 100644 (file)
@@ -1184,7 +1184,7 @@ static LinkageInfo getLVForLocalDecl(const NamedDecl *D,
     return LinkageInfo::none();
 
   const Decl *OuterD = getOutermostFuncOrBlockContext(D);
-  if (!OuterD)
+  if (!OuterD || OuterD->isInvalidDecl())
     return LinkageInfo::none();
 
   LinkageInfo LV;
diff --git a/test/SemaCXX/linkage-invalid-decl.cpp b/test/SemaCXX/linkage-invalid-decl.cpp
new file mode 100644 (file)
index 0000000..0a991ba
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This invalid declaration used to call infinite recursion in linkage
+// calculation for enum as a function argument.
+inline foo(A)(enum E;
+// expected-error@-1 {{unknown type name 'foo'}}
+// expected-error@-2 {{ISO C++ forbids forward references to 'enum' types}}
+// expected-error@-3 {{expected ')'}}
+// expected-note@-4 {{to match this '('}}