Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-01-19 22:02:31 -0500
committerNathan Ridge2017-02-02 23:51:00 -0500
commit4e0e816a6a0ae57e5abf41b1f1dcc500da3852a8 (patch)
treedc53572cba43744d6b5f42da8417fcc55e824c5b
parentcbe8e1f3cfb2f5782eea075fc26d993b3139dc8c (diff)
downloadorg.eclipse.cdt-4e0e816a6a0ae57e5abf41b1f1dcc500da3852a8.tar.gz
org.eclipse.cdt-4e0e816a6a0ae57e5abf41b1f1dcc500da3852a8.tar.xz
org.eclipse.cdt-4e0e816a6a0ae57e5abf41b1f1dcc500da3852a8.zip
Bug 510665 - User-defined literal operator in namespace
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java3
2 files changed, 15 insertions, 1 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 5c61f54be2..bb49c8989c 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
@@ -11868,6 +11868,19 @@ public class AST2CPPTests extends AST2TestBase {
assertTrue(test.getType() instanceof IProblemType); // resolution is ambiguous
}
+ // namespace N {
+ // class Color {};
+ // Color operator"" _color(const char*, unsigned long);
+ // }
+ // void setColor(N::Color);
+ // int main() {
+ // using namespace N;
+ // setColor("#ffffff"_color); // ERROR
+ // }
+ public void testUserDefinedLiteralInNamespace_510665() throws Exception {
+ parseAndCheckBindings();
+ }
+
// double waldo1 = 02.968;
// double waldo2 = 09.268;
// double waldo3 = 02e2;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index f3f7cfc02f..99e20dcb7a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -3186,7 +3186,8 @@ public class CPPSemantics {
*
*/
int kind = exp.getKind();
- IBinding[] bindings = findBindings(exp.getTranslationUnit().getScope(), ((CPPASTLiteralExpression) exp).getOperatorName(), false);
+ IScope lookupScope = CPPVisitor.getContainingScope(exp);
+ IBinding[] bindings = findBindings(lookupScope, ((CPPASTLiteralExpression) exp).getOperatorName(), false);
ICPPFunction[] funcs = new ICPPFunction[bindings.length];
ICPPFunctionTemplate[] tplFunctions = new ICPPFunctionTemplate[bindings.length];
LookupData data = new LookupData(((CPPASTLiteralExpression) exp).getOperatorName(), null, exp);

Back to the top