From df6ebf09e9750502f50ce8fec2901baea3fad3e1 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Mon, 6 Jun 2016 09:26:48 -0400 Subject: [PATCH] Bug 495423 - Indexer produces a erroneous "Symbol could not be found" Added catch all condition to ConditionalExpression type evaluation where both positive and negative types are the same. Change-Id: I990b502dfce8ef71c753ac188e072de312b7ea9f Signed-off-by: Joseph Henry --- .../eclipse/cdt/core/parser/tests/ast2/AST2Tests.java | 11 +++++++++++ .../core/dom/parser/c/CASTConditionalExpression.java | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 26c7d00bfac..98f25d9311f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -7554,6 +7554,17 @@ public class AST2Tests extends AST2TestBase { parseAndCheckBindings(getAboveComment(), C); } + // struct MyStruct { + // char* str; + // }; + // void foo() { + // const struct MyStruct a, b; + // (0 ? a : b).str; + // } + public void testCVQualifiedTypesInConversionOperator_495423() throws Exception { + parseAndCheckBindings(getAboveComment(), C); + } + // _Alignas(8) int x; // _Alignas(int) char y; // _Alignas(16) struct { int x; int y; }; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java index b76ceb58be4..410dd600bb7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java @@ -172,6 +172,10 @@ public class CASTConditionalExpression extends ASTNode implements private IType computeResultType(IASTExpression positiveExpression, IASTExpression negativeExpression, IType positiveType, IType negativeType) { + // Unwrap any top-level cv-qualifiers. + positiveType = CVisitor.unwrapCV(positiveType); + negativeType = CVisitor.unwrapCV(negativeType); + // [6.5.15] p5: If both the second and third operands have arithmetic type, the result type // that would be determined by the usual arithmetic conversions, were they applied to those // two operands, is the type of the result. If both operands have void type, the result has @@ -222,7 +226,7 @@ public class CASTConditionalExpression extends ASTNode implements return new CPointerType( ExpressionTypes.restoreCV(resultPointee, positivePointeeCV, negativePointeeCV), 0); } - + return null; }