Skip to content

Commit 1f1835b

Browse files
committed
C++ frontend: tolerate namespace attributes
Libstdc++ from g++7 contains: namespace std { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } We need to tolerate the construct (without doing anything useful with the attribute) to be able to use any includes from that version of the standard library.
1 parent e5d1c12 commit 1f1835b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/cpp/parse.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,20 @@ bool Parser::rNamespaceSpec(cpp_namespace_spect &namespace_spec)
856856
namespace_spec.set_namespace(name);
857857
namespace_spec.set_is_inline(is_inline);
858858

859+
// Tolerate constructs such as:
860+
// inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
861+
// which occurs in glibc. Obviously we need to better than just throw attribs
862+
// away like this in the future.
863+
if(lex.LookAhead(0)==TOK_GCC_ATTRIBUTE)
864+
{
865+
cpp_tokent tk;
866+
lex.get_token(tk);
867+
868+
typet discard;
869+
if(!rAttribute(discard))
870+
return false;
871+
}
872+
859873
switch(lex.LookAhead(0))
860874
{
861875
case '{':

0 commit comments

Comments
 (0)