r257461 - Fix infinite recursion for invalid declaration, by Dmitry Polukhin
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 12 01:01:25 PST 2016
Author: abataev
Date: Tue Jan 12 03:01:25 2016
New Revision: 257461
URL: http://llvm.org/viewvc/llvm-project?rev=257461&view=rev
Log:
Fix infinite recursion for invalid declaration, by Dmitry Polukhin
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
Added:
cfe/trunk/test/SemaCXX/linkage-invalid-decl.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=257461&r1=257460&r2=257461&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Jan 12 03:01:25 2016
@@ -1184,7 +1184,7 @@ static LinkageInfo getLVForLocalDecl(con
return LinkageInfo::none();
const Decl *OuterD = getOutermostFuncOrBlockContext(D);
- if (!OuterD)
+ if (!OuterD || OuterD->isInvalidDecl())
return LinkageInfo::none();
LinkageInfo LV;
Added: cfe/trunk/test/SemaCXX/linkage-invalid-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage-invalid-decl.cpp?rev=257461&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage-invalid-decl.cpp (added)
+++ cfe/trunk/test/SemaCXX/linkage-invalid-decl.cpp Tue Jan 12 03:01:25 2016
@@ -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 at -1 {{unknown type name 'foo'}}
+// expected-error at -2 {{ISO C++ forbids forward references to 'enum' types}}
+// expected-error at -3 {{expected ')'}}
+// expected-note at -4 {{to match this '('}}
More information about the cfe-commits
mailing list