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