aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2007-10-31 14:50:13 +0000
committerTom Tromey <tromey@gcc.gnu.org>2007-10-31 14:50:13 +0000
commit5b9a40df4e3e9c4253239bbc32578eda155577ea (patch)
tree8f71104ce2a18a26b24bccc9043f80465c769a6b /libcpp
parent69d10e15fb001b34aedfe14a7af7c9e1fafea6a0 (diff)
downloadgcc-5b9a40df4e3e9c4253239bbc32578eda155577ea.zip
gcc-5b9a40df4e3e9c4253239bbc32578eda155577ea.tar.gz
gcc-5b9a40df4e3e9c4253239bbc32578eda155577ea.tar.bz2
re PR preprocessor/30786 (ICE on _Pragma at end of file)
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. From-SVN: r129800
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog8
-rw-r--r--libcpp/directives.c28
-rw-r--r--libcpp/internal.h2
-rw-r--r--libcpp/macro.c3
4 files changed, 30 insertions, 11 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 08e5f86..beed407 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-31 Tom Tromey <tromey@redhat.com>
+
+ 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.
+
2007-09-06 Tom Tromey <tromey@redhat.com>
* internal.h (struct cpp_reader) <invocation_location>: New
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 7f72162..e8516e0 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. */
diff --git a/libcpp/internal.h b/libcpp/internal.h
index 59332df..830f07b 100644
--- a/libcpp/internal.h
+++ b/libcpp/internal.h
@@ -576,7 +576,7 @@ extern int _cpp_handle_directive (cpp_reader *, int);
extern void _cpp_define_builtin (cpp_reader *, const char *);
extern char ** _cpp_save_pragma_names (cpp_reader *);
extern void _cpp_restore_pragma_names (cpp_reader *, char **);
-extern void _cpp_do__Pragma (cpp_reader *);
+extern int _cpp_do__Pragma (cpp_reader *);
extern void _cpp_init_directives (cpp_reader *);
extern void _cpp_init_internal_pragmas (cpp_reader *);
extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
diff --git a/libcpp/macro.c b/libcpp/macro.c
index e80815b..50bb34d 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -300,8 +300,7 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node)
if (pfile->state.in_directive)
return 0;
- _cpp_do__Pragma (pfile);
- return 1;
+ return _cpp_do__Pragma (pfile);
}
buf = _cpp_builtin_macro_text (pfile, node);