diff --git a/gcc/gcc/c-parse.in b/gcc/gcc/c-parse.in index 6757c4d464..f8cac19647 100644 --- a/gcc/gcc/c-parse.in +++ b/gcc/gcc/c-parse.in @@ -205,6 +205,8 @@ end ifc %type parmlist_or_identifiers parmlist_or_identifiers_1 %type identifiers_or_typenames +%type extension + %type setspecs %type lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label @@ -247,6 +249,15 @@ static tree declspec_stack; /* 1 if we explained undeclared var errors. */ static int undeclared_variable_notice; +/* For __extension__, save/restore the warning flags which are + controlled by __extension__. */ +#define SAVE_WARN_FLAGS() (pedantic | (warn_pointer_arith << 1)) +#define RESTORE_WARN_FLAGS(val) \ + do { \ + pedantic = val & 1; \ + warn_pointer_arith = (val >> 1) & 1; \ + } while (0) + ifobjc /* Objective-C specific information */ @@ -307,7 +318,7 @@ end ifobjc else error ("argument of `asm' is not a constant string"); } | extension extdef - { pedantic = $1; } + { RESTORE_WARN_FLAGS ($1); } ; datadef: @@ -448,7 +459,7 @@ unary_expr: /* __extension__ turns off -pedantic for following primary. */ | extension cast_expr %prec UNARY { $$ = $2; - pedantic = $1; } + RESTORE_WARN_FLAGS ($1); } | unop cast_expr %prec UNARY { $$ = build_unary_op ($1, $2, 0); overflow_warning ($$); } @@ -1015,7 +1026,7 @@ decl: | declmods ';' { pedwarn ("empty declaration"); } | extension decl - { pedantic = $1; } + { RESTORE_WARN_FLAGS ($1); } ; /* Declspecs which contain at least one type specifier or typedef name. @@ -1614,7 +1625,7 @@ component_decl: { $$ = NULL_TREE; } | extension component_decl { $$ = $2; - pedantic = $1; } + RESTORE_WARN_FLAGS ($1); } ; components: @@ -2426,8 +2437,9 @@ identifiers_or_typenames: extension: EXTENSION - { $$ = pedantic; - pedantic = 0; } + { $$ = SAVE_WARN_FLAGS(); + pedantic = 0; + warn_pointer_arith = 0; } ; ifobjc diff --git a/gcc/gcc/extend.texi b/gcc/gcc/extend.texi index f969f65b18..6f95a95566 100644 --- a/gcc/gcc/extend.texi +++ b/gcc/gcc/extend.texi @@ -2928,7 +2928,8 @@ macros to replace them with the customary keywords. It looks like this: @end example @findex __extension__ -@samp{-pedantic} causes warnings for many GNU C extensions. You can +@samp{-pedantic} and other options cause warnings for many +GNU C extensions. You can prevent such warnings within one expression by writing @code{__extension__} before the expression. @code{__extension__} has no effect aside from this.