Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-22 10:45:00 +0000
committerMarkus Schorn2008-04-22 10:45:00 +0000
commit4db6ea5e7885e59e22a1eda48f656172ce2e0b1f (patch)
treeed4f549db052a60677b1c88771076efec17c05a5 /core/org.eclipse.cdt.core
parent3aa200e4e02247677b79dd78d826fdc05c69f8de (diff)
downloadorg.eclipse.cdt-4db6ea5e7885e59e22a1eda48f656172ce2e0b1f.tar.gz
org.eclipse.cdt-4db6ea5e7885e59e22a1eda48f656172ce2e0b1f.tar.xz
org.eclipse.cdt-4db6ea5e7885e59e22a1eda48f656172ce2e0b1f.zip
Syntax error in template definition (template id ambiguity), bug 228118.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 08acf4cb9f..170da467b8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -171,6 +171,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private int templateCount = 0;
private int functionBodyCount= 0;
private int templateArgListCount= 0;
+ private int preventLogicalOperatorInTemplateID;
protected CPPASTTranslationUnit translationUnit;
@@ -332,6 +333,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
/**
+ * To disambiguate between logical expressions and template id's in some situations
+ * we forbid the usage of the logical operators '&&' or '||' within template ids.
+ * @throws EndOfFileException
+ * @since 5.0
+ */
+ protected final ITokenDuple nameWithoutLogicalOperatorInTemplateID() throws BacktrackException, EndOfFileException {
+ preventLogicalOperatorInTemplateID++;
+ try {
+ return name();
+ }
+ finally {
+ preventLogicalOperatorInTemplateID--;
+ }
+ }
+ /**
* Parse a name.
* name ::= ("::")? name2 ("::" name2)*
* name2 ::= IDENTIFER | template-id
@@ -415,7 +431,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
@Override
protected IASTExpression conditionalExpression() throws BacktrackException, EndOfFileException {
final IASTExpression expr= super.conditionalExpression();
- if (templateArgListCount > 0) {
+ if (templateArgListCount > 0 && preventLogicalOperatorInTemplateID > 0) {
// bug 104706, don't allow usage of logical operators in template argument lists.
if (expr instanceof IASTConditionalExpression) {
final ASTNode node = (ASTNode) expr;
@@ -1744,7 +1760,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected IASTName idExpression() throws EndOfFileException, BacktrackException {
IASTName name = null;
try {
- name = createName(name());
+ name = createName(nameWithoutLogicalOperatorInTemplateID());
} catch (BacktrackException bt) {
IToken mark = mark();
if (LT(1) == IToken.tCOLONCOLON || LT(1) == IToken.tIDENTIFIER) {

Back to the top