2929#include "parse.h"
3030#include "template.h"
3131#include "utf.h"
32+ #if IN_LLVM
33+ #include "../gen/pragma.h"
34+ #endif
3235
3336
3437/********************************* AttribDeclaration ****************************/
@@ -820,6 +823,11 @@ void PragmaDeclaration::semantic(Scope *sc)
820823{
821824 // Should be merged with PragmaStatement
822825
826+ #if IN_LLVM
827+ Pragma llvm_internal = LLVMnone ;
828+ std ::string arg1str ;
829+ #endif
830+
823831 //printf("\tPragmaDeclaration::semantic '%s'\n",toChars());
824832 if (ident == Id ::msg )
825833 {
@@ -997,6 +1005,12 @@ void PragmaDeclaration::semantic(Scope *sc)
9971005 }
9981006#endif
9991007 }
1008+ #if IN_LLVM
1009+ else if ((llvm_internal = DtoGetPragma (sc , this , arg1str )) != LLVMnone )
1010+ {
1011+ // nothing to do anymore
1012+ }
1013+ #endif
10001014 else if (global .params .ignoreUnsupportedPragmas )
10011015 {
10021016 if (global .params .verbose )
@@ -1009,7 +1023,11 @@ void PragmaDeclaration::semantic(Scope *sc)
10091023 for (size_t i = 0 ; i < args -> dim ; i ++ )
10101024 {
10111025 Expression * e = (* args )[i ];
1012-
1026+ #if IN_LLVM
1027+ // ignore errors in ignored pragmas.
1028+ global .gag ++ ;
1029+ unsigned errors_save = global .errors ;
1030+ #endif
10131031 sc = sc -> startCTFE ();
10141032 e = e -> semantic (sc );
10151033 e = resolveProperties (sc , e );
@@ -1021,13 +1039,17 @@ void PragmaDeclaration::semantic(Scope *sc)
10211039 else
10221040 fprintf (global .stdmsg , "," );
10231041 fprintf (global .stdmsg , "%s" , e -> toChars ());
1042+ #if IN_LLVM
1043+ // restore error state.
1044+ global .gag -- ;
1045+ global .errors = errors_save ;
1046+ #endif
10241047 }
10251048 if (args -> dim )
10261049 fprintf (global .stdmsg , ")" );
10271050 }
10281051 fprintf (global .stdmsg , "\n" );
10291052 }
1030- goto Lnodecl ;
10311053 }
10321054 else
10331055 error ("unrecognized pragma(%s)" , ident -> toChars ());
@@ -1055,6 +1077,13 @@ void PragmaDeclaration::semantic(Scope *sc)
10551077 error ("can only apply to a single declaration" );
10561078 }
10571079 }
1080+ #if IN_LLVM
1081+ else
1082+ {
1083+ DtoCheckPragma (this , s , llvm_internal , arg1str );
1084+ }
1085+ #endif
1086+
10581087 }
10591088 }
10601089 return ;
0 commit comments