[cfe-commits] r134416 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/crashes.cpp
Douglas Gregor
dgregor at apple.com
Tue Jul 5 09:13:20 PDT 2011
Author: dgregor
Date: Tue Jul 5 11:13:20 2011
New Revision: 134416
URL: http://llvm.org/viewvc/llvm-project?rev=134416&view=rev
Log:
ActOnCXXConditionDeclaration should take into account that
ActOnDeclarator can return NULL. Fixes PR10270, from Hans Wennborg!
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/crashes.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=134416&r1=134415&r2=134416&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jul 5 11:13:20 2011
@@ -8914,10 +8914,13 @@
"Parser allowed 'typedef' as storage class of condition decl.");
Decl *Dcl = ActOnDeclarator(S, D);
+ if (!Dcl)
+ return true;
+
if (isa<FunctionDecl>(Dcl)) { // The declarator shall not specify a function.
Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type)
<< D.getSourceRange();
- return DeclResult();
+ return true;
}
return Dcl;
Modified: cfe/trunk/test/SemaCXX/crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/crashes.cpp?rev=134416&r1=134415&r2=134416&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/crashes.cpp (original)
+++ cfe/trunk/test/SemaCXX/crashes.cpp Tue Jul 5 11:13:20 2011
@@ -95,3 +95,12 @@
Write(x);
}
}
+
+namespace PR10270 {
+ template<typename T> class C;
+ template<typename T> void f() {
+ if (C<T> == 1) // expected-error{{expected unqualified-id}} \
+ // expected-error{{invalid '==' at end of declaration}}
+ return;
+ }
+}
More information about the cfe-commits
mailing list