summaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-31 14:50:13 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-31 14:50:13 +0000
commit2d507e6702aca4771ce5497dcac7df12a9ce3eae (patch)
tree8f71104ce2a18a26b24bccc9043f80465c769a6b /libcpp/directives.c
parente26011c9088dcacbd3e9001887eabe8e7e54b205 (diff)
downloadgcc-2d507e6702aca4771ce5497dcac7df12a9ce3eae.tar.gz
gcc/testsuite
PR preprocessor/30786: * gcc.dg/cpp/pr30786.c: New file. libcpp PR preprocessor/30786: * macro.c (builtin_macro): Return result of _cpp_do__Pragma. * directives.c (_cpp_do__Pragma): Return error status. * internal.h (_cpp_do__Pragma): Update. * directives.c (get__Pragma_string): Back up if EOF seen. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129800 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 7f7216265c9..e8516e0f39c 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1467,15 +1467,24 @@ static const cpp_token *
get__Pragma_string (cpp_reader *pfile)
{
const cpp_token *string;
+ const cpp_token *paren;
- if (get_token_no_padding (pfile)->type != CPP_OPEN_PAREN)
+ paren = get_token_no_padding (pfile);
+ if (paren->type == CPP_EOF)
+ _cpp_backup_tokens (pfile, 1);
+ if (paren->type != CPP_OPEN_PAREN)
return NULL;
string = get_token_no_padding (pfile);
+ if (string->type == CPP_EOF)
+ _cpp_backup_tokens (pfile, 1);
if (string->type != CPP_STRING && string->type != CPP_WSTRING)
return NULL;
- if (get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
+ paren = get_token_no_padding (pfile);
+ if (paren->type == CPP_EOF)
+ _cpp_backup_tokens (pfile, 1);
+ if (paren->type != CPP_CLOSE_PAREN)
return NULL;
return string;
@@ -1595,18 +1604,21 @@ destringize_and_run (cpp_reader *pfile, const cpp_string *in)
_cpp_push_token_context (pfile, NULL, toks, count);
}
-/* Handle the _Pragma operator. */
-void
+/* Handle the _Pragma operator. Return 0 on error, 1 if ok. */
+int
_cpp_do__Pragma (cpp_reader *pfile)
{
const cpp_token *string = get__Pragma_string (pfile);
pfile->directive_result.type = CPP_PADDING;
if (string)
- destringize_and_run (pfile, &string->val.str);
- else
- cpp_error (pfile, CPP_DL_ERROR,
- "_Pragma takes a parenthesized string literal");
+ {
+ destringize_and_run (pfile, &string->val.str);
+ return 1;
+ }
+ cpp_error (pfile, CPP_DL_ERROR,
+ "_Pragma takes a parenthesized string literal");
+ return 0;
}
/* Handle #ifdef. */