diff --git a/mlir/lib/Parser/LocationParser.cpp b/mlir/lib/Parser/LocationParser.cpp --- a/mlir/lib/Parser/LocationParser.cpp +++ b/mlir/lib/Parser/LocationParser.cpp @@ -126,17 +126,11 @@ // Check for a child location. if (consumeIf(Token::l_paren)) { - auto childSourceLoc = getToken().getLoc(); - // Parse the child location. LocationAttr childLoc; if (parseLocationInstance(childLoc)) return failure(); - // The child must not be another NameLoc. - if (childLoc.isa()) - return emitError(childSourceLoc, - "child of NameLoc cannot be another NameLoc"); loc = NameLoc::get(StringAttr::get(ctx, str), childLoc); // Parse the closing ')'. diff --git a/mlir/test/IR/invalid-locations.mlir b/mlir/test/IR/invalid-locations.mlir --- a/mlir/test/IR/invalid-locations.mlir +++ b/mlir/test/IR/invalid-locations.mlir @@ -30,13 +30,6 @@ // ----- -func @location_name_child_is_name() { -^bb: - return loc("foo"("foo")) // expected-error {{child of NameLoc cannot be another NameLoc}} -} - -// ----- - func @location_callsite_missing_l_paren() { ^bb: return loc(callsite unknown // expected-error {{expected '(' in callsite location}} diff --git a/mlir/test/IR/locations.mlir b/mlir/test/IR/locations.mlir --- a/mlir/test/IR/locations.mlir +++ b/mlir/test/IR/locations.mlir @@ -69,5 +69,11 @@ "foo.yield"(%1) : (i32) -> () }) : () -> () +// CHECK-LABEL: func @location_name_child_is_name +func @location_name_child_is_name() { + // CHECK: "foo"("foo") + return loc("foo"("foo")) +} + // CHECK-ALIAS: #[[LOC]] = loc("out_of_line_location") #loc = loc("out_of_line_location")