Skip to content

Commit 1b03cc8

Browse files
author
jason
committed
libcpp/
* lex.c (lex_string): Add -Wc++11-compat warning. * include/cpplib.h: Add CPP_W_CXX11_COMPAT. (struct cpp_options): Add cpp_warn_cxx11_compat. * init.c (cpp_create_reader): Initialize it. gcc/c-family/ * c.opt (Wc++0x-compat): Set it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222961 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent f03df32 commit 1b03cc8

File tree

7 files changed

+28
-2
lines changed

7 files changed

+28
-2
lines changed

gcc/c-family/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2015-05-08 Jason Merrill <[email protected]>
2+
3+
* c.opt (Wc++0x-compat): Also set cpp_warn_cxx11_compat.
4+
15
2015-05-08 Marek Polacek <[email protected]>
26

37
PR c/64918

gcc/c-family/c.opt

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ C ObjC Var(warn_cxx_compat) CPP(warn_cxx_operator_names) CppReason(CPP_W_CXX_OPE
312312
Warn about C constructs that are not in the common subset of C and C++
313313

314314
Wc++0x-compat
315-
C++ ObjC++ Var(warn_cxx0x_compat) Warning LangEnabledBy(C++ ObjC++,Wall)
315+
C++ ObjC++ Var(warn_cxx0x_compat) Warning LangEnabledBy(C++ ObjC++,Wall) Init(0) CPP(cpp_warn_cxx11_compat) CppReason(CPP_W_CXX11_COMPAT)
316316
Deprecated in favor of -Wc++11-compat
317317

318318
Wc++11-compat
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// { dg-options "-Wall" }
2+
3+
#define FOO "foo"
4+
const char *p = "bar"FOO; // { dg-warning "macro" }

libcpp/ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2015-05-08 Jason Merrill <[email protected]>
2+
3+
* include/cpplib.h: Add CPP_W_CXX11_COMPAT.
4+
(struct cpp_options): Add cpp_warn_cxx11_compat.
5+
* init.c (cpp_create_reader): Initialize it.
6+
* lex.c (lex_string): Add -Wc++11-compat warning.
7+
18
2015-05-05 David Malcolm <[email protected]>
29

310
* pch.c (cpp_valid_state): Fix indentation so that it reflects the

libcpp/include/cpplib.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ struct cpp_options
484484
/* True if warn about differences between C90 and C99. */
485485
signed char cpp_warn_c90_c99_compat;
486486

487+
/* True if warn about differences between C++98 and C++11. */
488+
bool cpp_warn_cxx11_compat;
489+
487490
/* Dependency generation. */
488491
struct
489492
{
@@ -960,7 +963,8 @@ enum {
960963
CPP_W_LITERAL_SUFFIX,
961964
CPP_W_DATE_TIME,
962965
CPP_W_PEDANTIC,
963-
CPP_W_C90_C99_COMPAT
966+
CPP_W_C90_C99_COMPAT,
967+
CPP_W_CXX11_COMPAT
964968
};
965969

966970
/* Output a diagnostic of some kind. */

libcpp/init.c

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table,
180180
CPP_OPTION (pfile, warn_trigraphs) = 2;
181181
CPP_OPTION (pfile, warn_endif_labels) = 1;
182182
CPP_OPTION (pfile, cpp_warn_c90_c99_compat) = -1;
183+
CPP_OPTION (pfile, cpp_warn_cxx11_compat) = 0;
183184
CPP_OPTION (pfile, cpp_warn_deprecated) = 1;
184185
CPP_OPTION (pfile, cpp_warn_long_long) = 0;
185186
CPP_OPTION (pfile, dollars_in_ident) = 1;

libcpp/lex.c

+6
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,12 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
19051905
++cur;
19061906
}
19071907
}
1908+
else if (CPP_OPTION (pfile, cpp_warn_cxx11_compat)
1909+
&& is_macro (pfile, cur)
1910+
&& !pfile->state.skipping)
1911+
cpp_warning_with_line (pfile, CPP_W_CXX11_COMPAT,
1912+
token->src_loc, 0, "C++11 requires a space "
1913+
"between string literal and macro");
19081914

19091915
pfile->buffer->cur = cur;
19101916
create_literal (pfile, token, base, cur - base, type);

0 commit comments

Comments
 (0)