OpaquePtr: Reject 'ptr*' again when parsing textual IR
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Jun 2021 18:53:27 +0000 (11:53 -0700)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Jun 2021 22:18:44 +0000 (15:18 -0700)
Bring back the testcase dropped in
1e6303e60ca5af4fbe7ca728572fd65666a98271 and get it passing by checking
explicitly for `ptr*` in LLParser. Uses `Type::isOpaquePointerTy()` from
ad4bb8280952c2cacf497e30560ee94c119b36e0.

Differential Revision: https://reviews.llvm.org/D104938

llvm/lib/AsmParser/LLParser.cpp
llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll [new file with mode: 0644]
llvm/test/Assembler/invalid-opaque-ptr.ll [new file with mode: 0644]

index bcdf51c..c4fa35f 100644 (file)
@@ -2597,6 +2597,8 @@ bool LLParser::parseType(Type *&Result, const Twine &Msg, bool AllowVoid) {
         return tokError("basic block pointers are invalid");
       if (Result->isVoidTy())
         return tokError("pointers to void are invalid - use i8* instead");
+      if (Result->isOpaquePointerTy())
+        return tokError("ptr* is invalid - use ptr instead");
       if (!PointerType::isValidElementType(Result))
         return tokError("pointer to this type is invalid");
       Result = PointerType::getUnqual(Result);
diff --git a/llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll b/llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll
new file mode 100644 (file)
index 0000000..f3d7722
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: ptr* is invalid - use ptr instead
+define void @f(ptr addrspace(3) %a) {
+    %b = bitcast ptr addrspace(3) %a to ptr addrspace(3)*
+    ret void
+}
diff --git a/llvm/test/Assembler/invalid-opaque-ptr.ll b/llvm/test/Assembler/invalid-opaque-ptr.ll
new file mode 100644 (file)
index 0000000..6e8340b
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: ptr* is invalid - use ptr instead
+define void @f(ptr %a) {
+    %b = bitcast ptr %a to ptr*
+    ret void
+}