]> granicus.if.org Git - clang/commitdiff
ActOnCXXConditionDeclaration should take into account that
authorDouglas Gregor <dgregor@apple.com>
Tue, 5 Jul 2011 16:13:20 +0000 (16:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 5 Jul 2011 16:13:20 +0000 (16:13 +0000)
ActOnDeclarator can return NULL. Fixes PR10270, from Hans Wennborg!

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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/crashes.cpp

index ac51138b91d44fb1d9b124a8988e6ca882d960cc..368fd9259e3b9433e2e609c71ea0e39228ea8971 100644 (file)
@@ -8914,10 +8914,13 @@ DeclResult Sema::ActOnCXXConditionDeclaration(Scope *S, Declarator &D) {
          "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;
index c75b0401fed69af2460c84babb53613a8aa09ec9..b77248ef4104ed8d43abc1b9be12f671029c8205 100644 (file)
@@ -95,3 +95,12 @@ namespace PR9026 {
     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;
+  }
+}