From 507d844b5e88a78f8b773f0aa3a90bca92bbd854 Mon Sep 17 00:00:00 2001
From: Markus Schorn <markus.schorn@windriver.com>
Date: Fri, 13 Aug 2010 10:58:14 +0000
Subject: [PATCH] Bug 305978: [C++ 0x] Deleted functions, additional testcase
 and a fix.

---
 .../eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java  | 7 +++++++
 .../core/dom/parser/cpp/semantics/CPPVisitor.java         | 8 ++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 216550c1920..e8db2ea6d50 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -8711,6 +8711,13 @@ public class AST2CPPTests extends AST2BaseTest {
 		assertTrue(fb.isDeleted());
 	}
 	
+	//	const int b=12;
+	//	void f(int a= b) = delete ;
+	public void testDefaultedAndDeletedFunctions_305978b() throws Exception {
+		String code= getAboveComment();
+		parseAndCheckBindings(code);
+	}
+	
 	//	namespace ns {
 	//		struct S {};
 	//	}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index 206e91eb39e..cda9d215924 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -896,8 +896,12 @@ public class CPPVisitor extends ASTQueries {
 						ASTNodeProperty prop = parent.getPropertyInParent();
 						if (prop == IASTSimpleDeclaration.DECLARATOR)
 						    return dtor.getFunctionScope();
-						else if (prop == IASTFunctionDefinition.DECLARATOR)
-						    return ((IASTCompoundStatement) ((IASTFunctionDefinition) parent.getParent()).getBody()).getScope();
+						else if (prop == IASTFunctionDefinition.DECLARATOR) {
+						    final IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition) parent.getParent()).getBody();
+						    if (body != null)
+						    	return body.getScope();
+						    return dtor.getFunctionScope();
+						}
 					}
 			    } else if (parent instanceof ICPPASTTemplateDeclaration) {
 			    	return CPPTemplates.getContainingScope(node);