mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 10:16:36 +01:00
Small cleanup of gen/pragma.cpp
- Added locations to many error messages - Fixed indentation
This commit is contained in:
102
gen/pragma.cpp
102
gen/pragma.cpp
@@ -71,7 +71,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
Expressions *args = decl->args;
|
||||
Expression *expr = (args && args->dim > 0) ? (*args)[0]->semantic(sc) : 0;
|
||||
|
||||
// pragma(intrinsic, "string") { funcdecl(s) }
|
||||
// pragma(LDC_intrinsic, "string") { funcdecl(s) }
|
||||
if (matchPragma(ident, Id::LDC_intrinsic, Id::intrinsic))
|
||||
{
|
||||
if (!args || args->dim != 1 || !parseStringExp(expr, arg1str))
|
||||
@@ -117,7 +117,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMintrinsic;
|
||||
}
|
||||
|
||||
// pragma(ctor [, priority]) { funcdecl(s) }
|
||||
// pragma(LDC_global_crt_ctor [, priority]) { funcdecl(s) }
|
||||
else if (ident == Id::LDC_global_crt_ctor || ident == Id::LDC_global_crt_dtor)
|
||||
{
|
||||
dinteger_t priority;
|
||||
@@ -142,7 +142,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return ident == Id::LDC_global_crt_ctor ? LLVMglobal_crt_ctor : LLVMglobal_crt_dtor;
|
||||
}
|
||||
|
||||
// pragma(notypeinfo) { typedecl(s) }
|
||||
// pragma(LDC_no_typeinfo) { typedecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_no_typeinfo, Id::no_typeinfo))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -153,7 +153,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMno_typeinfo;
|
||||
}
|
||||
|
||||
// pragma(nomoduleinfo) ;
|
||||
// pragma(LDC_no_moduleinfo) ;
|
||||
else if (matchPragma(ident, Id::LDC_no_moduleinfo, Id::no_moduleinfo))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -164,7 +164,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMno_moduleinfo;
|
||||
}
|
||||
|
||||
// pragma(alloca) { funcdecl(s) }
|
||||
// pragma(LDC_alloca) { funcdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_alloca, Id::Alloca))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -175,7 +175,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMalloca;
|
||||
}
|
||||
|
||||
// pragma(va_start) { templdecl(s) }
|
||||
// pragma(LDC_va_start) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_va_start, Id::vastart))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -186,7 +186,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMva_start;
|
||||
}
|
||||
|
||||
// pragma(va_copy) { funcdecl(s) }
|
||||
// pragma(LDC_va_copy) { funcdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_va_copy, Id::vacopy))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -197,7 +197,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMva_copy;
|
||||
}
|
||||
|
||||
// pragma(va_end) { funcdecl(s) }
|
||||
// pragma(LDC_va_end) { funcdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_va_end, Id::vaend))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -208,7 +208,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMva_end;
|
||||
}
|
||||
|
||||
// pragma(va_arg) { templdecl(s) }
|
||||
// pragma(LDC_va_arg) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_va_arg, Id::vaarg))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -219,7 +219,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMva_arg;
|
||||
}
|
||||
|
||||
// pragma(fence) { funcdecl(s) }
|
||||
// pragma(LDC_fence) { funcdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_fence, Id::fence))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -230,7 +230,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMfence;
|
||||
}
|
||||
|
||||
// pragma(atomic_load) { templdecl(s) }
|
||||
// pragma(LDC_atomic_load) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_atomic_load, Id::atomic_load))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -241,7 +241,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMatomic_load;
|
||||
}
|
||||
|
||||
// pragma(atomic_store) { templdecl(s) }
|
||||
// pragma(LDC_atomic_store) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_atomic_store, Id::atomic_store))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -252,7 +252,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMatomic_store;
|
||||
}
|
||||
|
||||
// pragma(atomic_cmp_xchg) { templdecl(s) }
|
||||
// pragma(LDC_atomic_cmp_xchg) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_atomic_cmp_xchg, Id::atomic_cmp_xchg))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -263,7 +263,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMatomic_cmp_xchg;
|
||||
}
|
||||
|
||||
// pragma(atomic_rmw, "string") { templdecl(s) }
|
||||
// pragma(LDC_atomic_rmw, "string") { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_atomic_rmw, Id::atomic_rmw))
|
||||
{
|
||||
if (!args || args->dim != 1 || !parseStringExp(expr, arg1str))
|
||||
@@ -309,7 +309,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMignore;
|
||||
}
|
||||
|
||||
// pragma(llvm_inline_asm) { templdecl(s) }
|
||||
// pragma(LDC_inline_asm) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_inline_asm, Id::llvm_inline_asm))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -320,7 +320,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMinline_asm;
|
||||
}
|
||||
|
||||
// pragma(llvm_inline_ir) { templdecl(s) }
|
||||
// pragma(LDC_inline_ir) { templdecl(s) }
|
||||
else if (matchPragma(ident, Id::LDC_inline_ir, Id::llvm_inline_ir))
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
@@ -343,7 +343,7 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
if (s->llvmInternal)
|
||||
{
|
||||
error("multiple LDC specific pragmas not allowed not affect the same "
|
||||
"declaration ('%s' at '%s')", s->toChars(), s->loc.toChars());
|
||||
"declaration ('%s' at '%s')", s->toChars(), s->loc.toChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
@@ -366,10 +366,12 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
}
|
||||
else
|
||||
{
|
||||
error("only allowed on function declarations");
|
||||
error(s->loc, "the '%s' pragma is only allowed on function or template declarations",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
|
||||
case LLVMglobal_crt_ctor:
|
||||
case LLVMglobal_crt_dtor:
|
||||
if (FuncDeclaration* fd = s->isFuncDeclaration())
|
||||
@@ -384,7 +386,7 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
fd->isThis()
|
||||
#endif
|
||||
&& !fd->isStatic())) {
|
||||
error(fd->loc, "the '%s' pragma is only allowed on void functions which take no arguments",
|
||||
error(s->loc, "the '%s' pragma is only allowed on void functions which take no arguments",
|
||||
ident->toChars());
|
||||
fd->llvmInternal = LLVMnone;
|
||||
break;
|
||||
@@ -409,8 +411,8 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
@@ -424,28 +426,28 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
{
|
||||
if (td->parameters->dim != 1)
|
||||
{
|
||||
error("the '%s' pragma template must have exactly one template parameter",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must have exactly one template parameter",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
else if (!td->onemember)
|
||||
{
|
||||
error("the '%s' pragma template must have exactly one member",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must have exactly one member",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
else if (td->overnext || td->overroot)
|
||||
{
|
||||
error("the '%s' pragma template must not be overloaded",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must not be overloaded",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
td->llvmInternal = llvm_internal;
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
@@ -463,8 +465,8 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma is only allowed on function declarations",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma is only allowed on function declarations",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
@@ -480,8 +482,8 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma must only be used on function declarations "
|
||||
"of type 'void* function(uint nbytes)'", ident->toChars());
|
||||
error(s->loc, "the '%s' pragma must only be used on function declarations "
|
||||
"of type 'void* function(uint nbytes)'", ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
@@ -491,22 +493,22 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
{
|
||||
if (td->parameters->dim > 1)
|
||||
{
|
||||
error("the '%s' pragma template must have exactly zero or one "
|
||||
"template parameters", ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must have exactly zero or one "
|
||||
"template parameters", ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
else if (!td->onemember)
|
||||
{
|
||||
error("the '%s' pragma template must have exactly one member",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must have exactly one member",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
td->llvmInternal = llvm_internal;
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
@@ -517,15 +519,15 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
Dsymbol* member = td->onemember;
|
||||
if (!member)
|
||||
{
|
||||
error("the '%s' pragma template must have exactly one member",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must have exactly one member",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
FuncDeclaration* fun = member->isFuncDeclaration();
|
||||
if (!fun)
|
||||
{
|
||||
error("the '%s' pragma template's member must be a function declaration",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template's member must be a function declaration",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
@@ -542,8 +544,8 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
|
||||
if(!valid_params)
|
||||
{
|
||||
error("the '%s' pragma template must have exactly three parameters: "
|
||||
"a string, a type and a type tuple", ident->toChars());
|
||||
error(s->loc, "the '%s' pragma template must have exactly three parameters: "
|
||||
"a string, a type and a type tuple", ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
@@ -551,15 +553,15 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
error(s->loc, "the '%s' pragma is only allowed on template declarations",
|
||||
ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
warning(Loc(),
|
||||
"the LDC specific pragma '%s' is not yet implemented, ignoring",
|
||||
ident->toChars());
|
||||
warning(s->loc,
|
||||
"the LDC specific pragma '%s' is not yet implemented, ignoring",
|
||||
ident->toChars());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user