diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java index d4dabaf1efa..552607efa69 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java @@ -10,11 +10,43 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import org.eclipse.cdt.core.parser.ParserLanguage; + /** * @author dsteffle */ public class AST2CSpecFailingTest extends AST2SpecBaseTest { + /** + [--Start Example(C 6.7.7-6): + typedef signed int t; + typedef int plain; + struct tag { + unsigned t:4; + const t:5; + plain r:5; + }; + t f(t (t)); + long t; + --End Example] + */ + public void test6_7_7s6() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef signed int t;\n"); //$NON-NLS-1$ + buffer.append("typedef int plain;\n"); //$NON-NLS-1$ + buffer.append("struct tag {\n"); //$NON-NLS-1$ + buffer.append("unsigned t:4;\n"); //$NON-NLS-1$ + buffer.append("const t:5;\n"); //$NON-NLS-1$ + buffer.append("plain r:5;\n"); //$NON-NLS-1$ + buffer.append("};\n"); //$NON-NLS-1$ + buffer.append("t f(t (t));\n"); //$NON-NLS-1$ + buffer.append("long t;\n"); //$NON-NLS-1$ + try { + parse(buffer.toString(), ParserLanguage.C, true, 0); + assertTrue(false); + } catch (Exception e) {} + } + /** [--Start Example(C 6.10.3.5-6): #define str(s) # s diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java index d7903556c44..29df85450d6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java @@ -1254,33 +1254,6 @@ public class AST2CSpecTest extends AST2SpecBaseTest { parseCandCPP(buffer.toString(), true, 0); } - /** - [--Start Example(C 6.7.7-6): - typedef signed int t; - typedef int plain; - struct tag { - unsigned t:4; - const t:5; - plain r:5; - }; - t f(t (t)); - long t; - --End Example] - */ - public void test6_7_7s6() throws Exception { - StringBuffer buffer = new StringBuffer(); - buffer.append("typedef signed int t;\n"); //$NON-NLS-1$ - buffer.append("typedef int plain;\n"); //$NON-NLS-1$ - buffer.append("struct tag {\n"); //$NON-NLS-1$ - buffer.append("unsigned t:4;\n"); //$NON-NLS-1$ - buffer.append("const t:5;\n"); //$NON-NLS-1$ - buffer.append("plain r:5;\n"); //$NON-NLS-1$ - buffer.append("};\n"); //$NON-NLS-1$ - buffer.append("t f(t (t));\n"); //$NON-NLS-1$ - buffer.append("long t;\n"); //$NON-NLS-1$ - parse(buffer.toString(), ParserLanguage.C, true, 0); - } - /** [--Start Example(C 6.7.7-7): typedef void fv(int), (*pfv)(int); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 2c8ae69892e..60c9af0adaa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -1076,9 +1076,9 @@ public class CVisitor { IASTNode parent = node.getParent(); if( parent instanceof IASTStandardFunctionDeclarator ){ parent = ((IASTDeclarator)parent).getParent(); - if ( parent instanceof IASTFunctionDefinition ) { + if ( parent instanceof IASTFunctionDefinition ) return ((IASTCompoundStatement)((IASTFunctionDefinition)parent).getBody()).getScope(); - } + return null; } } else if( node instanceof IASTEnumerator ){